Is it possible for a pod to assume multiple IAM roles?
Its definitely possible to dynamically switch the env variable AWS_ROLE_ARN value.
But do we have a straight approach to support multiple at a time?
like,
AWS_ROLE_ARN: test
AWS_ROLE_ARN2: test-2
2
Answers
As you can read in the documentation, IAM roles for pods are working like instance profile for EC2. So you can’t use easily 2 roles at the same time.
Source : https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html
You can’t assign two Roles to your Pod. However, your Pod can assume different Roles if it needs to change its permissions at run-time.
For instance:
Create two Roles,
ProducerRole
andConsumerRole
, with appropriate permissions and the following trust policy:Create a third Role,
PodRole
, with the following permission policy:and the following trust policy:
Also give this role whatever other basic permissions its needs to be your Pod role.
Configure your EKS Pod to use
PodRole
.Inside your EKS Pod, assume either
ProducerRole
orConsumerRole
, depending on which set of permissions you need at the time.