I wrote these scripts to help faciliate batch import of our CloudFormation templates into Terraform Configuration.
This script is a light wrapper around batch.sh. It simply iterates over the list of regions provided, exports expected variables, creates required directories, and calls batch.sh.
BASE_DIR=/path/to/dir EXCLUDE_REGEX="(some-stack-production|some-stack-staging)" ./region-batch.sh us-east-1 us-west-1
Retrieves all CloudFormation stacks for a REGION and processing any whose names don't match the provided EXCLUDE_REGEX. Will create the WORKING_DIR if it doesn't exist. Uses cf-to-tf to generate terraform config files and state. Also downloads the CloudFormation Stack template from AWS and uses that as the template_body. Runs terraform init in each directory so it's ready to rock 🤘.
REGION=eu-central-1 WORKING_DIR=/path/to/dir/${REGION} EXCLUDE_REGEX="(some-stack-production|some-stack-staging)" ./batch.sh
REGION=ap-southeast-1 STACK_NAME=some-stack-production STACK_DIR=/path/to/dir/${REGION}/${STACK_NAME} ./import-stack.sh
Iterates over terraform projects in BASE_DIR and runs terraform plan in each directory. If the output doesn't contain No changes., then there's something wrong with the project and requires attention.
BASE_DIR=/path/to/dir ./find-misconfigured.sh
Scans BASE_DIR for files/stack.json and compares them to any files in TEMPLATES_DIR, echoing out matching files.
BASE_DIR=/path/to/dir TEMPLATES_DIR=/path/to/dir-with-cloudformation-templates ./stack-compare.sh