white-balloon-205
creamy-potato-29402
09/17/2018, 10:41 PMaloof-tailor-93191
09/17/2018, 10:43 PMRegisterResourceOutputs
to see how scary it might be to make a stab at implementing itwhite-balloon-205
incalculable-sundown-82514
09/17/2018, 10:54 PMaloof-tailor-93191
09/17/2018, 10:55 PMaloof-tailor-93191
09/17/2018, 11:15 PMaloof-tailor-93191
09/17/2018, 11:15 PMpackage main
import (
"<http://github.com/pulumi/pulumi-aws/sdk/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/go/aws/ec2>"
"<http://github.com/pulumi/pulumi/sdk/go/pulumi|github.com/pulumi/pulumi/sdk/go/pulumi>"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
config := &ec2.InstanceArgs{
Ami: "ami-51537029",
AssociatePublicIpAddress: true,
InstanceType: "t2.micro",
}
inst, err := ec2.NewInstance(ctx, "test", config)
if err != nil {
return err
}
// Export the public IP of the instance
ctx.Export("inst", inst.PublicIp)
return nil
})
}
aloof-tailor-93191
09/17/2018, 11:15 PMaloof-tailor-93191
09/17/2018, 11:16 PM// RegisterResourceOutputs completes the resource registration, attaching an optional set of computed outputs.
func (ctx *Context) RegisterResourceOutputs(urn URN, outs map[string]interface{}) error {
fmt.Println(outs)
_, outsMarshalled, _, err := marshalInputs(outs)
if err != nil {
return errors.Wrap(err, "marshaling arguments")
}
// Note that we're about to make an outstanding RPC request, so that we can rendezvous during shutdown.
if err = ctx.beginRPC(); err != nil {
return err
}
// Kick off the resource registration. If we are actually performing a deployment, the resulting properties
// will be resolved asynchronously as the RPC operation completes. If we're just planning, values won't resolve.
go func() {
glog.V(9).Infof("RegisterResourceOutputs(%s): Goroutine spawned, RPC call being made", urn)
_, err := ctx.monitor.RegisterResourceOutputs(ctx.ctx, &pulumirpc.RegisterResourceOutputsRequest{
Urn: string(urn),
Outputs: outsMarshalled,
})
if err != nil {
glog.V(9).Infof("RegisterResource(%s): error: %v", urn, err)
} else {
glog.V(9).Infof("RegisterResource(%s): success: %s %s ...", urn)
}
// Signal the completion of this RPC and notify any potential awaiters.
ctx.endRPC()
}()
return nil
}
aloof-tailor-93191
09/17/2018, 11:16 PMaloof-tailor-93191
09/17/2018, 11:17 PMPreviewing update of stack 'ptest-dev'
Previewing changes:
Type Name Plan Info
* pulumi:pulumi:Stack ptest-ptest-dev no change 1 error, 2 info messages
0x9e
Diagnostics:
pulumi:pulumi:Stack: ptest-ptest-dev
info: map[inst:0x9eaef0]
pulumi:pulumi:Stack: ptest-ptest-dev
info: error: program failed: 1 error occurred:
* marshaling arguments: awaiting input property inst: unrecognized input property type: 0x9eaef0 (func() *pulumi.StringOutput)
pulumi:pulumi:Stack: ptest-ptest-dev
error: an unhandled error occurred: program exited with non-zero exit code: 1
error: an error occurred while advancing the preview
aloof-tailor-93191
09/17/2018, 11:17 PMincalculable-sundown-82514
09/17/2018, 11:53 PMincalculable-sundown-82514
09/17/2018, 11:54 PMincalculable-sundown-82514
09/17/2018, 11:55 PMincalculable-sundown-82514
09/17/2018, 11:55 PMaloof-tailor-93191
09/17/2018, 11:55 PMincalculable-sundown-82514
09/17/2018, 11:56 PMaloof-tailor-93191
09/17/2018, 11:56 PMctx.Export("inst", inst.PublicIp())
tooincalculable-sundown-82514
09/17/2018, 11:56 PMaloof-tailor-93191
09/17/2018, 11:57 PMPreviewing update of stack 'ptest-dev'
Previewing changes:
Type Name Plan Info
+ pulumi:pulumi:Stack ptest-ptest-dev create 1 error, 2 info messages
+ └─ aws:ec2:Instance test create
Diagnostics:
pulumi:pulumi:Stack: ptest-ptest-dev
info: error: program failed: 1 error occurred:
* attempted illegal RPC after program completion
pulumi:pulumi:Stack: ptest-ptest-dev
info: map[inst:0xc00000e898]
pulumi:pulumi:Stack: ptest-ptest-dev
error: an unhandled error occurred: program exited with non-zero exit code: 1
error: an error occurred while advancing the preview
aloof-tailor-93191
09/17/2018, 11:57 PMincalculable-sundown-82514
09/17/2018, 11:57 PMaloof-tailor-93191
09/17/2018, 11:58 PMaloof-tailor-93191
09/17/2018, 11:58 PMincalculable-sundown-82514
09/17/2018, 11:58 PMaloof-tailor-93191
09/17/2018, 11:58 PMaloof-tailor-93191
09/17/2018, 11:59 PMincalculable-sundown-82514
09/17/2018, 11:59 PM