What’s a good example of using `Output<T>` (...
# aws
w
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
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
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
you're trying to interpolate a pulumi output into a string, right?
w
derp, yep. I had a typo, and did not read the error right. THanks a bunch.
l
The Bucket class has an
arn
property, does it do what you need? That would allow you to avoid any interpolation.
🙌 1
w
used the
.bucket
property and it worked fine (need to restrict to paths in the policy. Thanks!