This is an EXPERIMENTAL tool for assisting migrating Terraform projects to Pulumi.
For robust approaches to migration please see the official documentation.
This tool is useful in pipelines that given a Terraform project with sources and state aim to produce equivalent Pulumi sources and state tracking the same infrastructure. Crucially such pipelines should not do any write operations on the actual infrastructure, staying in the purely symbolic exploratory world.
The key command translates an entire stack:
$ pulumi plugin run terraform-migrate -- stack --help
Translate Terraform state to a Pulumi stack state.
Example:
pulumi plugin run terraform-migrate -- stack \
--from path/to/terraform-sources \
--to path/to/pulumi-project \
--out /tmp/pulumi-state.json \
--plugins /tmp/required-plugins.json
The translated state picks recommended Pulumi providers and resource types to represent every Terraform resource
present in the source.
Before running this tool, '--to path/to/pulumi-project' should contain a valid Pulumi project with a
currently selected stack that already has initial state ('pulumi stack export' succeeds).
Generated 'pulumi-state.json' file is in the format compatible with importing into a Pulumi project:
pulumi stack import --file pulumi-state.json
Setting the optional '--plugins' parameter generates a 'required-plugins.json' such as '[{"name":"aws", "version":"7.12.0"}]'.
This file recommends Pulumi plugins and versions to install into the project, for example:
pulumi plugin install resource aws 7.12.0
The tool may run 'tofu', 'tofu init', 'tofu refresh' to extract the Terraform state and these commands may require
authorizing read-only access to the cloud accounts. The tool never runs mutating commands such as 'tofu apply'.
See also:
- pulumi stack import
https://www.pulumi.com/docs/iac/cli/commands/pulumi_stack_import/
- pulumi plugin install
https://www.pulumi.com/docs/iac/cli/commands/pulumi_plugin_install/
This produces a draft Pulumi stack state that represents a translated input Terraform state. Additionally it produces a map of recommended Pulumi provider names and versions to use in the translation.
To proceed with the migration, import the state into your Pulumi stack, feed these artifacts into an LLM, and ask it to
produce Pulumi sources that translate the Terraform sources. Instructing the LLM to aim for a clean pulumi preview
helps is to fix discrepancies between code and state and get accurate results.