Open rcousens opened 2 years ago
I've done some further investigation by recreating the problem in a less restricted environment and it appears the log entry may be misleading and it might just log the region before the client is actually used and subsequently it's actually set by the sts_endpoint parameter etc. I still think the log message is wrong but probably not related to my problem.
I think my issue is more likely to do with the fact that I can't access other AWS APIs like iam.amazonaws.com
within my environment (there's only an STS endpoint currently)
I've also found out through my testing that Vault can't use the sts format of an ARN with assumed-role in it. Is this true? I have to specify the principal ARN of the actual role that is assumed?
The downside of this is I lose user information in an SSO federated login environment.
So, I've answered my own questions here by doing a bit of investigation with tcpdump.
iam.amazonaws.com
to both add a role and then complete a login. IAM currently has no endpoint service in AWS, so Vault needs outbound internet network access, at least to iam.amazonaws.comfull_arn
, and then adding token metadata such that the client_arn is logged reveals the originating SSO user in audit logs, i.e.vault write auth/aws/config/identity iam_alias=full_arn iam_metadata=account_id,auth_type,canonical_arn,client_arn
So I think there is a bug here re the logs, it should read the sts_region
first and try and locate a cached client against the specified region instead of using the default us-east-1
and then overriding the region. At least that's my naive take?
@rcousens It looks like the we need to add support for regional STS endpoints to Vault. While debugging, I found this comment which states that STS endpoints are global. This is old since regional STS endpoints were released by AWS in 2019.
I can take a look at addressing this. Due to the assumption that we're using global STS, the region
argument doesn't make it the method that makes the call to AWS.
Describe the bug No matter what configuration is provided, I am incapable of getting vault server via vault CLI to use an STS client for an alternative region that is not 'us-east-1' when doing an IAM auth login
To Reproduce Steps to reproduce the behavior:
vault auth enable aws
vault write auth/aws/config/client sts_endpoint=https://sts.ap-southeast-2.amazonaws.com sts_region=ap-southeast-2
vault write auth/aws/role/test auth_type=iam bound_iam_principal_arn="arn:aws:sts::xxxxxxxx:assumed-role/SSO_Admin_Role/*"
vault login -token-only -method=aws role=test region=ap-southeast-2
, CLI client hangs untilcontext deadline exceeded
vault[5370]: 2022-04-19T04:43:28.014Z [DEBUG] auth.aws.auth_aws_0305af05: no cached client for region us-east-1 and stsRole
Expected behavior The region in the server debug logs for the STS client should be ap-southeast-2, us-east-1 is not valid in my environment (no net access)
Environment: Server version: 1.10.0 CLI version: 1.10.0 Server OS: Ubuntu AMD64
Vault server configuration file(s):
Additional context Strangely enough, when I specify a different region on the CLI, I get an error:
vault login -token-only -method=aws role=test region="us-east-1"