:question: In python pulumi, is there a easy way t...
# python
a
In python pulumi, is there a easy way to use string formatting with variables that comes from pulumi resources, config or stack output?
this is the example from the docs
Copy code
```python
    import pulumi
    import pulumi_aws as aws

    example = aws.iam.get_policy_document(statements=[
        {
            "sid": "1",
            "actions": [
                "s3:ListAllMyBuckets",
                "s3:GetBucketLocation",
            ],
            "resources": ["arn:aws:s3:::*"],
        },
        {
            "actions": ["s3:ListBucket"],
            "resources": [f"arn:aws:s3:::{s3_bucket_name}"],
            "conditions": [{
                "test": "StringLike",
                "variable": "s3:prefix",
                "values": [
                    "",
                    "home/",
                    "home/&{aws:username}/",
                ],
            }],
        },
        {
            "actions": ["s3:*"],
            "resources": [
                f"arn:aws:s3:::{s3_bucket_name}/home/&{{aws:username}}",
                f"arn:aws:s3:::{s3_bucket_name}/home/&{{aws:username}}/*",
            ],
        },
    ])
    example_policy = aws.iam.Policy("example",
        name="example_policy",
        path="/",
        policy=example.json)
but this doesn't work if the variables in the formatting coming from statements that generate pulumi resources.