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

quiet-painter-30539

06/30/2020, 8:10 AM
I'm creating a bucket and a bucket policy using Pulumi / Python. How to get the bucket arn from a bucket resource for creating the bucket policy? If I try to get the bucket arn in the same
pulumi up
run (i.e. creating the bucket and bucket policy) I get
required field is not set
.
l

loud-battery-37784

06/30/2020, 1:08 PM
You’re getting the error trying access
bucket.arn
with something like:
Copy code
import pulumi
import pulumi_aws as aws

bucket = aws.s3.Bucket("newBucket")
Maybe try
bucket.id
instead?
g

gentle-diamond-70147

06/30/2020, 5:47 PM
q

quiet-painter-30539

07/01/2020, 6:42 AM
I found a way to do it yesterday:
Copy code
policy = bucket.id.apply(lambda id:
            '''
            {{
...
               "Resource": "arn:aws:s3:::{my_id}/*"
...
'''.format(my_id=id)...