@@ -12,33 +12,38 @@ tags:
12
12
- features
13
13
---
14
14
15
- We are excited to announce that Pulumi can now execute [ Terraform modules
16
- directly] ( https://github.com/pulumi/pulumi-terraform-module ) . This new capability unlocks a great option for users
17
- contemplating migrating a large Terraform installation to Pulumi: when dealing with a complicated Terraform module, you
18
- can now bypass translating its sources while still quickly moving its state over to Pulumi and cross-linking its inputs
19
- and outputs with Pulumi code. Additionally, all Pulumi users can now more easily benefit from the existing awesome
20
- modules in the Terraform registry.
15
+ Today Pulumi is introducing the capability to execute
16
+ [ Terraform modules directly] ( https://www.pulumi.com/docs/iac/using-pulumi/extending-pulumi/use-terraform-module/ ) .
17
+ This makes migrating complex infrastructure from Terraform to Pulumi us now simpler than ever.
21
18
22
19
<!-- more-->
23
20
24
- As organizations optimize their infrastructure management, many teams are exploring transitioning from Terraform to
25
- Pulumi. However, migrating existing, complex Terraform configurations to Pulumi has often been cited as challenging,
26
- especially when intricate Terraform modules are involved. Our customers tell us that Pulumi's [ pulumi convert --from
27
- terraform] ( https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/ ) is very useful for small to
28
- medium programs, but runs into challenges on more complex projects, especially involving modules. Even when sources
29
- convert successfully, full migration still requires meticulous validation to ensure production infrastructure
30
- continuity is not affected by small differences in Pulumi and Terraform behavior.
31
-
32
- To address this feedback, Pulumi is excited to announce new support for executing Terraform modules directly within
33
- Pulumi. This new feature enables teams to continue utilizing their existing Terraform modules without source
34
- modifications. Modules execute under their exact Terraform semantics powered by [ OpenTofu] ( https://opentofu.org ) . Their
35
- inputs and outputs are exposed in a type-safe manner to your favorite Pulumi programming language, to be freely
36
- composed with other Pulumi components. Finally, Terraform state is automatically [ stored in
37
- Pulumi] ( https://www.pulumi.com/docs/iac/concepts/state-and-backends/ ) and takes full advantage of proper [ secret
38
- encryption] ( https://www.pulumi.com/docs/iac/concepts/secrets/ ) .
39
-
40
- Our hope is that this approach becomes an important part of the migration toolbox to be applied to selectively to those
41
- parts of the codebase that have the highest migration risk and/or source complexity.
21
+ We are releasing this feature in response to user feedback: our users tell us that while Pulumi's [ pulumi convert
22
+ --from terraform] ( https://www.pulumi.com/blog/converting-full-terraform-programs-to-pulumi/ ) is very useful for small
23
+ programs, it runs into challenges on more complex projects, especially ones involving modules. With the new feature you
24
+ no longer need to convert module sources, and can immediately manage everything with Pulumi.
25
+
26
+ What is included in the launch:
27
+
28
+ - ` pulumi package add terraform-module <module-source> [<version>] <pulumi-package-name> ` command can now run modules
29
+ from Terraform and OpenTofu registries as well as locally managed modules under Pulumi. This is enabled by the new
30
+ [ terraform-module] ( https://github.com/pulumi/pulumi-terraform-module ) provider.
31
+
32
+ - ` pulumi convert --from terraform ` now supports a ` // @pulumi-terraform-module <pulumi-package-name> ` annotation to
33
+ avoid translating a module recursively and instead execute it directly.
34
+
35
+ - Pulumi providers expose helper methods to assist with keeping config consistent across Pulumi and Terraform providers
36
+ required to run modules. For example, [ AWS provider] ( https://github.com/pulumi/pulumi-aws ) allows to query
37
+ ` awsProvider.terraformConfig() ` .
38
+
39
+ ## How it works
40
+
41
+ Under the hood Pulumi orchestrates an configurable executor such as ` tofu ` or ` terraform ` CLI to run updates against
42
+ your infrastructure. Module code executes under exact Terraform semantics, but participates in Pulumi lifecycle with
43
+ ` pulumi {preview,up,refresh,destroy} ` . Module inputs and outputs are exposed in a type-safe manner to your favorite
44
+ Pulumi programming language, to be freely composed with other Pulumi components. Finally, Terraform state is
45
+ automatically [ stored in Pulumi] ( https://www.pulumi.com/docs/iac/concepts/state-and-backends/ ) and takes full advantage
46
+ of proper [ secret encryption] ( https://www.pulumi.com/docs/iac/concepts/secrets/ ) .
42
47
43
48
## Walkthrough
44
49
@@ -96,6 +101,8 @@ export const privateSubnets = vpc.private_subnets;
96
101
97
102
If you have AWS credentials set up, you can now do ` pulumi up ` and it will show all the resources being created:
98
103
104
+ TODO: the preview update section looks different with views.
105
+
99
106
```
100
107
101
108
Previewing update (dev)
@@ -202,8 +209,30 @@ The above program is very simple. To take it further, check out
202
209
features such as computing subnets dynamically with Pulumi ` aws.getAvailabilityZonesOutput ` function or passing the
203
210
results of the VPC module to an EKS module.
204
211
205
- // TODO show-case cross-configuring the provider with a given AWS region
206
- // TODO show-case converting TF programs with @sandbox annotation
212
+ If you are instead starting from a Terraform program, you can use ` pulumi convert ` instead. Just make sure to annotate
213
+ the modules with a special comment marker ` // @pulumi-terraform-module ` . For example, given this ` infra.tf ` :
214
+
215
+ ``` terraform
216
+ // @pulumi-terraform-module vpcmod
217
+ module "my-vpc" {
218
+ source = "terraform-aws-modules/vpc/aws"
219
+ version = "5.18.1"
220
+ azs = ["us-west-2a", "us-west-2b"]
221
+ name = "test-vpc-123"
222
+ public_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
223
+ private_subnets = ["10.0.3.0/24", "10.0.4.0/24"]
224
+ enable_nat_gateway = true
225
+ single_nat_gateway = true
226
+ }
227
+ ```
228
+
229
+ Run ` pulumi convert ` as follows:
230
+
231
+ ``` shell
232
+ pulumi convert --from terraform --language typescript --out my-pulumi-project
233
+ ```
234
+
235
+ The resulting ` my-pulumi-project ` folder will have the project setup correctly for executing the ` my-vpc ` module.
207
236
208
237
## Supported Features
209
238
@@ -233,17 +262,12 @@ configuration options.
233
262
234
263
## What's next
235
264
236
- As part of hardening this feature Pulumi will be looking at removing the limitations and improving error handling and
237
- usability of the directly executed modules. Our team is currently excited about these possibilities:
238
-
239
- - extending ` pulumi convert --from terraform ` to put the users in control of which modules are converted recursively to
240
- Pulumi source code, and which are instead converted into directly executed modules
241
-
242
- - enhancing state import from Terraform into Pulumi to seamlessly work with directly executed modules
265
+ We are working on enhancing state import from Terraform into Pulumi to work in tandem with source conversion and
266
+ provide a seamless migration experience.
243
267
244
268
## Get Started
245
269
246
270
Support for modules is available as of today. Download the latest Pulumi CLI and it a try. If you run into any issues
247
- or have suggestions and feedback, please [ let us
248
- know] ( https://github.com/pulumi/pulumi-terraform-module/issues/new/choose ) or reach out in the [ Pulumi Community
249
- Slack] ( https://slack.pulumi.com/ ) .
271
+ or have suggestions and feedback, please
272
+ [ let us know] ( https://github.com/pulumi/pulumi-terraform-module/issues/new/choose ) or reach out in the
273
+ [ Pulumi Community Slack] ( https://slack.pulumi.com/ ) .
0 commit comments