microscopic-pilot-97530
pulumi convert --from terraform
command in v3.71.0 of the Pulumi CLI. It can convert whole Terraform projects, including Terraform modules. Read more about it at https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/salmon-gold-74709
06/13/2023, 7:54 AMechoing-dinner-19531
06/13/2023, 8:30 AMhope you can continue to improve thisWe will! While we've phrased this as bringing "tf2pulumi" into the CLI it's actually a complete rewrite of the Terraform conversion code to take full advantage of CrossCode. It should be much easier for us to fix issues and support new features. Plus we'll be spending significant effort in the coming months improving the stability and functionality of CrossCode itself.
millions-furniture-75402
06/13/2023, 12:01 PMerror: /Users/catmeme/dev/vendor/pulumi/vault-infra/terraform/main/providers.tf:5,12-15: Variables not allowed; Variables may not be used here.
error: /Users/catmeme/dev/vendor/pulumi/vault-infra/terraform/main/providers.tf:4,1-15: Failed to evaluate provider config; Failed to evaluate provider config for aws:region
error: load project: could not validate '/var/folders/5w/46p_zz3x3kd6j46cbsj7x6bh0000gn/T/pulumi-convert352646147/Pulumi.yaml': 3 errors occurred:
* #/runtime: oneOf failed
* #/runtime: length must be >= 1, but got 0
* #/runtime: expected object, but got string
echoing-dinner-19531
06/13/2023, 12:05 PMmillions-furniture-75402
06/13/2023, 12:06 PMgit clone <https://github.com/avantoss/vault-infra.git>
cd vault-infra/terraform/main
pulumi convert --from terraform --language typescript --out pulumi
echoing-dinner-19531
06/13/2023, 12:06 PMmillions-furniture-75402
06/13/2023, 12:06 PMechoing-dinner-19531
06/13/2023, 12:41 PMmillions-furniture-75402
06/13/2023, 12:43 PMerror: could not generate output program: no resource plugin 'pulumi-resource-std' found in the workspace or on your $PATH
echoing-dinner-19531
06/13/2023, 12:43 PMmillions-furniture-75402
06/13/2023, 12:43 PM❯ pulumi version
v3.70.0
echoing-dinner-19531
06/13/2023, 12:44 PMmillions-furniture-75402
06/13/2023, 12:45 PM3.71.0
error: /Users/catmeme/dev/vendor/pulumi/vault-infra/terraform/main/providers.tf:5,12-15: Variables not allowed; Variables may not be used here.
error: /Users/catmeme/dev/vendor/pulumi/vault-infra/terraform/main/providers.tf:4,1-15: Failed to evaluate provider config; Failed to evaluate provider config for aws:region
error: conversion failed
echoing-dinner-19531
06/13/2023, 12:47 PMmillions-furniture-75402
06/13/2023, 2:27 PMdefault_tags
and ebsBlockDevice
echoing-dinner-19531
06/13/2023, 2:35 PMsalmon-gold-74709
06/14/2023, 1:25 PMpulumi convert
and pulumi import
to convert TF code (and state)?
Comparing to https://www.pulumi.com/docs/using-pulumi/adopting-pulumi/import/ it seems that import can generate code from TF - what are the pros / cons of the two options?echoing-dinner-19531
06/14/2023, 2:32 PMsalmon-gold-74709
06/14/2023, 2:35 PMechoing-dinner-19531
06/14/2023, 2:45 PMimport
doesn't understand relationships between resources, configuration, unspecified default values, or resource meta-arguments (like having three of the same resource, or having protect
set).
convert
can understand all of the above as it gets to work directly with the markup source code that defined the resources in the first place.
However the domain of convert
is much more complicated than import and you are more likely to hit issues with it where it can't work out how to correctly translate things.
import
is a very simple "read the data, emit a single code block to set the data", so its much less likely to fail or emit something incorrect.
Finally if you already have resources created you have to use import
in some capacity to bring them into pulumi state. You might still want to use convert
first to get a good program for it, and then just use import
to get state and throw away it's codegen.
If you don't have resources created then you can't use import
because it depends on actual resource data read from the cloud api, but you can still use convert
.
And as I said above, we're looking at adding a way to take a terraform workspace and use convert
to translate it's markup to a pulumi program, and then import
to import it's state. So the best results will come from using both commands together.salmon-gold-74709
06/14/2023, 2:45 PMechoing-dinner-19531
06/14/2023, 2:47 PMsalmon-gold-74709
06/14/2023, 2:50 PM