Update ChainSetup and IdentityChain interface - #759
Conversation
| access_key_id = _get_string(profile, _ACCESS_KEY_ID) | ||
| secret_access_key = _get_string(profile, _SECRET_ACCESS_KEY) | ||
| access_key_id = config_file.get(profile_name, _ACCESS_KEY_ID) | ||
| secret_access_key = config_file.get(profile_name, _SECRET_ACCESS_KEY) |
There was a problem hiding this comment.
This runs before ProfileAssumeRole and terminates assembly, so a profile with both static keys and role_arn resolves to the raw user keys and the role is never assumed. This breaks the standard self-referencing pattern, where the keys are only the source credentials for the STS call:
[profile deploy]
role_arn = arn:aws:iam::999999999999:role/Deployer
source_profile = deploy
aws_access_key_id = AKIA... # near-zero-permission user, only sts:AssumeRole
aws_secret_access_key = ... # real permissions live on the rolebotocore gives role_arn precedence: botocore's assume-role provider runs before the static-keys providers and claims any profile containing role_arn, regardless of static keys (_has_assume_role_config_vars).
Let me know what you think.
There was a problem hiding this comment.
Boto3's credential chain order is legacy and places assume role credentials directly after environment (docs).
However, modern SDKs must follow the order defined in the StandardProvider enum. This means that self-referencing profiles will not be respected if used in a chain.
They are still respected if you use the assume role resolver on its own.
Description
This PR refactors
ChainSetupto store the resolved profile name instead of a parsed profileSection.Downstream providers (e.g. assume-role) need
ChainSetupto store the resolved profile name for cycle tracking. Storing the parsedSectionalongside it would make the profile reachable two ways,setup.profileandsetup.profile_file.get_profile(setup.profile_name), duplicating state. Usingprofile_nameas the single source of truth lets providers read values consistently throughMergedConfig.get(profile_name, key). That call also performs the string validation the previous_get_stringhelpers provided, so each provider no longer needs its own copy of that logic.This PR also renames
profile_file/profile_name_overridetoconfig_file/profile_namefor consistency, and updates theEcsContainermodule suggestion fromaws-credentials-ecstoaws-credentials-http.Testing
make check-pyandmake test-py.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.