You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/iac/extending-pulumi/use-terraform-module.md
+36-16Lines changed: 36 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,10 @@ packages:
117
117
- rdsmod
118
118
```
119
119
120
+
{{% chooser language "typescript,yaml" %}}
121
+
122
+
{{% choosable language typescript %}}
123
+
120
124
Since this was a TypeScript project, Pulumi generated a TypeScript SDK for the modules, making those available to use as `@pulumi/vpcmod` and `@pulumi/rdsmod` respectively. We can now use the Terraform modules directly in our TypeScript code:
121
125
122
126
***Example:** index.ts - Using the Terraform VPC and RDS module in a Pulumi program*
When authoring in YAML, there's no need for Pulumi to generate a SDK. In the YAML you can reference the Terraform module by its schema token, which takes the format `<module-name>:index:Module`:
216
+
217
+
**Example:** Pulumi.yaml - Using an imported Terraform module in a Pulumi YAML program*
218
+
219
+
TODO expand this example to match TypeScript above.
220
+
221
+
```yaml
222
+
resources:
223
+
my-rds:
224
+
type: rdsmod:index:Module
225
+
properties:
226
+
engine: mysql
227
+
identifier: my-rds-instance
228
+
manage_master_user_password: true
229
+
# other properties...
230
+
```
231
+
232
+
{{% /choosable %}}
233
+
234
+
{{% /chooser %}}
235
+
207
236
In the above code, the imported Terraform module works the same as any other Pulumi code. Outputs are returned, and resource state is stored in your Pulumi state storage, alongside all your other Pulumi-native resources. This also means that resource dependencies work as expected between Pulumi-native resources and resources created by Terraform modules.
208
237
209
238
## Configuring Terraform Providers
210
239
211
240
Some modules require Terraform providers to be configured with specific settings. You can configure these providers from within Pulumi:
212
241
242
+
{{% chooser language "typescript" %}}
243
+
244
+
{{% choosable language typescript %}}
245
+
213
246
**Example:** index.ts - Configuring the imported Terraform bucket module*
214
247
215
248
```typescript
@@ -228,24 +261,11 @@ const testBucket = new bucket.Module("test-bucket", {
228
261
}, { provider: provider });
229
262
```
230
263
231
-
Provider configuration is module-specific, so refer to the module's documentation for available configuration options.
232
-
233
-
## Using Modules with Pulumi YAML
264
+
{{% /choosable %}}
234
265
235
-
When authoring in YAML, there's no need for Pulumi to generate a SDK. In the YAML you can reference the Terraform module by its schema token, which takes the format `<module-name>:index:Module`:
266
+
{{% /chooser %}}
236
267
237
-
**Example:** Pulumi.yaml - Using an imported Terraform module in a Pulumi YAML program*
238
-
239
-
```yaml
240
-
resources:
241
-
my-rds:
242
-
type: rdsmod:index:Module
243
-
properties:
244
-
engine: mysql
245
-
identifier: my-rds-instance
246
-
manage_master_user_password: true
247
-
# other properties...
248
-
```
268
+
Provider configuration is module-specific, so refer to the module's documentation for available configuration options.
0 commit comments