Generated banner for Pulumi Terraform To Pulumi
Generated logo for Pulumi Terraform To Pulumi

Pulumi Terraform To Pulumi

PulumiOfficialPublished by Pulumi

  • Skill
  • Workflow
  • Cloud and DevOps
  • Apache-2.0
  • Low risk

From the author

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.
— the description by Pulumi

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a systematic procedure for transitioning infrastructure-as-code projects from Terraform or OpenTofu to Pulumi. It emphasizes state preservation by utilizing the terraform-migrate plugin to map existing resources to a Pulumi stack. The process covers planning, state extraction, provider dependency management, and code translation to ensure the resulting Pulumi project matches the original infrastructure configuration.

What it does

  • Extracts existing Terraform or OpenTofu state from local or remote backends.
  • Generates a Pulumi state draft using the terraform-migrate plugin.
  • Identifies and installs the necessary Pulumi provider dependencies.
  • Imports translated state data into a new Pulumi stack.
  • Guides the user through aligning source code with the imported state.
  • Verifies the migration via Pulumi preview to ensure no unintended infrastructure changes.

When to use it

  • When you need to migrate an existing Terraform or OpenTofu project to Pulumi.
  • When you want to maintain your current infrastructure state while switching tools.
  • When you need to translate HCL source code into a supported Pulumi language.
  • When you are ready to adopt Pulumi for managing existing cloud resources.

Advantages

  • Ensures state continuity by mapping existing resources to Pulumi.
  • Provides a clear, step-by-step path for complex infrastructure migrations.
  • Reduces manual effort by automating state translation and provider identification.
  • Validates the migration through iterative previewing to ensure infrastructure stability.

Usage examples

“Help me migrate my existing AWS Terraform project to Pulumi using TypeScript.”
The agent will initiate the planning phase, confirm the project paths, and guide you through extracting the state and installing the required Pulumi AWS packages.
“I have a Terraform state file in an S3 bucket. How do I move it to Pulumi?”
The agent will instruct you on how to pull the remote state locally and use the migration plugin to import it into your new Pulumi stack.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/pulumi/pulumi-terraform-to-pulumi/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip pulumi-terraform-to-pulumi.zip -d .agents/skills

Documentation by Pulumi

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.

You must run pulumi_up tool before proceeding to ensure initial stack state is written.

If no local .tfstate file exists in ${terraform_dir}, the state may be in a remote backend (S3, Pulumi Cloud, Terraform Cloud, etc.). Pull it before proceeding:

cd ${terraform_dir} && terraform state pull > terraform.tfstate

This works for all backends, including Pulumi Cloud. If terraform is not available, try tofu state pull instead.

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 that provides the necessary credentials so the command can succeed. If setting up an ESC environment is not feasible, inform the user that the migration cannot proceed automatically.

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 pulumi plugin install, which only downloads plugins without adding dependencies):

# TypeScript/JavaScript
npm install @pulumi/[email protected]

# Python
pip install pulumi_aws==7.12.0

# Go
go get github.com/pulumi/pulumi-aws/sdk/[email protected]

# C#
dotnet add package Pulumi.Aws --version 7.12.0

Import the translated state draft (/tmp/pulumi-state.json) into the Pulumi stack:

pulumi stack import --file /tmp/pulumi-state.json

Translate source code to match both the Terraform source and the translated state. Aim for exact match. You can consult the state draft /tmp/pulumi-state.json for Pulumi resource types and names to use.

Iterate on fixing the source code until pulumi_preview tool confirms that there are no changes to make and the diff is empty or almost empty. Provider diffs or diffs on tags may be OK.

Offer the user to link an ESC environment to the stack so that each Pulumi stack can seamlessly have access to the provider credentials it needs.

When all looks good, create a Pull Request with the migrated source code.

Files

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python, Needs Node.js

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Pulumi
Publisher
Pulumi (Official)
Source
pulumi/agent-skills · migration/skills/pulumi-terraform-to-pulumi · commit 82f222a
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Pulumi or Pulumi.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download pulumi-terraform-to-pulumi.zip