On occasion, I need to access multiple AWS resources that I have individual access for with separate IAM roles. If I need these resources to be used together, I currently have to figure out a non-native connector piece.
If I could access the resources together at the same time, I can sometimes use an AWS connector to interface with both resources at once (for example).
Is there a way to assume multiple IAM roles at the same time?
An instance profile can contain only one IAM role. This limit cannot be increased.
You can assume a role from an assumed role. Account C would have a role that trusts account B. Account B would have a role that trusts account A. Each role would also have to have permissions for sts:AssumeRole on the role that account is assuming.
You must explicitly grant your users permission to assume the role. Your users must actively switch to the role using the AWS Management Console or assume the role using the AWS CLI or AWS API.
You can assume a role by calling an AWS CLI or API operation or by using a custom URL. The method that you use determines who can assume the role and how long the role session can last. ¹ Using the credentials for one role to assume a different role is called role chaining.
Technically, yes, there is a way to assume multiple IAM roles at the same time.
But it doesn't mean what you intend.
Assuming an IAM role doesn't modify who you are and doesn't modify what permissions you have -- contrary to the intuitive interpretation of what it might mean to assume a different identity. Instead, when you assume a role, you are given a new set of temporary credentials to use, instead of "your" credentials -- the credentials you used to assume the role.
Requests made with these temporary credentials are authorized against the permissions granted to the role.
Thus, while you can assume multiple roles at the same time, each of those actions has a separate set of associated credentials, so it won't allow you to make requests that require you to have the permissions of more than one role for any given request.
Every request is performed by a single principal, so if you are trying to perform a single action that requires the union of the permissions of multiple roles, that's a not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With