Skip to content

Commit 0c75151

Browse files
committed
Introduce choosables
1 parent 0e2cbb6 commit 0c75151

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

content/docs/iac/extending-pulumi/use-terraform-module.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ packages:
117117
- rdsmod
118118
```
119119
120+
{{% chooser language "typescript,yaml" %}}
121+
122+
{{% choosable language typescript %}}
123+
120124
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:
121125

122126
***Example:** index.ts - Using the Terraform VPC and RDS module in a Pulumi program*
@@ -204,12 +208,41 @@ function getCidrSubnet(cidr: string, netnum: number): pulumi.Output<string> {
204208
}
205209
```
206210

211+
{{% /choosable %}}
212+
213+
{{% choosable language yaml %}}
214+
215+
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+
207236
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.
208237

209238
## Configuring Terraform Providers
210239

211240
Some modules require Terraform providers to be configured with specific settings. You can configure these providers from within Pulumi:
212241

242+
{{% chooser language "typescript" %}}
243+
244+
{{% choosable language typescript %}}
245+
213246
**Example:** index.ts - Configuring the imported Terraform bucket module*
214247

215248
```typescript
@@ -228,24 +261,11 @@ const testBucket = new bucket.Module("test-bucket", {
228261
}, { provider: provider });
229262
```
230263

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 %}}
234265

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 %}}
236267

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

250270
## Troubleshooting
251271

0 commit comments

Comments
 (0)