Prioritize assume role credentials and deprecate built-in network providers - #773
Conversation
…IC_KEYS in StandardProvider
…role configuration exists in profile
…red in IdentityChain.create()
| if config_file is None or profile_name is None: | ||
| return | ||
|
|
||
| if config_file.get(profile_name, _ROLE_ARN) is not None: |
There was a problem hiding this comment.
[The comment applies to line 81 as well]
With this deferment, consider a user whose profile looks like:
[default]
aws_access_key_id = AKIA...
aws_secret_access_key = ...
role_arn = arn:aws:iam::123:role/Foo
source_profile = defaultbut who doesn't have aws-credentials-sts installed. The profile key providers now defer, the assume-role provider isn't discovered, and _find_unclaimed_sources can't flag it either - PROFILE_ASSUME_ROLE.is_detected() is always False. So the user gets an IdentityChainError with no "install aws-credentials-sts" suggestion, but the SEP says the point of deferring is that "the chain reports the missing STS module".
Is this a gap we should address?
There was a problem hiding this comment.
I am aware of this gap. However adding it to this PR expands its scope. This PR focuses on behavioral changes we want to get in before our next release. The module suggestions improves customer experience but doesn't change behavior.
I already have a follow up PR to add better module suggestions which will add profile based provider suggestions to ChainSetup at the SharedConfigProvider. We should try to squeeze it in but can definitely wait until a future release.
| if identity_type is not AWSCredentialsIdentity: | ||
| return | ||
|
|
||
| if setup.profile_name is not None: |
There was a problem hiding this comment.
PR #771 passes config_context.profile_name into IdentityChain.create(), but it looks like SharedConfigContext.profile_name is never None? It falls back to AWS_PROFILE, then default.
smithy-python/packages/smithy-aws-core/src/smithy_aws_core/config/context.py
Lines 184 to 201 in c0150aa
So once both PRs land, a user with just AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY set and
no profile configured still gets the environment provider skipped.
Since the context already tracks profile_origin, should #771 pass the profile only when it came from the explicit argument?
There was a problem hiding this comment.
Good catch. I'll update #771 to only set the profile if its origin is an explicit override.
Description
This PR aligns credential resolution behavior with the modular credential chain spec changes:
role_arn.profile_nameis provided.This PR also deprecates the built-in IMDS and container resolvers in favor of
aws-credentials-imdsandaws-credentials-http.Testing
aws-credentials-stspackage andaws-sdk-stsclientBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.