-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update credential precedence to match AWS CLI #621
Conversation
src/AWSCredentials.jl
Outdated
elseif !isnothing(sso_start_url) | ||
access_key, secret_key, token, expiry = _aws_get_sso_credential_details(p, ini) | ||
return AWSCredentials(access_key, secret_key, token; expiry=expiry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential breakage if someone was using dot_aws_config
directly to get credentials for SSO support. If this is a concern I can leave this logic in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably safe to remove, but I feel like we should keep it in place. Having the rug pulled under you would be quite annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably safe to remove, but I feel like we should keep it in place. Having the rug pulled under you would be quite annoying.
– #621 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this back in with either a deprecation or just a comment
if isfile(config_file) | ||
ini = read(Inifile(), config_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to refactor this credential code in the future to avoid reloading the config_file
on each call. As this function and others are called in _aws_get_role
we could see some improved performance with this change.
# The AWS CLI uses the config file `credential_process` setting over | ||
# specifying the config file `aws_access_key_id`/`aws_secret_access_key`. | ||
@testset "precedence" begin | ||
open(config_file, "w") do io | ||
write( | ||
io, | ||
""" | ||
[profile $(test_values["Test-Config-Profile"])] | ||
aws_access_key_id = invalid | ||
aws_secret_access_key = invalid | ||
credential_process = $(abspath(credential_process_file)) | ||
""", | ||
) | ||
end | ||
|
||
result = dot_aws_config(test_values["Test-Config-Profile"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff is pretty messy but this was refactored and moved into the "Credential Precedence" testset
bors try |
tryBuild failed: |
bors try |
tryBuild failed: |
bors try |
tryBuild succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
src/AWSCredentials.jl
Outdated
elseif !isnothing(sso_start_url) | ||
access_key, secret_key, token, expiry = _aws_get_sso_credential_details(p, ini) | ||
return AWSCredentials(access_key, secret_key, token; expiry=expiry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably safe to remove, but I feel like we should keep it in place. Having the rug pulled under you would be quite annoying.
bors try |
tryBuild failed: |
bors try |
tryBuild failed: |
bcb9319
to
380f7ba
Compare
bors try |
tryBuild succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
bors try |
Alright, should be done with making any more changes to this PR. Summary of changes since the last review:
|
tryBuild succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
I noticed there were some credential precedence ordering differences between AWS.jl and AWS CLI. I ended up doing some experimentation with pairing different AWS CLI settings to determine the precedence ordering used by AWS CLI. Here are the results of those tests:
--profile
used over envAWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
--profile
used over envAWS_PROFILE
AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
used over envAWS_PROFILE
AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
used over config filesso_*
sso_*
used over~/.aws/credentials
(if exists)~/.aws/credentials
(if exists) used over config filecredential_process
credential_process
used over config fileaws_access_key_id
/aws_secret_access_key
aws_access_key_id
/aws_secret_access_key
used over EC2 instance metadataaws_access_key_id
/aws_secret_access_key
used overAWS_CONTAINER_CREDENTIALS_FULL_URI
Using
aws-cli/2.11.13 Python/3.11.3 Darwin/22.4.0 source/arm64 prompt/off
Notes:
sso_account_id
orsso_role_name
in a profile without othersso_*
keys results in an error about missing required configuration. Definingsso_start_url
andsso_region
by themselves doesn't produce this error.AWS_SHARED_CREDENTIALS_FILE
just replaces~/.aws/credentials