Added a new "Terraform Imports" tab that generates Terraform 1.5+ import blocks for AWS resources#397
Open
anup2230 wants to merge 1 commit intoiann0036:masterfrom
Conversation
Owner
|
Appreicate the effort. I don't think the strategy of attempting to map to CFN types is a good idea. We deliberately split TF types out as there are both TF-only and CFN-only types around. Instead of having a mapping in one file, I'd add a |
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.
Initial Code and Testing complete. Verified import block work for at least VPC, EC2, RDS, S3, Cloudfront, etc.. There might be some specific resources that need updates to the resource mapping.
Overview
Added a new "Terraform Imports" tab that generates Terraform 1.5+ import blocks for AWS resources selected in Former2, enabling batch imports without CLI commands.
Data Flow:
Purpose: Maps CloudFormation resource types → Terraform types + identifier property names
Why:
`function getTerraformImportIdentifier(cfnType, resourceData, trackedResource) {
const mapping = TERRAFORM_IMPORT_MAPPINGS[cfnType] || TERRAFORM_IMPORT_MAPPINGS['default'];
}`
Purpose: Property lookup that finds the resource identifier from various data sources
Strategy (6-level fallback cascade):
a. Exact match in resourceData - Direct property lookup (e.g., resourceData['InstanceId'])
b. Case-insensitive match in resourceData - Handles PascalCase vs camelCase variants
c. Exact match in trackedResource.options.cfn - CloudFormation mapped properties
d .Case-insensitive match in options.cfn
e. Exact match in trackedResource.obj.data - Raw AWS SDK data
f. Case-insensitive match in obj.data
g. Final fallback - Search for any property named 'id' or 'Id'
Purpose: Generates HCL import blocks for all tracked resources
Output Format (Terraform 1.5+ syntax):
Error Handling (Lines 540-567):
Change 1: Navigation Tab (Line 238)
Why: Adds the tab button to switch to Terraform Imports view
Change 2: Copy Button (Line 661)
Why:
Change 3: Terraform Imports Section (Lines 1551-1556)
Why:
Change 4: Script Include (Line 1637)
<script src="js/terraformImportMappings.js"></script>Change 1: Hide Copy Button Initially (Line 707)
Why: All output copy buttons are hidden by default, shown only when their tab is active
Change 2: Tab Navigation Event Handler (Lines 828-834)
Why:
Change 3: Set Editor Value (Line 917)
Why:
Change 4: CodeMirror Editor Initialization (Line 1170)
Why Each Setting:
Change 5: Copy Button Event Handler (Line 1181)
Why:
Change: Add Terraform Imports to Output (Line 4427)
Why: