Prompt

How do I migrate from CloudFormation to Terraform without breaking deployments?

Technology / Cloud Infrastructure1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

Migrating from CloudFormation to Terraform without breaking deployments is mostly about adopting existing resources safely, avoiding resource replacement, and changing one layer at a time.

Recommended approach

1) Inventory everything first

Make a full list of:

  • CloudFormation stacks
  • Resources in each stack
  • Resource dependencies
  • Outputs, parameters, mappings, conditions
  • Manual changes made outside CloudFormation

You want to know which resources are:

  • safe to recreate
  • must be preserved
  • shared across stacks/accounts
  • stateful, like RDS, EFS, S3 buckets, DynamoDB tables

2) Recreate the CloudFormation model in Terraform

Before touching prod, translate the stack into Terraform:

  • VPC, subnets, route tables
  • IAM roles/policies
  • Security groups
  • Load balancers
  • ECS/EKS/EC2 resources
  • DNS, certificates, alarms, etc.

Be careful with:

  • implicit dependencies in CloudFormation
  • default values that differ between tools
  • naming differences
  • resource ordering

3) Import existing resources into Terraform state

Do not create new resources if the old ones already exist.

Use:

  • terraform import for each resource
  • or newer Terraform import blocks if available in your workflow

This lets Terraform manage existing infrastructure instead of replacing it.

Important:

  • Import the exact real-world resource IDs
  • Verify Terraform config matches current settings before applying
  • If config differs, Terraform may try to change resources on the first plan

4) Keep CloudFormation and Terraform from fighting

During migration, do one of these:

Option A: Terraform takes over resource ownership

  • Import resources into Terraform
  • Stop CloudFormation from managing those resources
  • Remove or disable the CloudFormation stack only after Terraform is fully aligned

Option B: Migrate stack pieces gradually

  • Move low-risk resources first
  • Keep critical stateful resources in CloudFormation until last
  • Split stacks so boundaries are clear

Avoid having both tools manage the same resource.


5) Use a “no-op” plan as your safety check

Before applying Terraform:

  • Run terraform plan
  • Expect zero changes if you’re just adopting resources
  • If changes appear, investigate before proceeding

Common causes of unwanted diffs:

  • tags
  • default security group rules
  • ordering differences in lists
  • computed attributes
  • naming/formatting differences
  • IAM policy JSON normalization

6) Handle stateful resources very carefully

For resources that store data, avoid replacement unless you have a migration strategy:

  • RDS / Aurora
  • EBS volumes
  • EFS
  • S3 buckets
  • DynamoDB tables
  • ElastiCache clusters
  • OpenSearch domains

Check whether Terraform wants to recreate them because of:

  • immutable fields
  • naming changes
  • unsupported CloudFormation settings
  • provider differences

If needed, use:

  • lifecycle { prevent_destroy = true }
  • ignore_changes for safe drift you don’t want Terraform to manage immediately

7) Migrate outputs and dependencies

CloudFormation stack outputs often feed other stacks/apps. In Terraform:

  • replace stack outputs with Terraform outputs
  • update consumers to read from Terraform outputs, remote state, SSM, or parameter store
  • make sure CI/CD pipelines use the new source of truth

8) Move deployment pipelines last

Don’t switch your app deployment process too early.

A safe sequence is:

  1. Terraform manages infrastructure
  2. Verify infrastructure is stable
  3. Update deployment pipeline to use Terraform outputs
  4. Decommission CloudFormation stack

9) Decommission CloudFormation only after validation

Once Terraform is authoritative:

  • confirm resources are healthy
  • confirm plans are stable
  • confirm app deploys succeed
  • confirm monitoring/alerts are intact

Then:

  • remove CloudFormation stack resources carefully
  • ensure deletion policy / retention is set for stateful resources if needed
  • clean up leftover artifacts manually if necessary

Best practices to avoid outages

  • Migrate in small batches
  • Start with non-production first
  • Freeze unrelated infrastructure changes during migration
  • Use feature flags or blue/green deployments for app changes
  • Keep backups for stateful systems
  • Document every import and ownership change
  • Review Terraform plans in CI before applying

Common mistakes to avoid

  • Creating Terraform resources before importing existing ones
  • Deleting the CloudFormation stack too early
  • Letting both systems manage the same resource
  • Ignoring drift between actual infrastructure and config
  • Migrating stateful resources without backup/rollback plans
  • Not updating downstream references to stack outputs

A practical migration sequence

A safe sequence usually looks like this:

  1. Pick one stack or environment
  2. Freeze changes
  3. Translate CFN to Terraform
  4. Import existing resources
  5. Run terraform plan until it’s clean
  6. Apply only if necessary
  7. Update dependent pipelines/services
  8. Validate in production-like environment
  9. Remove CloudFormation ownership
  10. Repeat for the next stack

Rule of thumb

If you want the shortest safe answer:

Build Terraform to match the existing CloudFormation-managed infrastructure exactly, import the resources into Terraform state, verify a no-op plan, then gradually remove CloudFormation ownership only after confirming deployments still work.

If you want, I can also give you:

  • a step-by-step migration checklist
  • an example import workflow
  • or a CloudFormation-to-Terraform mapping strategy for a specific AWS stack.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.