Folks, How to assign multiple policies to one role...
# aws
a
Folks, How to assign multiple policies to one role. As per example, only one arn is assigned to the role. Is there any way we can assign multiple existing policies.
Copy code
policy = aws.iam.Policy("policy",
    description="A test policy",
    policy="""{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "ec2:Describe*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
""")
test_attach = aws.iam.PolicyAttachment("test-attach",
    users=[user.name],
    roles=[role.name],
    groups=[group.name],
    policy_arn=policy.arn)
b
you can just do this with a standard loop
a
that make sense, but so far no API available to attach multiple policies right!
l
The standard solution is to make a policy with multiple statements.
If you have to use multiple policies, then unfortunately you'll have to do it the long way...
a
@little-cartoon-10569 Creating multiple policies it’s still fine for me, but i am looking for a solution where we can attach multiple policies to one role.
l
As Lee said, you have to use attach them separately, and a loop will handle it. Note that there is an AWS limit of 10 policies per role.
1