Skip to content
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

Resolves #2171: Honor 'use_aws_shared_config_files' for process… #2172

Merged
merged 9 commits into from
Dec 17, 2020
Merged

Resolves #2171: Honor 'use_aws_shared_config_files' for process… #2172

merged 9 commits into from
Dec 17, 2020

Conversation

cuppett
Copy link
Contributor

@cuppett cuppett commented Dec 14, 2020

…-based CredentialProvider

Issue #, if available:

Resolves #2171

For the credential resolver whereby the default ~/.aws/config and ~/.aws/credentials are evaluated for access credentials, the config variable 'use_aws_shared_config_files' is considered. However, for the process-based credential resolver, checking the same $HOME directory shared config files, it is not. This adds the same conditional check to ensure those files are not considered for either method where configuration is explicitly supplied indicating they should not be.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…ased CredentialProvider

For the credential resolver whereby the default ~/.aws/config and ~/.aws/credentials are evaluated for access credentials, the config variable 'use_aws_shared_config_files' is considered. However, for the process-based credential resolver, checking the same $HOME directory shared config files, it is not. This adds the same conditional check to ensure those files are not considered for either method where configuration is explicitly supplied indicating they should not be.
@codecov-io
Copy link

codecov-io commented Dec 15, 2020

Codecov Report

Merging #2172 (0374cb8) into master (d15a231) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2172      +/-   ##
============================================
- Coverage     93.00%   92.99%   -0.01%     
- Complexity     4021     4023       +2     
============================================
  Files           222      222              
  Lines         10848    10850       +2     
============================================
+ Hits          10089    10090       +1     
- Misses          759      760       +1     
Impacted Files Coverage Δ Complexity Δ
src/Credentials/CredentialProvider.php 94.20% <100.00%> (-0.23%) 183.00 <0.00> (+2.00) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d15a231...5699a89. Read the comment docs.

The default ordering is supposed to be:
1) env
2) web identity
3) profile config
4) Container/Instance

The process type is a relative new add. However, it was put below ECS. In the Java SDK, all profile processing (and case logic) is together in the search order. This makes that match.

See Also: https://github.com/aws/aws-sdk-java/blob/1.11.918/aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/ProfilesConfigFile.java#L207-L216
The default ordering is supposed to be:
1) env
2) web identity
3) profile config
4) Container/Instance

ECS deployments and instance profiles are easily detectable via an environment variable. If the environment variable is present, add the ECS provider to the chain; otherwise, add the instance profile provider.

See Also: https://github.com/aws/aws-sdk-java/blob/1.11.918/aws-java-sdk-core/src/main/java/com/amazonaws/auth/EC2ContainerCredentialsProviderWrapper.java#L58-L64
@cuppett
Copy link
Contributor Author

cuppett commented Dec 15, 2020

I've pushed a couple more commits to order this according to the documentation:

defaultProvider provider

  1. environment variables
    a) Original environment variables
    b) Web Identity environment variables
  2. AWS config/credentials files
    a) SSO/role based
    b) process based
    c) static credentials
  1. ECS/EC2 roles
    a) ECS if environment variable present
    b) instance role

The ordering in the existing file is blended a bit. I've made the comment block and the code match the documentation. In addition, this ordering now matches the Java SDK for comparison

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.java#L46-L52

The profile types are all lumped together:

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/ProfilesConfigFile.java#L207-L216

And then, there's a toggle between ECS and instance profile "either/or" versus "both":

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/EC2ContainerCredentialsProviderWrapper.java#L58-L64

@SamRemis
Copy link
Member

@cuppett Thanks for your PR, I agree this is a better order than we had before- could you create a changelog file? I also will close/re-open this to retrigger the github actions since this was pushed while we were in the process of migrating from Travis.

@SamRemis SamRemis closed this Dec 16, 2020
@SamRemis SamRemis reopened this Dec 16, 2020
@cuppett
Copy link
Contributor Author

cuppett commented Dec 16, 2020

@cuppett Thanks for your PR, I agree this is a better order than we had before- could you create a changelog file? I also will close/re-open this to retrigger the github actions since this was pushed while we were in the process of migrating from Travis.

Done. Thanks!

Copy link
Member

@SamRemis SamRemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one of the docs is out of order if I'm reading it correctly. Please let me know if I misunderstood

@cuppett
Copy link
Contributor Author

cuppett commented Dec 16, 2020

Looks good, just one of the docs is out of order if I'm reading it correctly. Please let me know if I misunderstood

Double checked and raw file shows them all in good order. The markup view with line breaks a little confusing how it interrupts some of the sentences.

I've got each then, then, then on separate lines to let future adds and changes be easier to see and review; hope that helps!

@SamRemis
Copy link
Member

@cuppett I apologize for my confusion- I think I misread and the documentation is missing one step: the SSO provider. I saw the note about the CLI's default profile and my mind jumped to SSO.

@cuppett
Copy link
Contributor Author

cuppett commented Dec 17, 2020

@cuppett I apologize for my confusion- I think I misread and the documentation is missing one step: the SSO provider. I saw the note about the CLI's default profile and my mind jumped to SSO.

No worries, getting these right super important.

@cuppett
Copy link
Contributor Author

cuppett commented Dec 17, 2020

Does this PR need flipped back to approved?

@cuppett cuppett requested a review from SamRemis December 17, 2020 11:43
Copy link
Member

@SamRemis SamRemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the a line about the SSO- for example, add before line 60

src/Credentials/CredentialProvider.php Show resolved Hide resolved
@cuppett cuppett requested a review from SamRemis December 17, 2020 16:32
@SamRemis
Copy link
Member

Looks good! Going to wait for all the github actions to pass and will merge ASAP. Thank you for your contribution

@SamRemis SamRemis merged commit 8491d11 into aws:master Dec 17, 2020
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.

Process Provider does not honor 'use_aws_shared_config_files' boolean similar to ini provider
3 participants