Add ability to specify the STS region or endpoint URL in the config file when assuming a role #6754
Labels
configuration
feature-request
A feature should be added or improved.
p2
This is a standard priority issue
Is your feature request related to a problem? Please describe.
I can't assume a role in one region while issuing a command in another. Specifically, it's when the role being assumed requires the use of a specific VPC endpoint for the STS service, but the API being queried is in a different region and must be done as the role being assumed. Concrete example below.
Describe the solution you'd like
Either enhance the
sts_regional_endpoints
setting or create a new one with which we can force the use of a specific VPC endpoint or region in~/.aws/config
despite the region being passed to the AWS CLI.Describe alternatives you've considered
One workaround I've employed is to assume the role in the correct region first, then grab the temporary credentials and set them as environment variables in the call to the next AWS CLI command. This is a bit cumbersome, though.
Additional context
Here's some sample code to try out.
The below AWS CLI config is for use by an ECS task (could just as easily be on EC2--makes no difference) running in a VPC with an STS endpoint in us-east-1. The role is assumed just fine if we direct our queries to us-east-1, e.g.,
aws --region us-east-1 s3 ls
:Here's the trust relationship for
my_role
which allowsmy-ecs-task
to assume the role only through the STS VPC endpoint mentioned above.Now if you try to issue a command to any other region, you'll get a 403 saying that
my-ecs-task
is not allowed to assumemy-role
. When looking at the debug output, you'll see that the role is being assumed in the region specified by the command-line argument:The deny is expected. But it would be convenient if we could force the region that the role assumption happens in.
The text was updated successfully, but these errors were encountered: