How to Convert CloudFormation to Terraform
Input Your CloudFormation Template
Start by providing your AWS CloudFormation template. Whether you're migrating from CloudFormation to Terraform or modernizing your Infrastructure as Code, you have multiple options:
.template, .json, or .yaml files!Ref, !Sub and !GetAttAutomatic Conversion Process
The converter reads the template and writes a first draft in Terraform HCL:
Ref, !GetAtt, !Sub, !Join, !Select and !FindInMap to Terraform expressions; anything else is written as null and listed in a noteReview Generated Terraform Code
Review the generated main.tf configuration in the output panel. Treat it as a draft; the comment lines at the top tell you what was skipped:
Download and Deploy with Terraform
Once the draft looks right, download it and let Terraform check it before anything is created:
main.tf to your Terraform project directoryterraform init to download the AWS providerterraform validate to catch argument names that need fixing, then terraform plan to see what would be createdterraform apply to provision your AWS infrastructureterraform import to manage resources that already exist in your AWS accountQuick Start Commands
Essential Terraform CLI commands:
# Initialize Terraformterraform init# Preview changesterraform plan# Apply infrastructureterraform applyFrequently Asked Questions
How does the CloudFormation to Terraform conversion work?
The template is read as JSON or YAML, including the short YAML tags such as !Ref, !Sub and !GetAtt. Parameters become variable blocks, Mappings become a locals block, every resource with a known type becomes a resource block for the hashicorp/aws provider, and Outputs become output blocks. A comment at the top of the result lists anything that was skipped or could not be translated.
Which AWS resource types are converted?
A fixed list of 36 common types: EC2 instances, security groups, VPCs, subnets, internet gateways, route tables, routes, Elastic IPs and EBS volumes; Lambda functions and permissions; S3 buckets and bucket policies; RDS instances and subnet groups; DynamoDB tables; IAM roles, policies, users, groups and instance profiles; ALB/NLB load balancers, target groups and listeners; Auto Scaling groups and launch configurations; CloudWatch alarms and log groups; SNS topics; SQS queues; API Gateway REST APIs, resources and methods; and ECS clusters, services and task definitions. Any other type, including custom resources and nested stacks, is skipped and named in the notes.
Are the properties matched to the Terraform aws provider arguments?
Not one by one. Each property is copied with its name in snake_case, so BucketName becomes bucket_name and SecurityGroupIngress becomes security_group_ingress. Tags lists are turned into the tags map Terraform expects and IAM policy documents are wrapped in jsonencode(), but many aws provider arguments have different names or shapes (an S3 bucket's name is bucket, for example). Run terraform validate and fix what it reports.
Which intrinsic functions and pseudo parameters are translated?
Ref becomes var.name for a parameter or type.name.id for a resource, Fn::GetAtt becomes an attribute reference, Fn::Sub becomes string interpolation (including the form with a variable map), and Fn::Join, Fn::Select, Fn::Split, Fn::Base64 and Fn::FindInMap become join(), element(), split(), base64encode() and a lookup in local.mappings. AWS::Region becomes var.aws_region, AWS::AccountId and AWS::Partition read from data sources, and AWS::StackName becomes a variable you set. Fn::If, Fn::ImportValue, Conditions and the other functions are written as null and listed in the notes so you can replace them by hand.
Will long IDs, prices or text with quotes change?
No. Numbers keep the digits you typed, so 8901240544102066246 and 14.50 come out exactly as written, and 00501 stays the text 00501 whether it was quoted or not. Tag values are always written as text. Quotes, backslashes and line breaks are escaped, and a literal ${ or %{ is written as $${ or %%{ so Terraform does not treat it as interpolation.
What happens to DependsOn, Conditions and DeletionPolicy?
DependsOn entries that point at a converted resource become depends_on. A resource Condition, DeletionPolicy, UpdatePolicy and similar settings are kept as comments inside the resource block; in Terraform you would usually express them with count and a lifecycle block.
Is my CloudFormation template uploaded anywhere?
No. The conversion runs in your browser, nothing is sent to a server and nothing is kept, so a reload starts with an empty editor.
Related Tools
Terraform to CloudFormation
Convert Terraform HCL configurations to AWS CloudFormation templates in YAML or JSON
Azure ARM to Terraform
Convert Azure Resource Manager templates to Terraform HCL with azurerm provider
Ansible to Terraform
Convert Ansible playbooks to Terraform HCL for AWS, Azure, and GCP resources
ARM to Bicep
Convert Azure Resource Manager (ARM) templates to Bicep with modern syntax and improved readability
Bicep to ARM
Convert Bicep files to Azure Resource Manager (ARM) JSON templates for deployment and tooling compatibility
CloudFormation to Pulumi
Convert AWS CloudFormation templates to Pulumi TypeScript for modern infrastructure as code