This message was deleted.
# python
s
This message was deleted.
s
Solved, thanks to the first answer here: https://stackoverflow.com/questions/42444130/python-multi-line-json-and-variables We just need to do this:
Copy code
import pulumi_aws as aws

iam_role = aws.iam.Role(
        "my-role",
        name="my-role",
        assume_role_policy="""{
                ...
            }
        """,
        inline_policies=[
            aws.iam.RoleInlinePolicyArgs(
                name=f"my-policy-{stack_name}",
                policy="""{
                            "Version": "2012-10-17",
                            "Statement": [
                                {
                                    "Effect": "Allow",
                                    "Action": [
                                        "dynamodb:BatchGetItem",
                                        "dynamodb:GetItem",
                                        "dynamodb:Query",
                                        "dynamodb:Scan",
                                    ],
                                    "Resource": "arn:aws:dynamodb:ap-northeast-1:123456:table/myTablesPrefix-{stack_name}-*"
                                }
                            ]
                        }
                    """.format(stack_name=stack_name)
            ),
        ],
    )
s
I think you'll have an easier time with IAM policies using
json.dumps
for what it's worth. Writing a Python map is significantly easier and less fragile.