I'm creating a bucket and a bucket policy using Pu...
# python
q
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. If I try to get the id from the bucket I just get the Output object - how to convert that to string?
f
Is the
arn
always
arn:aws:s3:::bucket_name
?
The other way might be to “apply” the
arn
similar to this
Copy code
<https://github.com/pulumi/examples/blob/master/aws-py-assume-role/create-role/__main__.py#L41>
s
Copy code
bucket = aws.s3.Bucket("name")
arn = bucket.arn
g
You do need to apply the arn if you're building out the entire bucket policy json. Here's an example - https://github.com/pulumi/examples/blob/ec43670866809bfd64d3a39f68451f957d3c1e1d/aws-py-s3-folder/__main__.py#L21-L39.
q
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)...