sparse-intern-71089
08/03/2021, 5:22 PMlemon-agent-27707
08/03/2021, 9:28 PMctx.Export
should be top level in your pulumi.Run
func. The reason why you're seeing this behavior is due async work and the order of operations. What happens in your program above:
1. Program starts running
2. async work is scheduled via Provider.Apply
3. "output" is exported (internal impl is saving this output value in a private map on the context object
4. Your function finished executing - there may still be outstanding async work
5. The pulumi runtime registers stack outputs - https://github.com/pulumi/pulumi/blob/070125e6851f21a4a82290ed94dca43e49c76422/sdk/go/pulumi/run.go#L108
6. The pulumi runtime awaits outstanding async work
7. Your provider.apply
runs once the dependencies are fulfilled
8. When the apply runs, it tries to register stack outputs to no effect. The stack outputs were already registered in step (5).lemon-agent-27707
08/03/2021, 9:30 PMctx.Export
inside apply. The pattern is to instead return the value you want to export from an apply as an output, and then export that output at the top level.
Second thing I'll mention is that creating resources inside of apply is an anti-pattern. Best to avoid it if possible.quiet-architect-91246
08/03/2021, 9:41 PMlemon-agent-27707
08/03/2021, 9:42 PMcluster
?quiet-architect-91246
08/03/2021, 9:43 PMcluster, err := eks.NewCluster(ctx, "cluster",
&eks.ClusterArgs{
InstanceType: pulumi.String("t2.medium"),
DesiredCapacity: <http://pulumi.Int|pulumi.Int>(2),
MinSize: <http://pulumi.Int|pulumi.Int>(1),
MaxSize: <http://pulumi.Int|pulumi.Int>(2),
RoleMappings: eks.RoleMappingArray{
eks.RoleMappingArgs{
Groups: pulumi.StringArray{
pulumi.String("system:nodes"),
pulumi.String("system:bootstrappers"),
pulumi.String("eks-console-dashboard-full-access-group"),
},
RoleArn: pulumi.String("arn:aws:iam::964790551434:role/Administrator"),
Username: pulumi.String("testuser"),
},
},
},
)
lemon-agent-27707
08/03/2021, 9:45 PMlemon-agent-27707
08/03/2021, 9:46 PMlemon-agent-27707
08/03/2021, 9:49 PMquiet-architect-91246
08/03/2021, 9:56 PMlemon-agent-27707
08/03/2021, 10:01 PMcluster.Kubeconfig.ApplyT(func(v interface{})( string, error) {
var result string
result, ok := v.(string)
if !ok {
return result, errors.New("kubeconfig was not a string")
}
return result, ok
}).(pulumi.StringOutput)
lemon-agent-27707
08/03/2021, 10:01 PMquiet-architect-91246
08/03/2021, 10:11 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by