is it possible to convert `pulumi.StringOutout` to...
# golang
q
is it possible to convert
pulumi.StringOutout
to a
string
?, the
applyString
is just a transformer. I have templates that need outputs from a pulumi
resource
output that takes in a
string
only
c
Did you try and use
pulumi.Sprintf
?
q
it also returns
pulumi.StringOutput
i
I wrote some helper code that takes outputs, uses
ApplyT
to wait for them to resolve and then renders a Go template from that… i’ll clean it up a bit and push it to Github
i then can do things like this:
Copy code
// Grant Cloudfront access to the content bucket
		_, err = s3.NewBucketPolicy(ctx, "staticSitePolicy-"+host, &s3.BucketPolicyArgs{
			Bucket: bucket.Bucket.Bucket,
			Policy: pulutil.JSONTemplate(map[string]interface{}{
				"BucketARN":   bucket.BucketArn,
				"IdentityARN": identity.IamArn,
			}, `{
						"Version": "2012-10-17",
						"Id": "PolicyForCloudFrontPrivateContent",
						"Statement": [
							{
								"Effect": "Allow",
								"Principal": {
									"AWS": "{{ .IdentityARN }}"
								},
								"Action": "s3:GetObject",
								"Resource": "{{ .BucketARN }}/*"
							}
						]
					}`),
		})
the template there is just a normal Go template..
JSONTemplate
just does an additional check at the end to make sure the output is valid JSON before handing it off to Pulumi; get more useful error messages that way
q
Thanks @important-appointment-55126 🤞
meanwhile I can try
ApplyT
i
Uploaded my code with an example that i hope is useful: https://pkg.go.dev/github.com/gwatts/pulutil/template/#example-NewJSON
❤️ 1