clever-kite-79772
08/02/2023, 12:17 PMpulumi.StringOutput
and then use it in ctx.Export
?melodic-tomato-39005
08/02/2023, 2:18 PMStringOutput
as is. An example with an S3 bucket, Region
is a `StringOutput`:
ctx.Export("bucketRegion", bucket.Region)
clever-kite-79772
08/02/2023, 2:25 PM./main.go:65:27: cannot use pairResources (variable of type map[pulumi.String]KeyPairExport) as pulumi.Input value in argument to ctx.Export: map[pulumi.String]KeyPairExport does not implement pulumi.Input (missing method ElementType)
or
error: an unhandled error occurred: program failed:
waiting for RPCs: json: error calling MarshalJSON for type pulumi.StringOutput: Outputs can not be marshaled to JSON
melodic-tomato-39005
08/02/2023, 2:28 PMpulumi.Output()
on your map, or you might need to range
over the map and export the elements.clever-kite-79772
08/02/2023, 3:11 PMtype KeyPairExport struct {
KeyName pulumi.StringOutput `pulumi:"key_name"`
Id pulumi.StringOutput `pulumi:"id"`
}
pairResources := make(map[pulumi.String]KeyPairExport)
for _, kp := range keyPairs {
nkp, _ := ec2.NewKeyPair(ctx, kp.Name, &ec2.KeyPairArgs{
KeyName: pulumi.String(environment + "-key-pair-" + kp.Name),
PublicKey: pulumi.String("ssh-rsa key"),
Tags: tags,
})
pairResources[pulumi.String(kp.Name)] = KeyPairExport{
KeyName: nkp.KeyName,
Id: nkp.KeyPairId,
}
}
ctx.Export("key-pairs", pairResources)
Is it possible to make it workable.
That I can use dict of keys in other projects.melodic-tomato-39005
08/02/2023, 3:40 PMctx.Export("key-pairs", pulumi.ToOutput(pairResources))
should work.clever-kite-79772
08/02/2023, 4:19 PMerror: an unhandled error occurred: program failed:
waiting for RPCs: cannot marshal an input of type pulumi.StringOutput with element type string as a value of type pulumi.StringOutput
.Export
- it works.