Skip to content

Update ChainSetup and IdentityChain interface - #759

Merged
jonathan343 merged 2 commits into
smithy-lang:developfrom
arandito:update-chain-setup
Jul 31, 2026
Merged

Update ChainSetup and IdentityChain interface#759
jonathan343 merged 2 commits into
smithy-lang:developfrom
arandito:update-chain-setup

Conversation

@arandito

Copy link
Copy Markdown
Contributor

Description

This PR refactors ChainSetup to store the resolved profile name instead of a parsed profile Section.

Downstream providers (e.g. assume-role) need ChainSetup to store the resolved profile name for cycle tracking. Storing the parsed Section alongside it would make the profile reachable two ways, setup.profile and setup.profile_file.get_profile(setup.profile_name), duplicating state. Using profile_name as the single source of truth lets providers read values consistently through MergedConfig.get(profile_name, key). That call also performs the string validation the previous _get_string helpers provided, so each provider no longer needs its own copy of that logic.

This PR also renames profile_file/profile_name_override to config_file/profile_name for consistency, and updates the EcsContainer module suggestion from aws-credentials-ecs to aws-credentials-http.

Testing

  • Updated tests with new interfaces
  • Ran make check-py and make 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.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 role

botocore 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.

@arandito arandito Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jonathan343 jonathan343 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonathan343
jonathan343 merged commit cae847a into smithy-lang:develop Jul 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants