-
Notifications
You must be signed in to change notification settings - Fork 0
/
_index.md
230 lines (156 loc) · 5.52 KB
/
_index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
title: Any Terraform Provider
meta_desc: Learn how to use any Terraform provider in Pulumi.
layout: package
---
Pulumi's `terraform-provider` can be used to generate full Pulumi SDKs for *any* Terraform provider.
{{% notes type="warning" %}}
This provider is in Public Beta. We are still making breaking changes to nail down the
final design.
{{% /notes %}}
Any feedback is welcome! Please file suggestions and bugs at [pulumi/pulumi-terraform-provider](https://github.com/pulumi/pulumi-terraform-provider/issues).
## Example
As an example, let's depend directly on Hashicorp's [terraform-provider-random](https://github.com/hashicorp/terraform-provider-random).
{{% notes type="info" %}}
You will need to be using a version of Pulumi >= 3.130.0.
{{% /notes %}}
In an existing project, run:
{{< chooser language "typescript,python,go,csharp,java,yaml" >}}
{{% choosable language typescript %}}
```console
$ pulumi package add terraform-provider hashicorp/random
Successfully generated a Nodejs SDK for the random package at /Projects/pulumi/langs/typescript/sdks/random
To use this SDK in your Nodejs project, run the following command:
npm add random@file:sdks/random
You can then import the SDK in your TypeScript code with:
import * as random from "random";
```
{{% /choosable %}}
{{% choosable language python %}}
```console
$ pulumi package add terraform-provider hashicorp/random
Successfully generated a Python SDK for the random package at /Projects/pulumi/langs/python/sdks/random
To use this SDK in your Python project, run the following command:
echo sdks/random >> requirements.txt
pulumi install
You can then import the SDK in your Python code with:
import pulumi_random as random
```
{{% /choosable %}}
{{% choosable language go %}}
```console
$ pulumi package add terraform-provider hashicorp/random
Successfully generated a Go SDK for the random package at /Projects/pulumi/langs/golang/sdks/random
To use this SDK in your Go project, run the following command:
go mod edit -replace github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3=./sdks/random
You can then use the SDK in your Go code with:
import "github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3"
```
{{% /choosable %}}
{{% choosable language csharp %}}
```console
$ pulumi package add terraform-provider hashicorp/random
Successfully generated a .NET SDK for the random package at /Projects/pulumi/langs/csharp/sdks/random
To use this SDK in your .NET project, run the following command:
dotnet add reference sdks/random
You also need to add the following to your .csproj file of the program:
<DefaultItemExcludes>$(DefaultItemExcludes);sdks/**/*.cs</DefaultItemExcludes>
You can then use the SDK in your .NET code with:
using Pulumi.Random;
```
{{% /choosable %}}
{{% choosable language java %}}
```console
$ pulumi package add terraform-provider hashicorp/random
Successfully generated a Java SDK for the random package at /Projects/pulumi/langs/java/sdks/random
To use this SDK in your Java project, complete the following steps:
1. Copy the contents of the generated SDK to your Java project:
cp -r /Projects/pulumi/langs/java/sdks/random/src/* /Projects/pulumi/langs/java/src
2. Add the SDK's dependencies to your Java project's build configuration.
If you are using Maven, add the following dependencies to your pom.xml:
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
</dependencies>
```
{{% /choosable %}}
{{% choosable language yaml %}}
{{% notes type="info" %}}
`terraform-provider` is not available for Pulumi YAML. We are working on
bringing the underlying technology that `terraform-provider` uses to Pulumi YAML. Progress
is tracked in [Parameterized Providers: YAML support #16802](https://github.com/pulumi/pulumi/issues/16802).
{{% /notes %}}
{{% /choosable %}}
{{< /chooser >}}
By following the instructions given, we have generated a Pulumi SDK for the provider and
linked it into our project. We can now import the SDK we generate and consume a resource from it:
{{< chooser language "typescript,python,go,csharp,java,yaml" >}}
{{% choosable language typescript %}}
```ts
import * as random from "random";
new random.Pet("hi");
```
{{% /choosable %}}
{{% choosable language python %}}
```python
import pulumi_random as random
random.Pet("hi")
```
{{% /choosable %}}
{{% choosable language go %}}
```go
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := random.NewPet(ctx, "pet", &random.PetArgs{})
return err
})
}
```
{{% /choosable %}}
{{% choosable language csharp %}}
```csharp
using Pulumi;
using Pulumi.Random;
class MyStack : Stack
{
public MyStack()
{
new Pet("pet");
}
}
```
{{% /choosable %}}
{{% choosable language java %}}
```java
package myproject;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.Pet;
public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
new Pet("pet");
});
}
}
```
{{% /choosable %}}
{{% choosable language yaml %}}
```yaml
# Coming soon
```
{{% /choosable %}}
{{< /chooser >}}