https://pulumi.com logo
#typescript
Title
# typescript
i

icy-controller-6092

10/24/2022, 4:36 AM
I think I’ve figured it out….
policy: pulumi.output({ … }).apply(v => JSON.stringify(v))
b

billowy-army-68599

10/24/2022, 3:09 PM
@icy-controller-6092 yep that works! there’s two approaches in here: https://github.com/jaxxstorm/pulumi-examples/blob/main/typescript/aws/s3-cloudfront/index.ts
s

salmon-account-74572

10/24/2022, 3:11 PM
I was going to suggest
pulumi.interpolate
as well. 🙂
i

icy-controller-6092

10/24/2022, 10:36 PM
thanks, I didn’t know about
.all().apply
approach, I think I like
.output().apply
the most as there’s less repeating value names previously I’d used
pulumi.interpolate
but kept getting errors as the JSON syntax has to be exact - you must quote all object keys, no trailing commas, etc. And the worst part was you wouldn’t find out about the syntax error until you go to run
up
… and even then it wouldn’t tell you the location of the error, so you’d have to visually scan potentially hundreds of lines of policy JSON to try and find where you did or didn’t leave a comma hehe.