Skip to content

fix: offer aws sso login for a role profile with an SSO source profile - #935

Draft
cchu-ld wants to merge 1 commit into
mainfrom
cchu/aws-sso-shared-config
Draft

cchu-ld wants to merge 1 commit into
mainfrom
cchu/aws-sso-shared-config

Conversation

@cchu-ld

@cchu-ld cchu-ld commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Follow-up to #919.

Describe the solution you've provided

  • Problem: A role profile with role_arn and source_profile gets its credentials from the source profile. If the source profile uses SSO and its token expires, the command did not offer aws sso login. The error told you to run aws sts get-caller-identity.
    • Solution: SSOProfile reads the profile with awsconfig.LoadSharedConfigProfile. It follows source_profile and returns the first profile in the chain that uses SSO. The prompt and the error name that profile, because aws sso login needs the profile with the SSO configuration.
  • Problem: HasSSOConfig parsed the INI file by hand, next to the SDK parser. The two parsers can disagree.
    • Solution: HasSSOConfig, sectionProfile, and ConfigFilePath are gone. credentialsFilePath and configFilePath replace sharedConfigPaths, and they use the SDK default paths.
  • Problem: ssoLogin had its own configPath, but noCredentialsError read AWS_CONFIG_FILE. The prompt and the error message could read different files.
    • Solution: ssoLogin has no configPath. Both read the same files. The tests set AWS_CONFIG_FILE.

The SDK parser needs the [sso-session] section of an sso_session profile. Without it, LoadDefaultConfig fails before this check, so no real run changes. The test configurations now include the section.

Describe alternatives you've considered

The review also found that one failure reads the configuration files several times. A fix is to resolve the SSO profile once in NewClients and keep it on the error. This change moves about ten tests from cmd/aws_devops_agent to internal/awsdevops, and it saves a few file reads on a failure path. I did not do it in this PR.

Additional context

TestSSOTokenInvalidForEachSDKCase has a new case. It uses the real SDK for a role profile with an sso_session source profile and no cached token.

🤖 Generated with Claude Code

SSOProfile now reads the profile with the SDK parser, and not with a
hand parser. It follows source_profile, so a role profile with an SSO
source profile gets the login offer. The login and the error name the
source profile, because that profile has the SSO configuration.

The SDK parser needs the [sso-session] section of an sso_session
profile. Without that section, the SDK cannot load the profile, so the
command fails before this check.

ConfigFilePath, HasSSOConfig, and the injected configuration path in
ssoLogin are gone. The error message and the login decision now read
the same files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant