Loading converter...

How to Convert Terraform to CloudFormation - Step by Step Guide

Step 1

Prepare Your Terraform Configuration

Locate your Terraform configuration files (typically main.tf, variables.tf, or resources.tf). Terraform uses HashiCorp Configuration Language (HCL) to define infrastructure. Copy the contents of your Terraform files.

Validate first: Run terraform validate to ensure your configuration is syntactically correct
AWS resources only: This converter focuses on AWS resources—non-AWS provider resources will be skipped with warnings
Multiple files: You can merge multiple .tf files or convert them separately and combine the results
Step 2

Paste and Convert

Paste your Terraform HCL code into the left editor panel. The converter parses your Terraform resource blocks, variables, and outputs, then maps them to equivalent CloudFormation syntax. Terraform references like aws_vpc.main.id are automatically converted to CloudFormation intrinsic functions.

Resource mapping: AWS resources like aws_instance are converted to AWS::EC2::Instance
Variables: Terraform variables are converted to CloudFormation Parameters with appropriate types
Choose format: Select YAML or JSON output format using the dropdown in the output panel
Step 3

Review and Customize Output

Examine the generated CloudFormation template in the right panel. While the converter handles common AWS resources and patterns, some Terraform-specific features don't have direct CloudFormation equivalents. Review property mappings and ensure all required CloudFormation properties are present.

Dynamic blocks: Terraform's dynamic blocks need manual conversion
Modules: Terraform modules should be flattened or converted separately as nested CloudFormation stacks
Functions: Terraform functions need manual mapping to CloudFormation intrinsic functions
Step 4

Download and Deploy to AWS

Download the converted CloudFormation template in your preferred format. Save it as template.yaml or stack.json. Deploy using the AWS CloudFormation console, AWS CLI, or AWS CDK. Always test in a dev/staging environment first.

Validate template: Use aws cloudformation validate-template before deploying
Review parameters: Check all parameter default values and adjust for your environment
IAM permissions: Ensure CloudFormation has proper permissions to create your resources