Add option to terraform-to-secrets
to search for secrets in remote state resources
#113
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
This PR adds a new
--remote-state
option to theterraform-to-secrets
script. When the option is included, the script will search for secrets in Terraform remote state resources. When the option is excluded, it will only search for secrets in the local state resources. This changes the behavior ofterraform-to-secrets
because it would previously search in the remote state by default.💭 Motivation and context
There are some cases when it may be desirable to search for secrets in remote state resources, but generally, we will only want to search the local state.
This change was prompted by a situation (in cisagov/ansible-role-cdm-nessus-agent#62) where the intended
TEST_ROLE_TO_ASSUME
for theansible-role-cdm-nessus-agent
was being overwritten by an additionalTEST_ROLE_TO_ASSUME
that was included in the remote state foransible-role-cdm-certificates
. Adding this new option will allow us to avoid situations like this in the future.🧪 Testing
I tested these changes by running the script in a repository that had secrets in both the local state and remote state. I confirmed that the changes worked as expected.
✅ Pre-approval checklist
to reflect the changes in this PR.