Ansible Playbook to Terraform Converter - Convert Playbooks to HCL Online
Free online Ansible to Terraform converter tool to transform Ansible playbooks to Terraform HCL with support for AWS, Azure, and GCP resources.
Loading converter...
How to Convert Ansible Playbook to Terraform - Step by Step Guide
Prepare Your Ansible Playbook
Open your Ansible playbook file (typically with .yml or .yaml extension). The converter focuses on infrastructure provisioning tasks using cloud provider modules like amazon.aws.ec2, azure.azcollection.azure_rm_virtualmachine, or google.cloud.gcp_compute_instance. Copy the contents of your playbook.
Paste and Convert
Paste your Ansible playbook YAML into the left editor panel. The converter parses Ansible tasks and maps cloud provider modules to equivalent Terraform resources. Click "Convert to Terraform" to generate HCL code. Ansible variables are converted to Terraform variables, and task parameters become resource arguments.
amazon.aws.ec2 are converted to aws_instance resourcesReview and Refine
Examine the generated Terraform HCL code in the right panel. The conversion is a starting point—you'll need to review and adjust for your specific use case. Ansible's imperative style and Terraform's declarative style differ significantly, so manual refinement is typically needed.
when conditions may need manual conversion to Terraform's count or dynamic blocksdepends_onDownload and Initialize
Download the converted Terraform configuration and save it as main.tf. Run terraform init to initialize the working directory and download required providers. Use terraform plan to preview changes before applying.
terraform validate to check for syntax errorsRelated Tools
CloudFormation to Terraform
Convert AWS CloudFormation templates to Terraform HCL configuration
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
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