Skip to content

Commit d8e60e6

Browse files
authored
feat(tf): tf.Element (#280)
* feat(tf): `tf.Element` * Update README.md
1 parent 37ec403 commit d8e60e6

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

tf/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,28 @@ class DnsimpleProvider {
185185
186186
Use `DnsimpleProvider.getOrCreate(scope)` to get the provider instance.
187187
188+
## `tf.Element`
189+
190+
Just a blob of JSON that goes into the Terraform output:
191+
192+
```js
193+
bring tf;
194+
195+
new tf.Element({
196+
provider: [
197+
{ aws: { } },
198+
{ aws: { alias: "server_function" } },
199+
{ aws: { alias: "global", region: "us-east-1" } }
200+
]
201+
});
202+
```
203+
204+
The above example will add a `provider` section to the output Terraform with a set of providers.
205+
188206
## Maintainers
189207
190208
* [Elad Ben-Israel](@eladb)
209+
* [Chris Rybicki](@Chriscbr)
191210
192211
## License
193212

tf/element.test.w

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bring util;
2+
bring "./element.w" as e;
3+
4+
if util.env("WING_TARGET").startsWith("tf") {
5+
new e.Element({
6+
provider: [
7+
{ foo: "bar" },
8+
{ baz: "qux" }
9+
]
10+
});
11+
}

tf/element.test.w.tf-aws.snap.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# `element.test.w.tf-aws.snap.md`
2+
3+
## main.tf.json
4+
5+
```json
6+
{
7+
"//": {
8+
"metadata": {
9+
"backend": "local",
10+
"stackName": "root",
11+
"version": "0.20.3"
12+
},
13+
"outputs": {
14+
}
15+
},
16+
"provider": [
17+
{
18+
"foo": "bar"
19+
},
20+
{
21+
"baz": "qux"
22+
}
23+
],
24+
"terraform": {
25+
"backend": {
26+
"local": {
27+
"path": "./terraform.tfstate"
28+
}
29+
},
30+
"required_providers": {
31+
"aws": {
32+
"source": "aws",
33+
"version": "5.31.0"
34+
}
35+
}
36+
}
37+
}
38+
```

tf/element.w

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
bring "cdktf" as cdktf;
3+
4+
pub class Element extends cdktf.TerraformElement {
5+
config: Json;
6+
7+
new(config: Json) {
8+
super();
9+
this.config = config;
10+
}
11+
12+
pub toTerraform(): Json {
13+
return this.config;
14+
}
15+
}

tf/provider.test.w.tf-aws.snap.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# `provider.test.w.tf-aws.snap.md`
2+
3+
## main.tf.json
4+
5+
```json
6+
{
7+
"//": {
8+
"metadata": {
9+
"backend": "local",
10+
"stackName": "root",
11+
"version": "0.20.3"
12+
},
13+
"outputs": {
14+
}
15+
},
16+
"provider": {
17+
"aws": [
18+
{
19+
}
20+
],
21+
"dnsimple": [
22+
{
23+
"token": "dnsimple_token"
24+
}
25+
]
26+
},
27+
"terraform": {
28+
"backend": {
29+
"local": {
30+
"path": "./terraform.tfstate"
31+
}
32+
},
33+
"required_providers": {
34+
"aws": {
35+
"source": "aws",
36+
"version": "5.31.0"
37+
},
38+
"dnsimple": {
39+
"source": "dnsimple/dnsimple",
40+
"version": "1.6.0"
41+
}
42+
}
43+
}
44+
}
45+
```

0 commit comments

Comments
 (0)