| name | pulumi-terraform-to-pulumi |
| description | Migrate Terraform projects to Pulumi. Use when users need to move infrastructure from Terraform to Pulumi, translate HCL configurations, or convert Terraform modules to Pulumi components. |
Migrating from Terraform to Pulumi
First establish scope and plan the migration by working out with the user:
- where the Terraform sources are (
${terraform_dir})
- where the migrated Pulumi project lives (
${pulumi_dir})
- what is the target Pulumi language (such as TypeScript, Python, YAML)
- whether migration aims to setup Pulumi stack states, or only translate source code
Confirm the plan with the user before proceeding.
Create a new Pulumi project in ${pulumi_dir} in the chosen language. Edit sources to be empty and not declare any
resources. Ensure a Pulumi stack exists.
You must run pulumi_up tool before proceeding to ensure initial stack state is written.
Now produce a draft Pulumi state translation:
pulumi plugin run terraform-migrate -- stack \
--from ${terraform_dir} \
--to ${pulumi_dir} \
--out /tmp/pulumi-state.json \
--plugins /tmp/required-providers.json
Do NOT install the plugin as it will auto-install as needed.
Sometimes terraform-migrate plugin fails because tofu refresh is not authorized. DO NOT skip this step. Work with the
user to find or build a Pulumi ESC environment to run the command in to make it succeed.
Read the generated /tmp/required-providers.json and install all these Pulumi providers into the new project,
respecting the suggested versions even if they downgrade an already installed provider. The file will contain records
such as [{"name":"aws","version":"7.12.0"}].
Install providers as project dependencies using the language-specific package manager (NOT ,
which only downloads plugins without adding dependencies):