pulumi-terraform-to-pulumi

作成者: pulumi

Terraform/OpenTofuプロジェクトをPulumiに移行します。HCLソースコードの変換や、Terraformの状態をPulumiスタックにインポートする機能を含みます。ユーザーが…場合に使用します。

npx skills add https://github.com/pulumi/agent-skills --skill pulumi-terraform-to-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/aws@7.12.0

# Python
pip install pulumi_aws==7.12.0

# Go
go get github.com/pulumi/pulumi-aws/sdk/v7@v7.12.0

# 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.

pulumiのその他のスキル

package-usage
pulumi
Pulumi組織全体のスタックにおいて、特定のパッケージがどのバージョンで使用されているかを追跡します。クロススタック監査や、古くなった、またはメンテナンスされていないものを特定するために使用します…
official
pulumi-automation-api
pulumi
Pulumiインフラストラクチャ操作を複数のスタックやアプリケーションにわたってプログラム的にオーケストレーションします。ローカルソース(既存のPulumiプロジェクト)とインラインソース(埋め込みプログラム)の両方のアーキテクチャをサポートし、シンプルなものから複雑なマルチスタックシナリオまで柔軟なデプロイパターンを実現します。依存関係の順序付け、並行した独立デプロイ、スタック間の出力受け渡しによる調整されたインフラプロビジョニングを備えたマルチスタックオーケストレーションを処理します。プログラム的な...
official
pulumi-best-practices
pulumi
信頼性が高く保守しやすいPulumiインフラストラクチャコードを記述するための包括的なベストプラクティス。apply()コールバック内でリソースを作成せず、依存関係の追跡とプレビューの可視性を維持するためにOutputオブジェクトを直接入力として渡します。ComponentResourceクラスを使用して関連リソースを再利用可能な論理ユニットにグループ化し、parent: thisを介して適切な親子階層を設定します。--secretフラグまたはconfig.requireSecret()を使用して最初からシークレットを暗号化し、状態ファイルへの認証情報漏洩を防ぎます...
official
pulumi-component
pulumi
再利用可能なインフラストラクチャコンポーネントで、多言語サポート、適切なデフォルト設定、および構成パターンを備えています。4つのコア要素が必要です:ComponentResourceを拡張し、標準パラメータを受け入れ、すべての子にparent: thisを設定し、コンストラクタの最後にregisterOutputs()を呼び出します。ArgsインターフェースはInput<T>ラッパーを使用し、ユニオン型や関数を避け、構造をフラットに保つことで多言語SDK生成をサポートします。必須の出力のみをパブリックプロパティとして公開し、非表示にします...
official
pulumi-debug-failed-operation
pulumi
失敗したPulumiの更新またはプレビューをデバッグします:Pulumiが既に記録した失敗を読み取り、原因を特定して修正します。ユーザーが依頼したときにこのスキルを読み込んでください。
official
pulumi-esc
pulumi
Pulumiインフラストラクチャとアプリケーション向けの、集中管理されたシークレット、設定、動的認証情報管理。インポートとレイヤリングによる環境構成をサポートし、environmentVariables、pulumiConfig、files用の予約キーを備えています。OIDCを介してAWS、Azure、GCP向けの短期認証情報を生成し、AWS Secrets Manager、Azure Key Vault、HashiCorp Vault、1Passwordと統合します。コアCLIコマンドには、pulumi env init、pulumi env edit、pulumi env open(表示...)が含まれます。
official
pulumi-neo-handoff
pulumi
現在のスレッドを新しいPulumi Neoタスクに一方向で引き継ぎます。ユーザーが明示的に引き継ぎ、送信、転送、または現在の続行を依頼した場合に使用します…
official
pulumi-overview
pulumi
このスキルは、クラウドインフラストラクチャやSaaS構成を作成、変更、検査、または破棄するあらゆるタスクに使用します。単発のCLI操作から完全な…
official