This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
state convert blog #3428
Merged
Merged
state convert blog #3428
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
themes/default/content/blog/converting-full-terraform-states-to-pulumi/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "Converting Full Terraform States to Pulumi" | ||
date: 2023-10-09 | ||
meta_desc: Learn how to convert whole Terraform states to Pulumi using the new Terraform converter | ||
meta_image: meta.png | ||
authors: | ||
- fraser-waters | ||
tags: | ||
- migration | ||
--- | ||
|
||
Building on our work of [converting Terraform projects](/docs/converting-full-terraform-programs-to-pulumi), we now have support for adopting resources from Terraform state. | ||
|
||
<!--more--> | ||
|
||
In the prior blog post about converting from Terraform we called out that while it was great that the converter could migrate a Terraform project, but what if you had existing infrastructure resources. | ||
|
||
Historically we've shared some AWS specific code for [TypeScript](https://github.com/pulumi/tf2pulumi/blob/master/misc/import/import.ts) and [Go](https://github.com/pulumi/tf2pulumi/blob/master/misc/import-go/import.go) to import from `.tfstate` files. These have been useful, but they're limited to the AWS provider and either Go or TypeScript programs. | ||
|
||
From [v3.87.0](/docs/install) we have extended our converter system to also include state in addition to code. So now it's possible to import resources from other state systems, the first of which is Terraform. | ||
|
||
## Converting a Real World Workspace | ||
|
||
Terraform stores its state in workspaces. In the most simple case this is just a `terraform.tfstate` file in the directory with the code. For remote state it can be fetched with [terraform state pull](https://developer.hashicorp.com/terraform/cli/commands/state/pull). | ||
|
||
Given a `terraform.tfstate` file we can set up a Pulumi stack and tell it to import the resource from Terraform. | ||
|
||
```bash | ||
$ pulumi stack init | ||
$ pulumi import --from terraform ./terraform.tfstate | ||
``` | ||
|
||
Pulumi will try to convert the resources in the Terraform state into their matching Pulumi types and import strings (normally just the resource ID). | ||
|
||
Some resources don't use their ID as the import string. For some well known AWS resources the converter will handle this; for others, they might still cause an error at import time. However, if the import does fail (for any reason) the import file listing all the resources will be written out to the current directory, allowing you the opportunity to manually fix up issues with type tokens or import strings, and then try again using `pulumi import --file`. | ||
|
||
We're working on ensuring more types correctly translate, so feel free to open issues with any import errors you get while using this new converter to help us improve. | ||
|
||
## Get Started | ||
|
||
Support for the new `pulumi import --from terraform` command is now available in v3.87.0 of the Pulumi CLI. [Download](/docs/install/) the latest Pulumi CLI and give the new converter a try today. If you run into any issues, please [let us know](https://github.com/pulumi/pulumi/issues/new/choose) or reach out in the [Pulumi Community Slack](https://slack.pulumi.com) with any questions! |
Binary file added
BIN
+599 KB
themes/default/content/blog/converting-full-terraform-states-to-pulumi/meta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.