Migrate Terraform/OpenTofu projects to Pulumi, including translating HCL source code and/or importing Terraform state into a Pulumi stack. Use when a user wants to convert Terraform to Pulumi, migrate from HCL, or…
---
name: pulumi-terraform-to-pulumi
description: Migrate Terraform/OpenTofu projects to Pulumi, including translating HCL source code and/or importing Terraform state into a Pulumi stack. Use when a user wants to convert Terraform to Pulumi, migrate from HCL, or import tfstate into Pulumi. Do NOT trigger for general Terraform-vs-Pulumi comparisons or questions about using both tools side-by-side.
---
# Migrating from Terraform to Pulumi
> **Critical constraints — read before acting:**
> - Do NOT run `pulumi convert` — use the terraform-migrate plugin instead, which preserves state mapping.
> - Do NOT run `pulumi package add terraform-module` — this is for a different workflow.
> - Do NOT create the Pulumi project under `/workspace` — create it inside the checked-out repo.
> - Replace `${terraform_dir}` and `${pulumi_dir}` below with the actual paths confirmed with the user.
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.