Loading converter...
How to Convert Terraform to CloudFormation
Collect your Terraform configuration
Open the files that make up the stack, usually main.tf, variables.tf and outputs.tf, and paste them into the left editor one after another. Terraform reads all the files in a folder as one configuration, and so does this page when they sit in the same editor.
terraform validate catches typos before you convert. If the HCL itself is broken, the page shows the line and column it stopped at.Look at what came out
The template shows up on the right shortly after you stop typing. A reference such as aws_vpc.main.id becomes Ref: Main, aws_iam_role.app.arn becomes Fn::GetAtt: [App, Arn], and a string like "$${var.env}-logs" becomes Fn::Sub.
web_server becomes WebServer). When two resources share a name, the type is added, so aws_vpc.main and aws_subnet.main become MainVpc and MainSubnet.Finish what the notes point out
The blue notes name every resource, argument and expression that couldn't be carried over. The usual ones:
a ? b : c needs a Condition and Fn::If, so it is copied as text for you to replace.Validate before you deploy
Download the template as cloudformation-template.yaml or .json and run cfn-lint or aws cloudformation validate-template on it. Create the stack in a test account first, and keep the Terraform state of the old resources in mind: CloudFormation creates new ones, it doesn't take over the existing ones unless you import them.
Frequently Asked Questions
What does the converter do with my Terraform files?
It reads the HCL with the same parser Terraform is built on, then writes a CloudFormation template. Variables become Parameters, each resource of a supported aws_ type becomes a resource with CloudFormation property names (cidr_block becomes CidrBlock, a security group ingress block becomes SecurityGroupIngress rules, tags become a Key/Value list), locals are filled in where they are used, and outputs become Outputs. Anything it can't translate is listed in the notes above the result, and in YAML also as comments at the top of the template.
Which resource types are supported?
About forty common ones: VPCs, subnets, internet gateways (with their VPC attachment), NAT gateways, Elastic IPs, route tables, routes and route table associations; security groups and their rules; EC2 instances; S3 buckets and bucket policies; IAM roles, managed policies, role policies and instance profiles; Lambda functions and permissions; DynamoDB tables; SQS queues; SNS topics and subscriptions; KMS keys and aliases; CloudWatch log groups and metric alarms; ECR repositories; ECS clusters; Route 53 zones and records; load balancers, target groups and listeners; and RDS instances, clusters and subnet groups. aws_s3_bucket_versioning, aws_s3_bucket_public_access_block and aws_iam_role_policy_attachment are folded into the bucket or role they point at. Other types, and anything from a non-AWS provider, are skipped and named in the notes.
How are references and interpolation translated?
var.name becomes a Ref to the parameter. A resource's id becomes a Ref, and other attributes such as arn or dns_name become Fn::GetAtt with the CloudFormation attribute name. A string like "${var.env}-logs" becomes Fn::Sub, and jsonencode(), join(), split(), element(), format() and base64encode() become their CloudFormation counterparts. data.aws_region, data.aws_caller_identity and data.aws_partition become the AWS:: pseudo parameters, and an aws_iam_policy_document data source is written out as the policy itself. Conditionals, for expressions, count.index, modules and most other functions have no plain CloudFormation form; they are copied as text and flagged so you can replace them.
What about count, for_each, modules and providers?
A plain CloudFormation template has no loops, so a resource with count or for_each is written once and the notes tell you to repeat it. Module blocks are not followed; convert each module's .tf files on their own (nested stacks are the CloudFormation counterpart). Provider and terraform blocks are left out because a stack is created in the account and region you deploy it to. lifecycle { prevent_destroy = true } becomes DeletionPolicy: Retain, and skip_final_snapshot on a database becomes DeletionPolicy Delete or Snapshot.
Will long numbers, prices or codes like 00501 change?
No. A parameter default of 8901240544102066246 is written with every digit, 14.50 keeps its trailing zero, and the quoted text "00501" stays text. Tag values and Lambda environment variables are always strings in CloudFormation, so numbers there are written as quoted text with the same digits.
Can I deploy the result straight away?
Treat it as a first draft. Read the notes, fill in anything that was copied as text, and check the template with cfn-lint or aws cloudformation validate-template before creating a stack. A few things always need a hand: a Lambda function built from a local zip needs its code in S3, and parameters without a default need values when you deploy.
Is my Terraform code 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.
Going the other way? CloudFormation to Terraform turns a template into HCL, and the HCL validator checks your .tf syntax first.
Related Tools
CloudFormation to Terraform
Convert AWS CloudFormation templates to Terraform HCL configuration
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