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. Collection names are matched by their last part, so amazon.aws.ec2_instance and ec2_instance both work. Copy the contents of your playbook.
Paste and Convert
Paste your Ansible playbook YAML into the left editor panel. The HCL shows up on the right a moment after you stop typing; there is no button to press. Ansible variables become Terraform variables, and the common arguments of each recognised module become resource arguments.
amazon.aws.ec2_instance are converted to aws_instance resources{{ region }} are kept as quoted text, and loops are not translated, so swap them for var.region, count or for_each yourselfReview 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 errorsFrequently Asked Questions
Which Ansible modules does it turn into Terraform resources?
A short, fixed list of cloud modules: ec2 and ec2_instance (aws_instance), ec2_security_group and ec2_group, ec2_vpc_net, ec2_vpc_subnet, s3_bucket and aws_s3, iam_role, iam_policy, iam_user, rds and rds_instance, lambda, the azure_rm virtual machine, resource group, storage account and virtual network modules, and gcp_compute_instance, gcp_compute_network and gcp_storage_bucket. Collection names such as amazon.aws.ec2_instance are matched by their last part. Only the common arguments are carried over, so expect to fill in the rest.
What happens to tasks like apt, copy, template or shell?
They are skipped. Those tasks configure a server rather than create infrastructure, and Terraform has no direct equivalent for them. If nothing in the playbook matches the list above, the output says that no convertible resources were found and only the variables are written.
Are Jinja expressions like {{ region }} turned into Terraform references?
No. They are copied into the HCL as ordinary quoted text, so "{{ region }}" stays a string. Replace each one with the matching reference, for example var.region, before you run terraform plan. Loops, when conditions and handlers are not translated either; the checklist at the end of the output reminds you of them.
Will long IDs, zip codes or prices change on the way through?
No. Numbers are written with the text you typed, so 8901240544102066246 and 14.50 come out exactly as they were, and a value with leading zeros such as 00501 is written as the string "00501". Quotes, backslashes and line breaks inside strings are escaped, and ${ or %{ is written as $${ or %%{ so Terraform does not try to interpolate it. Database passwords are never copied; you get a comment telling you to set them from a variable instead.
Can I paste a role tasks file or a vars file instead of a full playbook?
Yes. A list of tasks without hosts is read as tasks, and a plain map of keys and values is read as variables, so a role tasks/main.yml or a group_vars file both work. Roles listed inside a play are only named in a comment, because their tasks live in other files.
Is my playbook sent anywhere?
No. The conversion runs in your browser and nothing is uploaded or kept, so reloading the page starts you off with an empty editor.
Related 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