Skip to content

aws: keep other URL options when assuming a role - #3849

Merged
vangent merged 1 commit into
google:masterfrom
iamabhilaksh:aws-role-keep-options
Nov 22, 2026
Merged

vangent merged 1 commit into
google:masterfrom
iamabhilaksh:aws-role-keep-options

Conversation

@iamabhilaksh

@iamabhilaksh iamabhilaksh commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

URL openers take their AWS settings from the URL. For example:

s3://my-bucket?region=us-east-1&fips=true&role=arn:aws:iam::123456789012:role/my-role

That URL holds two kinds of settings:

  • Which identity to use: role means "assume this role before calling AWS".
  • How to connect: fips, dualstack, profile, request_checksum_calculation and response_checksum_validation.

When role is set, V2ConfigFromURLParams works in three steps (aws.go#L203-L211):

  1. It builds a config from all the URL options.
  2. It uses that config to call STS and get the role's credentials.
  3. It builds the returned config, which the S3, SQS or other service client uses, from a new list containing only the role's credentials and the region.

Step 3 starts from scratch, so every connection option is dropped and no error is reported. STS gets the options, but the service client, which is the one that actually matters, doesn't. With the URL above:

  • STS uses the FIPS endpoint, as expected.
  • S3 uses the regular endpoint, even though fips=true was set.

The checksum options are dropped the same way, so S3 keeps sending checksums the user turned off. endpoint and rate_limiter_capacity still work, because they're applied after this step.

The list has been replaced like this since role was added in #3716. #3732 moved this step so STS gets the options, but step 3 still starts from the new list.

Change

  • aws/aws.go: in step 3, append the role's credentials to the existing options instead of starting a new list. The role's credentials still win, because they're added last.
  • TestV2ConfigFromURLParamsAssumeRoleKeepsOptions: sets role with fips, dualstack and both checksum options, then checks that all of them reach the returned config.
  • TestV2ConfigFromURLParamsAssumeRoleKeepsProfile: sets role with a profile that has its own keys and request_checksum_calculation = when_required. It checks that the profile's setting is kept and that the credentials still come from the role, not from the profile.

Impact and risk

  • Impact: anyone using role together with these options silently loses them on the service client. For fips, that means traffic is expected to go to FIPS endpoints but doesn't.
  • Risk: low. The only behavior change is that options already in the URL now apply. Credentials are unchanged.

Testing

  • The new tests fail on master: all 4 options are dropped, and so is the profile's setting. They pass with this change.
  • Real S3, fips=true with a role, 2 runs each:
    • Master: STS went to sts-fips.us-east-1.amazonaws.com, and S3 went to <bucket>.s3.us-east-1.amazonaws.com (not FIPS).
    • With this change: S3 went to <bucket>.s3-fips.us-east-1.amazonaws.com.
    • Without role, master already uses FIPS.
  • Real S3, both checksum options set to when_required with a role, 2 runs each:
    • Master: PutObject still sent x-amz-sdk-checksum-algorithm: CRC32 plus a CRC32 trailer, and GetObject sent x-amz-checksum-mode: ENABLED.
    • With this change: neither was sent, the same as master without role.
  • TestV2ConfigFromURLParamsAssumeRole still passes, so the role's credentials are still used.
  • go test passes for aws/..., blob/s3blob, docstore/awsdynamodb/v2, pubsub/awssnssqs, secrets/awskms, runtimevar/awsparamstore and runtimevar/awssecretsmanager.

Checks (go1.27.3 and go1.26.10): go test -race ./aws/..., go vet, gofmt -s and golangci-lint v2.14.0 pass. go.mod is unchanged.

With role set, V2ConfigFromURLParams replaced the option list with only
the assumed role's credentials and the region, so fips, dualstack,
profile and the checksum settings only reached the STS client and not
the returned config. Append the credentials provider instead.
@iamabhilaksh
iamabhilaksh marked this pull request as ready for review November 16, 2026 12:18
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.66%. Comparing base (bbb3555) to head (c56a4a8).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3849      +/-   ##
==========================================
+ Coverage   80.35%   80.66%   +0.31%     
==========================================
  Files         104      104              
  Lines       12571    12617      +46     
==========================================
+ Hits        10101    10178      +77     
+ Misses       2469     2438      -31     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vangent
vangent merged commit cde02ae into google:master Nov 22, 2026
13 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.

2 participants