https://pulumi.com logo
#aws
Title
# aws
w

white-secretary-18260

03/25/2021, 6:54 PM
What’s a good example of using
Output<T>
(in typescript) to use a generated bucket name
new-bucket-[the magic hash number]
in a previous task as a string value in an IAM policy in a later script:
Copy code
const importPolicy = {
    Version: '2012-10-17',
    Statement: [
      {
        Sid: 's3Import',
        Action: [
          's3:GetObject',
          's3:ListBucket'
        ],
        Effect: 'Allow',
        Resource: [
          `arn:aws:s3:::${newS3.bucket}`, // <-- does not work
          `arn:aws:s3:::${newS3.bucket}/*` // <-- does not work
        ]
      }
    ]
  }
w

white-secretary-18260

03/25/2021, 7:06 PM
hehe you are not using that code (https://github.com/pulumi/examples/blob/e942d6130cd402d48db56889581ce2db1879803f/kubernetes-ts-s3-rollout/s3Helpers.ts#L39). This helps me understand, but this returns
Output<string>
I need
Input<string>
, I think I saw an example on converting this….
m

microscopic-dress-1605

03/25/2021, 7:08 PM
If I’m not wrong you can assign an
Ouput<string>
to an
Input<string>
.
To convert an
Input
to an
Output
you need
pulumi.output(input)
b

billowy-army-68599

03/25/2021, 7:12 PM
you're trying to interpolate a pulumi output into a string, right?
w

white-secretary-18260

03/25/2021, 7:13 PM
derp, yep. I had a typo, and did not read the error right. THanks a bunch.
l

little-cartoon-10569

03/25/2021, 7:55 PM
The Bucket class has an
arn
property, does it do what you need? That would allow you to avoid any interpolation.
🙌 1
w

white-secretary-18260

03/25/2021, 11:22 PM
used the
.bucket
property and it worked fine (need to restrict to paths in the policy. Thanks!