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

worried-queen-40276

06/01/2022, 6:17 PM
Hi All, How can I use the bucket name inside a inline policy json using pulumi in python e.g.
Copy code
mlflow_s3_policy = aws.iam.RolePolicy("mlflow_s3_policy",
                                      role=mlflow_s3_role.id,
                                      policy=json.dumps({
                                          "Version": "2012-10-17",
                                          "Statement": [{
                                              "Action": "*",
                                              "Effect": "Allow",
                                              "Resource": mlflow_bucket.bucket.apply(lambda bucket_name: f'arn:aws:s3:::{bucket_name}/*'),
                                          }],
                                      }))
I get the following error
Copy code
TypeError: Object of type Output is not JSON serializable
w

witty-candle-66007

06/01/2022, 6:27 PM
Try putting the
json.dumps()
block inside of the apply. So something like
Copy code
policy = mlflow_bucket.bucket.apply(lambda bucket_name: json.dumps({ . use bucket_name in here...})`
w

worried-queen-40276

06/01/2022, 7:29 PM
That worked @witty-candle-66007 Thank you.
94 Views