Rewrite aws_auth_login{}
to use all conventional AWS authentication options
#2519
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.
Description
Closes #1808, #1672
Relates to #1086
A re-implementation of AWS authentication with
aws-sdk-go-v2
to perform authentication flow as closely as possible to Terraform AWS Provider.Naturally, this change required me to completely cut out
awsutil
as it introduced its own logic of credential precedence that couldn't be worked around. All functions related to request construction and signing, as well as region resolution were implemented to mimic the original behaviour as closely as possible.Support matrix for different credential sources in the order of precedence:
aws_role_arn
ignoredaws_role_arn
ignoredsource_profile
+role_arn
in config)AWS_ROLE_ARN
+AWS_WEB_IDENTITY_TOKEN_FILE
)aws_role_arn
ignoredaws_role_arn
ignoredIn this implementation,
auth_login_aws {}
supports all these authentication methods and always assumes the role if it's available from one of the sources. It now also supports loading parameters such asaws_role_arn
andregion
from the shared credentials/web identity.For example, role will selected in the order of precedence:
auth_login_aws { aws_role_arn = <role_arn> }
in provider configuration$AWS_PROFILE
aws_role_arn
supplied with shared credentials/web identity token.User-facing changes
aws_profile
with SSO profiles or providedaws_role_arn
with static credentials were not validated, these options were quietly ignored. Now, these combinations will actually have an effect. Ifauth_login_aws.aws_role_arn
or$AWS_ROLE_ARN
are present, the provider will always attempt to assume that role using first available credentials in the order of precedence.Checklist
Output from acceptance testing:
Community Note
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.