behavior of aws_profile
is not in line with standard aws tooling
#1696
Labels
aws_profile
is not in line with standard aws tooling
#1696
The Problem
aws_profile
is that it would use the same credential discovery that the AWS CLI does (or any AWS SDK).aws_profile
is not available (in CI or a production server, for instance), the config file is not decryptable without removing theaws_profile
first.Most of the
aws_profile
related github issues in this repo revolve around expected behavior vs observed behavior - most of which would be solved by following the same behavior that AWS enforces for their own tooling.Proposal
Introduce the correct priority ordering for credential discovery. Instead of forcing the
aws_profile
to be the only method of authentication, we should use the value ofaws_profile
to override theAWS_PROFILE
environment variable. This would allow the normal credential discovery built into the aws sdk to run its proper course.In the case where the
aws_profile
is not available in the Credentials file or Config file, or those files do not exist at all, theaws_profile
should be ignored entirely to allow those files to still be decrypted.I am happy to work on this feature if permitted and needed.
Explanation
AWS Documentation on Credential Discovery
When using the AWS CLI, there is a priority to which credentials are chosen (I've listed them all here with the relevant ones retaining their descriptions):
From the AWS Documentation on CLI Credential configuration using environment variables:
Stated extremely clearly on this documentation page:
Sops
aws_profile
FunctionalityWhen a file is encrypted with
sops
, you have the option to specify--aws-profile
, and that profile is written into the config file as a sort of default profile when decrypting. The most obvious use case of the embeddedaws_profile
appears to be that it allows the use of multiple AWS accounts in a repo without requiring changing environment variables just to edit encrypted files that are encrypted with keys from different accounts. This is a very nice boon for setups where, for instance, non-prod and prod are in separate accounts. Very convenient!In
sops
, when theaws_profile
field is set up originally, it is used as a command line argument through--aws-profile
. Command line arguments are priority 1, so it should override all other settings. This is done correctly by the AWS docs.When decrypting, it is not a command line argument anymore. It's an implicit override for the
AWS_PROFILE
environment variable. Therefore, ifAWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environment variables happen to be available, they should take precedence over it. This can (and has been) observed to not be the case, assops
forces theaws_profile
to be used regardless of any other available credentials - even if the profile is not found at all and there are other valid credentials available.See also
This extremely similar issue in the
serverless
repo, illustrating this issue of parity with the AWS tooling: serverless/serverless#9290The text was updated successfully, but these errors were encountered: