Hi All, How can I use the bucket name inside a in...
# general
w
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
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
That worked @witty-candle-66007 Thank you.
112 Views