Repository navigation
DRIVERS-3723: Restore the instance profile in auth_aws teardown - #926
Merged
Merged
Conversation
adelinowona
requested review from
PavelSafronov and
blink1073
and
a balanced review from Copilot
and removed request for
PavelSafronov
November 6, 2026 01:28
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the AWS authentication teardown change.
No open issues 🎉
What changed in this PR
Fixes AWS authentication teardown so ambient credentials from another account do not prevent restoration of the host’s EC2 instance profile.
Changes:
- Clears the three AWS credential environment variables before sourcing secrets, matching
aws_setup.sh. - Adds a comment explaining why ambient credentials must be cleared.
| File | Description |
|---|---|
.evergreen/auth_aws/teardown.sh |
Clears ambient AWS credentials so profile restoration can use the instance account’s credentials. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DRIVERS-3723
Summary
After the web identity test detaches the host's EC2 instance profile,
auth_aws/teardown.shrunsaws_assign_instance_profile.pyto put it back. The call fails withInvalidInstanceID.NotFoundand prints a traceback, but the command ends in|| true, so the task still passes and the profile is never restored.The cause is that the task's secrets-role credentials are still in the environment. They belong to a different AWS account than the host, so EC2 calls made with them cannot see the instance.
aws_assign_instance_profile.pyonly applies the instance account's credentials withos.environ.setdefault, so the ambient keys take precedence.aws_setup.shalready unsets theAWS_*variables before running, butteardown.shdoes not.Changes in this PR
teardown.shunsetsAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYandAWS_SESSION_TOKENbefore sourcing the secrets file, mirroringaws_setup.sh.Test Plan
Evergreen patch running
test-auth-awson the Ubuntu 22.04, Ubuntu 24.04 and both Windows variants, with the EKS subtest skipped as in #920 so that the Linux runs reach teardown. All four pass. With temporary diagnostics around the assign call (not part of this PR), the instance's profile association list was empty before the call and contained the host's profile afterwards on every host, and theInvalidInstanceID.NotFoundtraceback no longer appears.I did not run this against the unfixed script on Linux, so the failure itself was only observed on the Windows variants.
Checklist
Checklist for Author
Checklist for Reviewer