Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request #91

Open
jdonalson opened this issue Nov 15, 2024 · 4 comments
Open

Feature Request #91

jdonalson opened this issue Nov 15, 2024 · 4 comments

Comments

@jdonalson
Copy link

Currently I have scripts that will append all the .tf files into a single tf file, is this something we can flag? - so they aren't separated at the end... just an idea

@awsandy
Copy link
Contributor

awsandy commented Nov 15, 2024

ok - will look at that as an option

@jdonalson
Copy link
Author

#!/bin/bash

Create output file

output_file="combined.tf"

Clear output file if it exists

"$output_file"

Add header comment

echo "# Combined Terraform configuration from import folder" > "$output_file"
echo "# Generated on $(date)" >> "$output_file"
echo "" >> "$output_file"

Combine all .tf files

for file in *.tf; do
if [ -f "$file" ]; then
echo "# Source: $file" >> "$output_file"
cat "$file" >> "$output_file"
echo "" >> "$output_file"
fi
done

echo "Combined all .tf files into $output_file"

#!/bin/bash

Temporary file for processing

tmp_file="combined.tmp"

Fix empty excludes lists and remove conflicting name_prefix

sed -e 's/excludes = []/excludes = ["none"]/'
-e '/name_prefix/d'
combined.tf > "$tmp_file"

mv "$tmp_file" combined.tf

echo "Fixed Terraform configuration issues" here are my scripts to bring 1300 imported resources to valid state…

@awsandy
Copy link
Contributor

awsandy commented Nov 15, 2024

which resources have excludes=[] ? (i can code that out for you)

and which resources are giving you name_prefix errors ?

@awsandy
Copy link
Contributor

awsandy commented Nov 15, 2024

committed changes so there is now a "-s" (singlefile) flag
aws2tf.py -t vpc -s

you only get main.tf - not all the individual files

(They are still tucked away in the imported directory - so merging will still work)

./aws2tf.py -t efs -m -s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants