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

sticky-bear-14421

06/20/2023, 9:54 AM
I have the following simplified resource:
Copy code
new aws.s3.BucketPolicy("pulumi-infrastructure-bucket-policy", {
        bucket: bucket.bucket,
        policy: 
            `
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::infrastructure.pulumi.dev",
                "arn:aws:s3:::infrastructure.pulumi.dev/*"
            ],
            "Condition": {
                "Bool": {
                    "aws:SecureTransport": "false"
                }
            }
        }
    ]
}`,
    });
I would like to make those two Resource definitions dynamic, but when I switch to the
${bucket.arn}
notation I get an error that my string literal contains a
\n
somehow. Even though I am inside a backticks backed string.
e

echoing-dinner-19531

06/20/2023, 10:06 AM
arn
is an output, you can't use that with backtick formatting. Look at the docs at https://www.pulumi.com/docs/concepts/inputs-outputs/#outputs-and-strings and for JSON policies like this https://www.pulumi.com/docs/concepts/inputs-outputs/#outputs-and-json
s

sticky-bear-14421

06/21/2023, 7:30 AM
@echoing-dinner-19531 Yeah, I wrapped my whole stack in a
const main = async () => {} …
construct and made the wrong assumption that a
const bucket = await new aws.s3.bucket()
would resolve the Promise/Output.
Happy layer 8 problem on my side. Still learning the details about TypeScript every day
e

echoing-dinner-19531

06/21/2023, 7:39 AM
Yeh no worries, output values are the most unusual part of the Pulumi SDKs. Nearly everyone trips up on them first day.
s

sticky-bear-14421

06/21/2023, 12:34 PM
Hehe, yes. I thought I had mastered them, but my naive thinking of await new .. threw me off track. 🙂