The Golang example for setting up <CloudTrail and ...
# aws
g
The Golang example for setting up CloudTrail and an S3 BucketPolicy does something a bit weird:
Copy code
Policy: pulumi.All(bucket.ID(), bucket.ID()).ApplyT(func(_args []interface{}) (string, error) {
	bucketId := _args[0].(string)
	bucketId1 := _args[1].(string)
	// Policy fmt.Sprintf() here
}
Why is
bucket.ID()
repeated 2x in the
pulumi.All()
, and then assigned to two separate variables,
bucketId
and
bucketId1
? It's the same resource, so why does it need to be referenced 2x for the same policy doc? Is there some extra magic going on under the hood?
f
Nope, nothing magic going on under the hood. All the examples in our documentation are automatically generated from a common source, so itโ€™s likely either the original example was written in a way that causes this to use two variables or itโ€™s a bug in the automated code generation.
๐Ÿ‘ 1
w
I do think this is something we can improve in the code generation for these examples. Opened https://github.com/pulumi/tf2pulumi/issues/230 to track this.
๐Ÿ™Œ 1
g
Great to hear x2 -- thank you both ๐Ÿ™