@cdktn/hcl2cdk 0.24.0-pre.45 → 0.24.0-pre.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +355 -0
- package/README.md +1 -1
- package/build/__tests__/expressions.test.js +10 -19
- package/build/__tests__/functions.test.js +8 -18
- package/build/__tests__/testHelpers.js +3 -2
- package/build/coerceType.js +11 -21
- package/build/dynamic-blocks.js +3 -3
- package/build/expressions.js +13 -22
- package/build/function-bindings/functions.generated.js +2 -2
- package/build/generation.js +24 -34
- package/build/index.js +15 -25
- package/build/iteration.js +7 -6
- package/build/jsii-rosetta-workarounds.js +6 -5
- package/build/partialCode.js +11 -20
- package/build/provider.js +4 -3
- package/build/references.js +6 -5
- package/build/schema.js +8 -18
- package/build/terraformSchema.js +4 -4
- package/build/utils.js +3 -3
- package/build/variables.js +12 -21
- package/package.json +20 -17
- package/package.sh +1 -1
- package/src/__tests__/coerceType.test.ts +207 -0
- package/src/__tests__/expressionToTs.test.ts +1167 -0
- package/src/__tests__/expressions.test.ts +541 -0
- package/src/__tests__/findExpressionType.test.ts +112 -0
- package/src/__tests__/functions.test.ts +768 -0
- package/src/__tests__/generation.test.ts +72 -0
- package/src/__tests__/jsii-rosetta-workarounds.test.ts +145 -0
- package/src/__tests__/partialCode.test.ts +432 -0
- package/src/__tests__/terraformSchema.test.ts +107 -0
- package/src/__tests__/testHelpers.ts +11 -0
- package/src/coerceType.ts +261 -0
- package/src/dynamic-blocks.ts +61 -0
- package/src/expressions.ts +968 -0
- package/src/function-bindings/functions.generated.ts +1139 -0
- package/src/function-bindings/functions.ts +104 -0
- package/src/generation.ts +1189 -0
- package/src/index.ts +584 -0
- package/src/iteration.ts +156 -0
- package/src/jsii-rosetta-workarounds.ts +145 -0
- package/src/partialCode.ts +132 -0
- package/src/provider.ts +60 -0
- package/src/references.ts +193 -0
- package/src/schema.ts +74 -0
- package/src/terraformSchema.ts +182 -0
- package/src/types.ts +58 -0
- package/src/utils.ts +19 -0
- package/src/variables.ts +214 -0
- package/test/__snapshots__/backends.test.ts.snap +70 -0
- package/test/__snapshots__/externals.test.ts.snap +37 -0
- package/test/__snapshots__/granular-imports.test.ts.snap +180 -0
- package/test/__snapshots__/imports.test.ts.snap +159 -0
- package/test/__snapshots__/iteration.test.ts.snap +532 -0
- package/test/__snapshots__/jsiiLanguage.test.ts.snap +347 -0
- package/test/__snapshots__/locals.test.ts.snap +55 -0
- package/test/__snapshots__/modules.test.ts.snap +127 -0
- package/test/__snapshots__/outputs.test.ts.snap +77 -0
- package/test/__snapshots__/partialCode.test.ts.snap +120 -0
- package/test/__snapshots__/provider.test.ts.snap +128 -0
- package/test/__snapshots__/references.test.ts.snap +376 -0
- package/test/__snapshots__/resource-meta-properties.test.ts.snap +342 -0
- package/test/__snapshots__/resources.test.ts.snap +613 -0
- package/test/__snapshots__/tfExpressions.test.ts.snap +537 -0
- package/test/__snapshots__/typeCoercion.test.ts.snap +253 -0
- package/test/__snapshots__/variables.test.ts.snap +150 -0
- package/test/backends.test.ts +75 -0
- package/test/convertProject.test.ts +257 -0
- package/test/externals.test.ts +35 -0
- package/test/globalSetup.ts +224 -0
- package/test/globalTeardown.ts +11 -0
- package/test/granular-imports.test.ts +161 -0
- package/test/hcl2cdk.test.ts +88 -0
- package/test/helpers/convert.ts +543 -0
- package/test/helpers/tmp.ts +25 -0
- package/test/imports.test.ts +141 -0
- package/test/iteration.test.ts +342 -0
- package/test/jsiiLanguage.test.ts +73 -0
- package/test/locals.test.ts +47 -0
- package/test/modules.test.ts +143 -0
- package/test/outputs.test.ts +69 -0
- package/test/partialCode.test.ts +25 -0
- package/test/provider.test.ts +106 -0
- package/test/references.test.ts +287 -0
- package/test/resource-meta-properties.test.ts +288 -0
- package/test/resources.test.ts +551 -0
- package/test/tfExpressions.test.ts +300 -0
- package/test/typeCoercion.test.ts +154 -0
- package/test/variables.test.ts +96 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`JSII Language Support complex aws example snapshot csharp 1`] = `
|
|
4
|
+
"using Constructs;
|
|
5
|
+
using Io.Cdktn;
|
|
6
|
+
/*
|
|
7
|
+
* Provider bindings are generated by running \`cdktn get\`.
|
|
8
|
+
* See https://cdktn.io/docs/concepts/providers#import-providers for more details.
|
|
9
|
+
*/
|
|
10
|
+
using aws.Kms.Key;
|
|
11
|
+
using aws.Provider;
|
|
12
|
+
using aws.S3.Bucket;
|
|
13
|
+
using aws.S3.Bucket.Object;
|
|
14
|
+
using aws.Security.Group;
|
|
15
|
+
class MyConvertedCode : TerraformStack
|
|
16
|
+
{
|
|
17
|
+
public MyConvertedCode(Construct scope, string name) : base(scope, name)
|
|
18
|
+
{
|
|
19
|
+
new AwsProvider(this, "aws", new AwsProviderConfig {
|
|
20
|
+
Region = "us-east-1"
|
|
21
|
+
});
|
|
22
|
+
var examplekms = new KmsKey(this, "examplekms", new KmsKeyConfig {
|
|
23
|
+
DeletionWindowInDays = 7,
|
|
24
|
+
Description = "KMS key 1"
|
|
25
|
+
});
|
|
26
|
+
var examplebucket = new S3Bucket(this, "examplebucket", new S3BucketConfig {
|
|
27
|
+
Acl = "private",
|
|
28
|
+
Bucket = "examplebuckettftest"
|
|
29
|
+
});
|
|
30
|
+
new S3BucketObject(this, "examplebucket_object", new S3BucketObjectConfig {
|
|
31
|
+
Bucket = examplebucket.Bucket,
|
|
32
|
+
Key = "someobject",
|
|
33
|
+
KmsKeyId = examplekms.Arn,
|
|
34
|
+
Source = "index.html"
|
|
35
|
+
});
|
|
36
|
+
new SecurityGroup(this, "allow_tls", new SecurityGroupConfig {
|
|
37
|
+
Description = "Allow TLS inbound traffic",
|
|
38
|
+
Egress = new [] { new SecurityGroupEgress {
|
|
39
|
+
CidrBlocks = new [] { "0.0.0.0/0" },
|
|
40
|
+
FromPort = 0,
|
|
41
|
+
Ipv6CidrBlocks = new [] { "::/0" },
|
|
42
|
+
Protocol = "-1",
|
|
43
|
+
ToPort = 0
|
|
44
|
+
} },
|
|
45
|
+
Ingress = new [] { new SecurityGroupIngress {
|
|
46
|
+
Description = "TLS from VPC",
|
|
47
|
+
FromPort = 443,
|
|
48
|
+
Protocol = "tcp",
|
|
49
|
+
ToPort = 443
|
|
50
|
+
}, new SecurityGroupIngress {
|
|
51
|
+
Description = "TLS from VPC",
|
|
52
|
+
FromPort = 80,
|
|
53
|
+
Protocol = "tcp",
|
|
54
|
+
ToPort = 80
|
|
55
|
+
}, new SecurityGroupIngress {
|
|
56
|
+
FromPort = 8080,
|
|
57
|
+
Protocol = "tcp",
|
|
58
|
+
ToPort = 8080
|
|
59
|
+
} },
|
|
60
|
+
Name = "allow_tls",
|
|
61
|
+
Tags = new Dictionary<string, string> {
|
|
62
|
+
{ "Name", "allow_tls" }
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}"
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
exports[`JSII Language Support complex aws example snapshot go 1`] = `
|
|
70
|
+
"import "github.com/aws/constructs-go/constructs"
|
|
71
|
+
import "github.com/open-constructs/cdk-terrain-go/cdktn"
|
|
72
|
+
/*
|
|
73
|
+
* Provider bindings are generated by running \`cdktn get\`.
|
|
74
|
+
* See https://cdktn.io/docs/concepts/providers#import-providers for more details.
|
|
75
|
+
*/
|
|
76
|
+
import "cdk.tf/go/stack/generated/aws/kmskey"
|
|
77
|
+
import "cdk.tf/go/stack/generated/aws/provider"
|
|
78
|
+
import "cdk.tf/go/stack/generated/aws/s3bucket"
|
|
79
|
+
import "cdk.tf/go/stack/generated/aws/s3bucketobject"
|
|
80
|
+
import "cdk.tf/go/stack/generated/aws/securitygroup"
|
|
81
|
+
type myConvertedCode struct {
|
|
82
|
+
TerraformStack
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func newMyConvertedCode(scope Construct, name *string) *myConvertedCode {
|
|
86
|
+
this := &myConvertedCode{}
|
|
87
|
+
newTerraformStack_Override(this, scope, name)
|
|
88
|
+
genprovidersawsprovider.NewAwsProvider(this, jsii.String("aws"), &AwsProviderConfig{
|
|
89
|
+
region: jsii.String("us-east-1"),
|
|
90
|
+
})
|
|
91
|
+
examplekms := genprovidersawskmskey.NewKmsKey(this, jsii.String("examplekms"), &KmsKeyConfig{
|
|
92
|
+
deletionWindowInDays: jsii.Number(7),
|
|
93
|
+
description: jsii.String("KMS key 1"),
|
|
94
|
+
})
|
|
95
|
+
examplebucket := genprovidersawss3bucket.NewS3Bucket(this, jsii.String("examplebucket"), &S3BucketConfig{
|
|
96
|
+
acl: jsii.String("private"),
|
|
97
|
+
bucket: jsii.String("examplebuckettftest"),
|
|
98
|
+
})
|
|
99
|
+
genprovidersawss3bucketobject.NewS3BucketObject(this, jsii.String("examplebucket_object"), &S3BucketObjectConfig{
|
|
100
|
+
bucket: examplebucket.bucket,
|
|
101
|
+
key: jsii.String("someobject"),
|
|
102
|
+
kmsKeyId: examplekms.arn,
|
|
103
|
+
source: jsii.String("index.html"),
|
|
104
|
+
})
|
|
105
|
+
genprovidersawssecuritygroup.NewSecurityGroup(this, jsii.String("allow_tls"), &SecurityGroupConfig{
|
|
106
|
+
description: jsii.String("Allow TLS inbound traffic"),
|
|
107
|
+
egress: []interface{}{
|
|
108
|
+
&SecurityGroupEgress{
|
|
109
|
+
cidrBlocks: []*string{
|
|
110
|
+
jsii.String("0.0.0.0/0"),
|
|
111
|
+
},
|
|
112
|
+
fromPort: jsii.Number(0),
|
|
113
|
+
ipv6CidrBlocks: []*string{
|
|
114
|
+
jsii.String("::/0"),
|
|
115
|
+
},
|
|
116
|
+
protocol: jsii.String("-1"),
|
|
117
|
+
toPort: jsii.Number(0),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
ingress: []interface{}{
|
|
121
|
+
&SecurityGroupIngress{
|
|
122
|
+
description: jsii.String("TLS from VPC"),
|
|
123
|
+
fromPort: jsii.Number(443),
|
|
124
|
+
protocol: jsii.String("tcp"),
|
|
125
|
+
toPort: jsii.Number(443),
|
|
126
|
+
},
|
|
127
|
+
&SecurityGroupIngress{
|
|
128
|
+
description: jsii.String("TLS from VPC"),
|
|
129
|
+
fromPort: jsii.Number(80),
|
|
130
|
+
protocol: jsii.String("tcp"),
|
|
131
|
+
toPort: jsii.Number(80),
|
|
132
|
+
},
|
|
133
|
+
&SecurityGroupIngress{
|
|
134
|
+
fromPort: jsii.Number(8080),
|
|
135
|
+
protocol: jsii.String("tcp"),
|
|
136
|
+
toPort: jsii.Number(8080),
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
name: jsii.String("allow_tls"),
|
|
140
|
+
tags: map[string]*string{
|
|
141
|
+
"Name": jsii.String("allow_tls"),
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
return this
|
|
145
|
+
}"
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`JSII Language Support complex aws example snapshot java 1`] = `
|
|
149
|
+
"import software.constructs.Construct;
|
|
150
|
+
import io.cdktn.cdktn.TerraformStack;
|
|
151
|
+
/*
|
|
152
|
+
* Provider bindings are generated by running \`cdktn get\`.
|
|
153
|
+
* See https://cdktn.io/docs/concepts/providers#import-providers for more details.
|
|
154
|
+
*/
|
|
155
|
+
import imports.aws.kms.key.KmsKey;
|
|
156
|
+
import imports.aws.provider.AwsProvider;
|
|
157
|
+
import imports.aws.s3.bucket.S3Bucket;
|
|
158
|
+
import imports.aws.s3.bucket.object.S3BucketObject;
|
|
159
|
+
import imports.aws.security.group.SecurityGroup;
|
|
160
|
+
public class MyConvertedCode extends TerraformStack {
|
|
161
|
+
public MyConvertedCode(Construct scope, String name) {
|
|
162
|
+
super(scope, name);
|
|
163
|
+
new AwsProvider(this, "aws", new AwsProviderConfig()
|
|
164
|
+
.region("us-east-1")
|
|
165
|
+
);
|
|
166
|
+
KmsKey examplekms = new KmsKey(this, "examplekms", new KmsKeyConfig()
|
|
167
|
+
.deletionWindowInDays(7)
|
|
168
|
+
.description("KMS key 1")
|
|
169
|
+
);
|
|
170
|
+
S3Bucket examplebucket = new S3Bucket(this, "examplebucket", new S3BucketConfig()
|
|
171
|
+
.acl("private")
|
|
172
|
+
.bucket("examplebuckettftest")
|
|
173
|
+
);
|
|
174
|
+
new S3BucketObject(this, "examplebucket_object", new S3BucketObjectConfig()
|
|
175
|
+
.bucket(examplebucket.getBucket())
|
|
176
|
+
.key("someobject")
|
|
177
|
+
.kmsKeyId(examplekms.getArn())
|
|
178
|
+
.source("index.html")
|
|
179
|
+
);
|
|
180
|
+
new SecurityGroup(this, "allow_tls", new SecurityGroupConfig()
|
|
181
|
+
.description("Allow TLS inbound traffic")
|
|
182
|
+
.egress(List.of(new SecurityGroupEgress()
|
|
183
|
+
.cidrBlocks(List.of("0.0.0.0/0"))
|
|
184
|
+
.fromPort(0)
|
|
185
|
+
.ipv6CidrBlocks(List.of("::/0"))
|
|
186
|
+
.protocol("-1")
|
|
187
|
+
.toPort(0)
|
|
188
|
+
))
|
|
189
|
+
.ingress(List.of(new SecurityGroupIngress()
|
|
190
|
+
.description("TLS from VPC")
|
|
191
|
+
.fromPort(443)
|
|
192
|
+
.protocol("tcp")
|
|
193
|
+
.toPort(443)
|
|
194
|
+
, new SecurityGroupIngress()
|
|
195
|
+
.description("TLS from VPC")
|
|
196
|
+
.fromPort(80)
|
|
197
|
+
.protocol("tcp")
|
|
198
|
+
.toPort(80)
|
|
199
|
+
, new SecurityGroupIngress()
|
|
200
|
+
.fromPort(8080)
|
|
201
|
+
.protocol("tcp")
|
|
202
|
+
.toPort(8080)
|
|
203
|
+
))
|
|
204
|
+
.name("allow_tls")
|
|
205
|
+
.tags(Map.of(
|
|
206
|
+
"Name", "allow_tls"))
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}"
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
exports[`JSII Language Support complex aws example snapshot python 1`] = `
|
|
213
|
+
"from constructs import Construct
|
|
214
|
+
from cdktn import TerraformStack
|
|
215
|
+
#
|
|
216
|
+
# Provider bindings are generated by running \`cdktn get\`.
|
|
217
|
+
# See https://cdktn.io/docs/concepts/providers#import-providers for more details.
|
|
218
|
+
#
|
|
219
|
+
from imports.aws.kms_key import KmsKey
|
|
220
|
+
from imports.aws.provider import AwsProvider
|
|
221
|
+
from imports.aws.s3_bucket import S3Bucket
|
|
222
|
+
from imports.aws.s3_bucket_object import S3BucketObject
|
|
223
|
+
from imports.aws.security_group import SecurityGroup
|
|
224
|
+
class MyConvertedCode(TerraformStack):
|
|
225
|
+
def __init__(self, scope, name):
|
|
226
|
+
super().__init__(scope, name)
|
|
227
|
+
AwsProvider(self, "aws",
|
|
228
|
+
region="us-east-1"
|
|
229
|
+
)
|
|
230
|
+
examplekms = KmsKey(self, "examplekms",
|
|
231
|
+
deletion_window_in_days=7,
|
|
232
|
+
description="KMS key 1"
|
|
233
|
+
)
|
|
234
|
+
examplebucket = S3Bucket(self, "examplebucket",
|
|
235
|
+
acl="private",
|
|
236
|
+
bucket="examplebuckettftest"
|
|
237
|
+
)
|
|
238
|
+
S3BucketObject(self, "examplebucket_object",
|
|
239
|
+
bucket=examplebucket.bucket,
|
|
240
|
+
key="someobject",
|
|
241
|
+
kms_key_id=examplekms.arn,
|
|
242
|
+
source="index.html"
|
|
243
|
+
)
|
|
244
|
+
SecurityGroup(self, "allow_tls",
|
|
245
|
+
description="Allow TLS inbound traffic",
|
|
246
|
+
egress=[SecurityGroupEgress(
|
|
247
|
+
cidr_blocks=["0.0.0.0/0"],
|
|
248
|
+
from_port=0,
|
|
249
|
+
ipv6_cidr_blocks=["::/0"],
|
|
250
|
+
protocol="-1",
|
|
251
|
+
to_port=0
|
|
252
|
+
)
|
|
253
|
+
],
|
|
254
|
+
ingress=[SecurityGroupIngress(
|
|
255
|
+
description="TLS from VPC",
|
|
256
|
+
from_port=443,
|
|
257
|
+
protocol="tcp",
|
|
258
|
+
to_port=443
|
|
259
|
+
), SecurityGroupIngress(
|
|
260
|
+
description="TLS from VPC",
|
|
261
|
+
from_port=80,
|
|
262
|
+
protocol="tcp",
|
|
263
|
+
to_port=80
|
|
264
|
+
), SecurityGroupIngress(
|
|
265
|
+
from_port=8080,
|
|
266
|
+
protocol="tcp",
|
|
267
|
+
to_port=8080
|
|
268
|
+
)
|
|
269
|
+
],
|
|
270
|
+
name="allow_tls",
|
|
271
|
+
tags={
|
|
272
|
+
"Name": "allow_tls"
|
|
273
|
+
}
|
|
274
|
+
)"
|
|
275
|
+
`;
|
|
276
|
+
|
|
277
|
+
exports[`JSII Language Support complex aws example snapshot typescript 1`] = `
|
|
278
|
+
"import { Construct } from "constructs";
|
|
279
|
+
import { TerraformStack } from "cdktn";
|
|
280
|
+
/*
|
|
281
|
+
* Provider bindings are generated by running \`cdktn get\`.
|
|
282
|
+
* See https://cdktn.io/docs/concepts/providers#import-providers for more details.
|
|
283
|
+
*/
|
|
284
|
+
import { KmsKey } from "./.gen/providers/aws/kms-key";
|
|
285
|
+
import { AwsProvider } from "./.gen/providers/aws/provider";
|
|
286
|
+
import { S3Bucket } from "./.gen/providers/aws/s3-bucket";
|
|
287
|
+
import { S3BucketObject } from "./.gen/providers/aws/s3-bucket-object";
|
|
288
|
+
import { SecurityGroup } from "./.gen/providers/aws/security-group";
|
|
289
|
+
class MyConvertedCode extends TerraformStack {
|
|
290
|
+
constructor(scope: Construct, name: string) {
|
|
291
|
+
super(scope, name);
|
|
292
|
+
new AwsProvider(this, "aws", {
|
|
293
|
+
region: "us-east-1",
|
|
294
|
+
});
|
|
295
|
+
const examplekms = new KmsKey(this, "examplekms", {
|
|
296
|
+
deletionWindowInDays: 7,
|
|
297
|
+
description: "KMS key 1",
|
|
298
|
+
});
|
|
299
|
+
const examplebucket = new S3Bucket(this, "examplebucket", {
|
|
300
|
+
acl: "private",
|
|
301
|
+
bucket: "examplebuckettftest",
|
|
302
|
+
});
|
|
303
|
+
new S3BucketObject(this, "examplebucket_object", {
|
|
304
|
+
bucket: examplebucket.bucket,
|
|
305
|
+
key: "someobject",
|
|
306
|
+
kmsKeyId: examplekms.arn,
|
|
307
|
+
source: "index.html",
|
|
308
|
+
});
|
|
309
|
+
new SecurityGroup(this, "allow_tls", {
|
|
310
|
+
description: "Allow TLS inbound traffic",
|
|
311
|
+
egress: [
|
|
312
|
+
{
|
|
313
|
+
cidrBlocks: ["0.0.0.0/0"],
|
|
314
|
+
fromPort: 0,
|
|
315
|
+
ipv6CidrBlocks: ["::/0"],
|
|
316
|
+
protocol: "-1",
|
|
317
|
+
toPort: 0,
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
ingress: [
|
|
321
|
+
{
|
|
322
|
+
description: "TLS from VPC",
|
|
323
|
+
fromPort: 443,
|
|
324
|
+
protocol: "tcp",
|
|
325
|
+
toPort: 443,
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
description: "TLS from VPC",
|
|
329
|
+
fromPort: 80,
|
|
330
|
+
protocol: "tcp",
|
|
331
|
+
toPort: 80,
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
fromPort: 8080,
|
|
335
|
+
protocol: "tcp",
|
|
336
|
+
toPort: 8080,
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
name: "allow_tls",
|
|
340
|
+
tags: {
|
|
341
|
+
Name: "allow_tls",
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
"
|
|
347
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`locals locals snapshot typescript 1`] = `
|
|
4
|
+
"import { Construct } from "constructs";
|
|
5
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
6
|
+
class MyConvertedCode extends TerraformStack {
|
|
7
|
+
constructor(scope: Construct, name: string) {
|
|
8
|
+
super(scope, name);
|
|
9
|
+
const howMany = 42;
|
|
10
|
+
const isItGreat = true;
|
|
11
|
+
const owner = "Community Team";
|
|
12
|
+
const serviceName = "forum";
|
|
13
|
+
new TerraformOutput(this, "combined-so-it-does-not-get-removed", {
|
|
14
|
+
value:
|
|
15
|
+
"\${" +
|
|
16
|
+
serviceName +
|
|
17
|
+
"},\${" +
|
|
18
|
+
owner +
|
|
19
|
+
"},\${" +
|
|
20
|
+
isItGreat +
|
|
21
|
+
"},\${" +
|
|
22
|
+
howMany +
|
|
23
|
+
"}",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
"
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`locals multiple locals blocks snapshot typescript 1`] = `
|
|
31
|
+
"import { Construct } from "constructs";
|
|
32
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
33
|
+
class MyConvertedCode extends TerraformStack {
|
|
34
|
+
constructor(scope: Construct, name: string) {
|
|
35
|
+
super(scope, name);
|
|
36
|
+
const owner = "Community Team";
|
|
37
|
+
const serviceName = "forum";
|
|
38
|
+
const howMany = 42;
|
|
39
|
+
const isItGreat = true;
|
|
40
|
+
new TerraformOutput(this, "combined-so-it-does-not-get-removed", {
|
|
41
|
+
value:
|
|
42
|
+
"\${" +
|
|
43
|
+
serviceName +
|
|
44
|
+
"},\${" +
|
|
45
|
+
owner +
|
|
46
|
+
"},\${" +
|
|
47
|
+
isItGreat +
|
|
48
|
+
"},\${" +
|
|
49
|
+
howMany +
|
|
50
|
+
"}",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
"
|
|
55
|
+
`;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`modules all module types snapshot typescript 1`] = `
|
|
4
|
+
"import { Construct } from "constructs";
|
|
5
|
+
import { TerraformStack } from "cdktn";
|
|
6
|
+
import * as Consul from "./.gen/modules/consul";
|
|
7
|
+
import * as TerraformConsulAws from "./.gen/modules/hashicorp/terraform-consul-aws";
|
|
8
|
+
import * as Example from "./.gen/modules/hashicorp/example";
|
|
9
|
+
import * as Example from "./.gen/modules/hashicorp/example";
|
|
10
|
+
import * as K8SCluster from "./.gen/modules/example-corp/azurerm/k8s-cluster";
|
|
11
|
+
import * as Consul from "./.gen/modules/hashicorp/aws/consul";
|
|
12
|
+
import * as Storage from "./.gen/modules/storage";
|
|
13
|
+
import * as Vpc from "./.gen/modules/vpc";
|
|
14
|
+
class MyConvertedCode extends TerraformStack {
|
|
15
|
+
constructor(scope: Construct, name: string) {
|
|
16
|
+
super(scope, name);
|
|
17
|
+
new Consul.Consul(this, "consul", {});
|
|
18
|
+
new TerraformConsulAws.TerraformConsulAws(this, "consul-butbucket", {});
|
|
19
|
+
new Example.Example(this, "consul-git", {});
|
|
20
|
+
new Example.Example(this, "consul-github", {});
|
|
21
|
+
new K8SCluster.K8SCluster(this, "consul-hosted-registry", {});
|
|
22
|
+
new Consul.Consul(this, "consul-registry", {});
|
|
23
|
+
new Storage.Storage(this, "storage", {});
|
|
24
|
+
new Vpc.Vpc(this, "vpc", {});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
"
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`modules duplicate modules snapshot typescript 1`] = `
|
|
31
|
+
"import { Construct } from "constructs";
|
|
32
|
+
import { TerraformStack } from "cdktn";
|
|
33
|
+
import * as Vpc from "./.gen/modules/terraform-aws-modules/aws/vpc";
|
|
34
|
+
class MyConvertedCode extends TerraformStack {
|
|
35
|
+
constructor(scope: Construct, name: string) {
|
|
36
|
+
super(scope, name);
|
|
37
|
+
new Vpc.Vpc(this, "vpca", {
|
|
38
|
+
name: "my-vpc-a",
|
|
39
|
+
});
|
|
40
|
+
new Vpc.Vpc(this, "vpcb", {
|
|
41
|
+
name: "my-vpc-b",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
"
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
exports[`modules local module snapshot typescript 1`] = `
|
|
49
|
+
"import { Construct } from "constructs";
|
|
50
|
+
import { TerraformStack } from "cdktn";
|
|
51
|
+
import * as AwsVpc from "./.gen/modules/aws_vpc";
|
|
52
|
+
class MyConvertedCode extends TerraformStack {
|
|
53
|
+
constructor(scope: Construct, name: string) {
|
|
54
|
+
super(scope, name);
|
|
55
|
+
new AwsVpc.AwsVpc(this, "aws_vpc", {});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
"
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
exports[`modules modules snapshot typescript 1`] = `
|
|
62
|
+
"import { Construct } from "constructs";
|
|
63
|
+
import { TerraformStack } from "cdktn";
|
|
64
|
+
import * as Vpc from "./.gen/modules/terraform-aws-modules/aws/vpc";
|
|
65
|
+
class MyConvertedCode extends TerraformStack {
|
|
66
|
+
constructor(scope: Construct, name: string) {
|
|
67
|
+
super(scope, name);
|
|
68
|
+
new Vpc.Vpc(this, "vpc", {
|
|
69
|
+
azs: ["eu-west-1a", "eu-west-1b", "eu-west-1c"],
|
|
70
|
+
cidr: "10.0.0.0/16",
|
|
71
|
+
enableNatGateway: true,
|
|
72
|
+
enableVpnGateway: true,
|
|
73
|
+
name: "my-vpc",
|
|
74
|
+
privateSubnets: ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"],
|
|
75
|
+
publicSubnets: ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"],
|
|
76
|
+
tags: {
|
|
77
|
+
Environment: "dev",
|
|
78
|
+
Terraform: "true",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
"
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`modules referenced modules snapshot typescript 1`] = `
|
|
87
|
+
"import { Construct } from "constructs";
|
|
88
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
89
|
+
import * as Vpc from "./.gen/modules/terraform-aws-modules/aws/vpc";
|
|
90
|
+
class MyConvertedCode extends TerraformStack {
|
|
91
|
+
constructor(scope: Construct, name: string) {
|
|
92
|
+
super(scope, name);
|
|
93
|
+
const vpc = new Vpc.Vpc(this, "vpc", {
|
|
94
|
+
azs: ["eu-west-1a", "eu-west-1b", "eu-west-1c"],
|
|
95
|
+
cidr: "10.0.0.0/16",
|
|
96
|
+
enableNatGateway: true,
|
|
97
|
+
enableVpnGateway: true,
|
|
98
|
+
name: "my-vpc",
|
|
99
|
+
privateSubnets: ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"],
|
|
100
|
+
publicSubnets: ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"],
|
|
101
|
+
tags: {
|
|
102
|
+
Environment: "dev",
|
|
103
|
+
Terraform: "true",
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
new TerraformOutput(this, "subnet_ids", {
|
|
107
|
+
value: vpc.publicSubnetsOutput,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
"
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
exports[`modules terraform workspace snapshot typescript 1`] = `
|
|
115
|
+
"import { Construct } from "constructs";
|
|
116
|
+
import { TerraformStack } from "cdktn";
|
|
117
|
+
import * as MyModule from "./.gen/modules/my-module";
|
|
118
|
+
class MyConvertedCode extends TerraformStack {
|
|
119
|
+
constructor(scope: Construct, name: string) {
|
|
120
|
+
super(scope, name);
|
|
121
|
+
new MyModule.MyModule(this, "example", {
|
|
122
|
+
namePrefix: "app-\${terraform.workspace}",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
"
|
|
127
|
+
`;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`outputs multiple outputs snapshot typescript 1`] = `
|
|
4
|
+
"import { Construct } from "constructs";
|
|
5
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
6
|
+
class MyConvertedCode extends TerraformStack {
|
|
7
|
+
constructor(scope: Construct, name: string) {
|
|
8
|
+
super(scope, name);
|
|
9
|
+
new TerraformOutput(this, "first_cidr_out", {
|
|
10
|
+
value: "first",
|
|
11
|
+
});
|
|
12
|
+
new TerraformOutput(this, "second_cidr_out", {
|
|
13
|
+
value: "second",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
"
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`outputs number output snapshot typescript 1`] = `
|
|
21
|
+
"import { Construct } from "constructs";
|
|
22
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
23
|
+
class MyConvertedCode extends TerraformStack {
|
|
24
|
+
constructor(scope: Construct, name: string) {
|
|
25
|
+
super(scope, name);
|
|
26
|
+
new TerraformOutput(this, "test", {
|
|
27
|
+
value: 42,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
"
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
exports[`outputs output snapshot typescript 1`] = `
|
|
35
|
+
"import { Construct } from "constructs";
|
|
36
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
37
|
+
class MyConvertedCode extends TerraformStack {
|
|
38
|
+
constructor(scope: Construct, name: string) {
|
|
39
|
+
super(scope, name);
|
|
40
|
+
new TerraformOutput(this, "cidr_out", {
|
|
41
|
+
value: "test",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
"
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
exports[`outputs output withdescription snapshot typescript 1`] = `
|
|
49
|
+
"import { Construct } from "constructs";
|
|
50
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
51
|
+
class MyConvertedCode extends TerraformStack {
|
|
52
|
+
constructor(scope: Construct, name: string) {
|
|
53
|
+
super(scope, name);
|
|
54
|
+
new TerraformOutput(this, "cidr_out", {
|
|
55
|
+
value: "test",
|
|
56
|
+
description: "Best output",
|
|
57
|
+
sensitive: true,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
"
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
exports[`outputs sensitive output snapshot typescript 1`] = `
|
|
65
|
+
"import { Construct } from "constructs";
|
|
66
|
+
import { TerraformOutput, TerraformStack } from "cdktn";
|
|
67
|
+
class MyConvertedCode extends TerraformStack {
|
|
68
|
+
constructor(scope: Construct, name: string) {
|
|
69
|
+
super(scope, name);
|
|
70
|
+
new TerraformOutput(this, "cidr_out", {
|
|
71
|
+
value: "test",
|
|
72
|
+
sensitive: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
"
|
|
77
|
+
`;
|