Fix for local-exec failure when updating trust policies. #237
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.
https://dsdmoj.atlassian.net/browse/ANPL-1449
There were a few issues with the
local-exec
resource that is used to update trust policies of app roles:sts assume role
was being passed as a parameter wasn't a role arn but the arn of the session (ie: hadassumed-role
in the arn)aws-vault
to run locally, reporting aninvalid session token
error. This PR resolves both issues.Changes in the PR
aws_caller_identity
terraform datasource to get the caller arn, this usesaws_session_context
which converts the session arn to the role arn used to the session. Passing this into thests assume role
command resolves theAccess Denied
andcan't assume role
errors.AWS_SECURITY_TOKEN
envvar if the caller identity is an SSO role (meaning the code is being run locally.) AWS cli appears to treat this envvar as higher priority thanAWS_SESSION_TOKEN
which causedSession token invalid
errors. (ref: Pass credentials to local-exec OR extract credentials via properties hashicorp/terraform-provider-aws#8242 (comment))Assuming no further errors, this PR has been tested to successfully amend trust policies of existing app roles to add the clause allowing assumption by CP service accounts.