Repository navigation
Run a command against a different permission set - #2
Merged
Merged
Conversation
A profile in ~/.aws/config pins exactly one sso_role_name, so reaching a
second permission set in the same account has meant editing that file and
remembering to put it back. The edit is global and outlives the command it
was made for.
sr leaves the file alone. The profile still supplies the account, the start
URL and the region; only the permission set is substituted, and only for the
one child process the credentials are handed to.
sr -p example -r ReadOnlyAccess terraform plan
The substitution is config.WithSSOProviderOptions, which is applied after
ssocreds.New has taken sso_role_name from the profile. That leaves the token
cache, and the refresh an [sso-session] profile is capable of, to the SDK.
GetRoleCredentials is the only call made: what the account has is never
listed, and there is no attempt to sign anyone in.
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.
A profile in
~/.aws/configpins exactly onesso_role_name, so reaching a second permission set in the same account has meant editing that file and remembering to put it back. The edit is global and outlives the command it was made for.srleaves the file alone. The profile still supplies the account, the start URL and the region; only the permission set is substituted, and only for the one child process the credentials are handed to.How
The substitution is
config.WithSSOProviderOptions, applied afterssocreds.Newhas takensso_role_namefrom the profile, so it wins. That leaves the profile resolution, the token cache and the refresh an[sso-session]profile is capable of to the SDK.GetRoleCredentialsis the only call made. What the account has is never listed — that would cost a call in front of the one that matters and would only move the same failure earlier — and there is no attempt to sign anyone in: a missing or expired token is reported with theaws sso loginthat fixes it.A profile that gets its credentials some other way is refused rather than run, since the override would have been quietly ignored and the command would have used whatever that profile does use.
SR_ALIASgives short names for permission sets. The expansion is local, so there is no lookup to wait for and no partial matching to be surprised by.Notes
srrather than being spawned by it, so the terminal, the signals and the exit status all belong to it, and no parent is left holding the credentials. That makessrUnix-only, and the release builds are limited to darwin and linux.AWS_PROFILEis removed from the child's environment: left in place it would point back at the permission set being replaced.package sr_test) and driveCmd.Runagainst a stub Identity Center. Every function exceptExecProcess, which does not return, is fully covered.