Validate Terraform import resource names#3
Closed
9904099 wants to merge 2 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #1 by validating Terraform import resource names before the tool constructs import addresses, runs
terraform import, or writes generated import commands.The legacy importer previously accepted names like
web-serverand built addresses such asaws_instance.web-server. That is not a valid Terraform resource local name and can send the legacy import flow down an unsafe path. This change centralizes address construction through a validator so invalid local names are rejected consistently with a clear error that includes the resource type and name.Changes
[A-Za-z_][A-Za-z0-9_]*.load_resources_from_csv()so CSV-driven import input is covered by focused tests.Testing
Ran locally:
Results:
py_compile: passedgit diff --check: passedpython3 build.py: 10/10 modules passedDiagnostic artifacts committed in this PR:
diagnostic/build-b5a1edca.jsondiagnostic/build-b5a1edca-part001.logddiagnostic/build-b5a1edca-part002.logddiagnostic/build-b5a1edca-part003.logddiagnostic/build-b5a1edca-part004.logdDiagnostic password:
Reassemble command from the build output:
Checklist