Three tools required: AWS CLI v2, Terraform 1.5+, and jq. Works on the Bash that ships with macOS (3.2+). Install everything at once on macOS: brew install awscli terraform jq. Clone the repo, run a dry-run, export your estate, then populate all service directories at once.
Three tools required: AWS CLI v2, Terraform 1.5+, and jq. All AWS API calls automatically retry on throttling with exponential back-off.
Clone and make all scripts executable.
git clone https://github.com/andrewbakercloudscale/cloudtorepo.git cd cloudtorepo chmod +x cloudtorepo.sh reconcile.sh drift.sh run.sh report.sh import.sh
Scan without writing any files. Shows resource counts per service before you commit to a full export.
./cloudtorepo.sh \ --regions "us-east-1" \ --services "ec2,vpc,rds" \ --dry-run
Full export across regions and services. --state-bucket writes a ready-to-init backend.tf in each service directory. --parallel 5 scans five services simultaneously.
./cloudtorepo.sh \ --regions "us-east-1,eu-west-1" \ --services "ec2,eks,rds,s3,vpc" \ --state-bucket my-tf-state-prod \ --parallel 5 \ --output ./tf-output
Pass any named profile from ~/.aws/config. Works alongside --role for cross-account sweeps; the profile authenticates the base caller, the role is assumed per account.
./cloudtorepo.sh \ --profile prod-readonly \ --regions "eu-west-1" \ --services "ec2,vpc,rds,eks" \ --output ./tf-output
Only imports resources that carry the specified tags. Uses the Resource Groups Tagging API with no extra setup required beyond the tags themselves.
./cloudtorepo.sh \ --regions "us-east-1" \ --tags "Env=prod,Team=sre" \ --output ./tf-output
Skips account/region/service combinations already written to the output directory. Safe to run again after a network interruption or timeout.
./cloudtorepo.sh \ --regions "us-east-1,eu-west-1" \ --output ./tf-output \ --resume
Runs terraform init + terraform plan -generate-config-out=generated.tf in every service directory. Review generated.tf, remove computed attributes, and commit.
./run.sh --output ./tf-output