@cdktn/hcl2cdk 0.26.0-pre.3 → 0.26.0-pre.30

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.
Files changed (94) hide show
  1. package/build/expressions.js +3 -5
  2. package/build/index.js +3 -3
  3. package/package.json +8 -7
  4. package/.spec.swcrc +0 -22
  5. package/build/__tests__/coerceType.test.d.ts +0 -2
  6. package/build/__tests__/coerceType.test.js +0 -165
  7. package/build/__tests__/expressionToTs.test.d.ts +0 -6
  8. package/build/__tests__/expressionToTs.test.js +0 -693
  9. package/build/__tests__/expressions.test.d.ts +0 -4
  10. package/build/__tests__/expressions.test.js +0 -424
  11. package/build/__tests__/findExpressionType.test.d.ts +0 -6
  12. package/build/__tests__/findExpressionType.test.js +0 -105
  13. package/build/__tests__/functions.test.d.ts +0 -6
  14. package/build/__tests__/functions.test.js +0 -615
  15. package/build/__tests__/generation.test.d.ts +0 -6
  16. package/build/__tests__/generation.test.js +0 -45
  17. package/build/__tests__/jsii-rosetta-workarounds.test.d.ts +0 -2
  18. package/build/__tests__/jsii-rosetta-workarounds.test.js +0 -86
  19. package/build/__tests__/partialCode.test.d.ts +0 -6
  20. package/build/__tests__/partialCode.test.js +0 -390
  21. package/build/__tests__/terraformSchema.test.d.ts +0 -6
  22. package/build/__tests__/terraformSchema.test.js +0 -105
  23. package/build/__tests__/testHelpers.d.ts +0 -7
  24. package/build/__tests__/testHelpers.js +0 -15
  25. package/jest.config.js +0 -25
  26. package/package.sh +0 -9
  27. package/src/__tests__/coerceType.test.ts +0 -207
  28. package/src/__tests__/expressionToTs.test.ts +0 -1167
  29. package/src/__tests__/expressions.test.ts +0 -541
  30. package/src/__tests__/findExpressionType.test.ts +0 -112
  31. package/src/__tests__/functions.test.ts +0 -764
  32. package/src/__tests__/generation.test.ts +0 -72
  33. package/src/__tests__/jsii-rosetta-workarounds.test.ts +0 -145
  34. package/src/__tests__/partialCode.test.ts +0 -432
  35. package/src/__tests__/terraformSchema.test.ts +0 -107
  36. package/src/__tests__/testHelpers.ts +0 -11
  37. package/src/coerceType.ts +0 -261
  38. package/src/dynamic-blocks.ts +0 -61
  39. package/src/expressions.ts +0 -968
  40. package/src/function-bindings/functions.generated.ts +0 -1211
  41. package/src/function-bindings/functions.ts +0 -104
  42. package/src/generation.ts +0 -1189
  43. package/src/index.ts +0 -584
  44. package/src/iteration.ts +0 -156
  45. package/src/jsii-rosetta-workarounds.ts +0 -145
  46. package/src/partialCode.ts +0 -132
  47. package/src/provider.ts +0 -60
  48. package/src/references.ts +0 -193
  49. package/src/schema.ts +0 -74
  50. package/src/terraformSchema.ts +0 -182
  51. package/src/types.ts +0 -58
  52. package/src/utils.ts +0 -19
  53. package/src/variables.ts +0 -214
  54. package/test/__snapshots__/backends.test.ts.snap +0 -70
  55. package/test/__snapshots__/externals.test.ts.snap +0 -37
  56. package/test/__snapshots__/granular-imports.test.ts.snap +0 -180
  57. package/test/__snapshots__/imports.test.ts.snap +0 -159
  58. package/test/__snapshots__/iteration.test.ts.snap +0 -532
  59. package/test/__snapshots__/jsiiLanguage.test.ts.snap +0 -347
  60. package/test/__snapshots__/locals.test.ts.snap +0 -55
  61. package/test/__snapshots__/modules.test.ts.snap +0 -127
  62. package/test/__snapshots__/outputs.test.ts.snap +0 -77
  63. package/test/__snapshots__/partialCode.test.ts.snap +0 -120
  64. package/test/__snapshots__/provider.test.ts.snap +0 -128
  65. package/test/__snapshots__/references.test.ts.snap +0 -376
  66. package/test/__snapshots__/resource-meta-properties.test.ts.snap +0 -342
  67. package/test/__snapshots__/resources.test.ts.snap +0 -613
  68. package/test/__snapshots__/tfExpressions.test.ts.snap +0 -537
  69. package/test/__snapshots__/typeCoercion.test.ts.snap +0 -253
  70. package/test/__snapshots__/variables.test.ts.snap +0 -150
  71. package/test/backends.test.ts +0 -75
  72. package/test/convertProject.test.ts +0 -262
  73. package/test/externals.test.ts +0 -35
  74. package/test/globalSetup.ts +0 -224
  75. package/test/globalTeardown.ts +0 -11
  76. package/test/granular-imports.test.ts +0 -161
  77. package/test/hcl2cdk.test.ts +0 -88
  78. package/test/helpers/convert.ts +0 -544
  79. package/test/helpers/tmp.ts +0 -40
  80. package/test/imports.test.ts +0 -141
  81. package/test/iteration.test.ts +0 -342
  82. package/test/jsiiLanguage.test.ts +0 -73
  83. package/test/locals.test.ts +0 -47
  84. package/test/modules.test.ts +0 -143
  85. package/test/outputs.test.ts +0 -69
  86. package/test/partialCode.test.ts +0 -25
  87. package/test/provider.test.ts +0 -106
  88. package/test/references.test.ts +0 -287
  89. package/test/resource-meta-properties.test.ts +0 -288
  90. package/test/resources.test.ts +0 -551
  91. package/test/tfExpressions.test.ts +0 -300
  92. package/test/typeCoercion.test.ts +0 -154
  93. package/test/variables.test.ts +0 -96
  94. package/tsconfig.json +0 -47
@@ -1,613 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`resources access use fqn for data source snapshot typescript 1`] = `
4
- "import { Construct } from "constructs";
5
- import { Fn, Token, TerraformStack } from "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
- import { DataAwsAvailabilityZones } from "./.gen/providers/aws/data-aws-availability-zones";
11
- import { EbsVolume } from "./.gen/providers/aws/ebs-volume";
12
- import { AwsProvider } from "./.gen/providers/aws/provider";
13
- class MyConvertedCode extends TerraformStack {
14
- constructor(scope: Construct, name: string) {
15
- super(scope, name);
16
- new AwsProvider(this, "aws", {
17
- region: "us-east-1",
18
- });
19
- const changemeAzListEbsSnapshot = new DataAwsAvailabilityZones(
20
- this,
21
- "changeme_az_list_ebs_snapshot",
22
- {
23
- state: "available",
24
- }
25
- );
26
- new EbsVolume(this, "changeme_ebs_volume_snapshot", {
27
- availabilityZone: Token.asString(
28
- Fn.lookupNested(changemeAzListEbsSnapshot.names, ["0"])
29
- ),
30
- encrypted: false,
31
- size: 10,
32
- tags: {
33
- Name: "changeme_ebs_volume_tag",
34
- },
35
- type: "standard",
36
- });
37
- }
38
- }
39
- "
40
- `;
41
-
42
- exports[`resources blocks should be arrays snapshot typescript 1`] = `
43
- "import { Construct } from "constructs";
44
- import { TerraformStack } from "cdktn";
45
- /*
46
- * Provider bindings are generated by running \`cdktn get\`.
47
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
48
- */
49
- import { ComputeAutoscaler } from "./.gen/providers/google/compute-autoscaler";
50
- import { GoogleProvider } from "./.gen/providers/google/provider";
51
- class MyConvertedCode extends TerraformStack {
52
- constructor(scope: Construct, name: string) {
53
- super(scope, name);
54
- new GoogleProvider(this, "google", {
55
- project: "my-project",
56
- region: "us-central1",
57
- });
58
- new ComputeAutoscaler(this, "example", {
59
- autoscalingPolicy: {
60
- cooldownPeriod: 60,
61
- cpuUtilization: {
62
- target: 0.5,
63
- },
64
- maxReplicas: 8,
65
- minReplicas: 2,
66
- },
67
- name: "example-autoscaler",
68
- target: "target-for-example-autoscaler",
69
- zone: "us-east1-b",
70
- });
71
- }
72
- }
73
- "
74
- `;
75
-
76
- exports[`resources built-in data resource snapshot typescript 1`] = `
77
- "import { Construct } from "constructs";
78
- import { TerraformVariable, DataResource, TerraformStack } from "cdktn";
79
- class MyConvertedCode extends TerraformStack {
80
- constructor(scope: Construct, name: string) {
81
- super(scope, name);
82
- /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
83
- You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
84
- const revision = new TerraformVariable(this, "revision", {
85
- default: 1,
86
- });
87
- new DataResource(this, "replacement", {
88
- input: revision.value,
89
- });
90
- }
91
- }
92
- "
93
- `;
94
-
95
- exports[`resources complex resource snapshot typescript 1`] = `
96
- "import { Construct } from "constructs";
97
- import { TerraformStack } from "cdktn";
98
- /*
99
- * Provider bindings are generated by running \`cdktn get\`.
100
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
101
- */
102
- import { CloudfrontDistribution } from "./.gen/providers/aws/cloudfront-distribution";
103
- import { AwsProvider } from "./.gen/providers/aws/provider";
104
- class MyConvertedCode extends TerraformStack {
105
- constructor(scope: Construct, name: string) {
106
- super(scope, name);
107
- new AwsProvider(this, "aws", {
108
- region: "us-east-1",
109
- });
110
- new CloudfrontDistribution(this, "s3_distribution", {
111
- aliases: ["mysite.example.com", "yoursite.example.com"],
112
- comment: "Some comment",
113
- defaultCacheBehavior: {
114
- allowedMethods: [
115
- "DELETE",
116
- "GET",
117
- "HEAD",
118
- "OPTIONS",
119
- "PATCH",
120
- "POST",
121
- "PUT",
122
- ],
123
- cachedMethods: ["GET", "HEAD"],
124
- defaultTtl: 3600,
125
- forwardedValues: {
126
- cookies: {
127
- forward: "none",
128
- },
129
- queryString: false,
130
- },
131
- maxTtl: 86400,
132
- minTtl: 0,
133
- targetOriginId: "local_s3_origin_id",
134
- viewerProtocolPolicy: "allow-all",
135
- },
136
- defaultRootObject: "index.html",
137
- enabled: true,
138
- isIpv6Enabled: true,
139
- loggingConfig: {
140
- bucket: "mylogs.s3.amazonaws.com",
141
- includeCookies: false,
142
- prefix: "myprefix",
143
- },
144
- orderedCacheBehavior: [
145
- {
146
- allowedMethods: ["GET", "HEAD", "OPTIONS"],
147
- cachedMethods: ["GET", "HEAD", "OPTIONS"],
148
- compress: true,
149
- defaultTtl: 86400,
150
- forwardedValues: {
151
- cookies: {
152
- forward: "none",
153
- },
154
- headers: ["Origin"],
155
- queryString: false,
156
- },
157
- maxTtl: 31536000,
158
- minTtl: 0,
159
- pathPattern: "/content/immutable/*",
160
- targetOriginId: "local_s3_origin_id",
161
- viewerProtocolPolicy: "redirect-to-https",
162
- },
163
- {
164
- allowedMethods: ["GET", "HEAD", "OPTIONS"],
165
- cachedMethods: ["GET", "HEAD"],
166
- compress: true,
167
- defaultTtl: 3600,
168
- forwardedValues: {
169
- cookies: {
170
- forward: "none",
171
- },
172
- queryString: false,
173
- },
174
- maxTtl: 86400,
175
- minTtl: 0,
176
- pathPattern: "/content/*",
177
- targetOriginId: "local_s3_origin_id",
178
- viewerProtocolPolicy: "redirect-to-https",
179
- },
180
- ],
181
- origin: [
182
- {
183
- domainName: "aws_s3_bucket.b.bucket_regional_domain_name",
184
- originId: "local_s3_origin_id",
185
- s3OriginConfig: {
186
- originAccessIdentity:
187
- "origin-access-identity/cloudfront/ABCDEFG1234567",
188
- },
189
- },
190
- ],
191
- priceClass: "PriceClass_200",
192
- restrictions: {
193
- geoRestriction: {
194
- locations: ["US", "CA", "GB", "DE"],
195
- restrictionType: "whitelist",
196
- },
197
- },
198
- tags: {
199
- Environment: "production",
200
- },
201
- viewerCertificate: {
202
- cloudfrontDefaultCertificate: true,
203
- },
204
- });
205
- }
206
- }
207
- "
208
- `;
209
-
210
- exports[`resources handle special resource names snapshot typescript 1`] = `
211
- "import { Construct } from "constructs";
212
- import { Fn, Token, TerraformStack } from "cdktn";
213
- /*
214
- * Provider bindings are generated by running \`cdktn get\`.
215
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
216
- */
217
- import { ObjectBucket } from "./.gen/providers/scaleway/object-bucket";
218
- import { ObjectResource } from "./.gen/providers/scaleway/object-resource";
219
- import { ScalewayProvider } from "./.gen/providers/scaleway/provider";
220
- class MyConvertedCode extends TerraformStack {
221
- constructor(scope: Construct, name: string) {
222
- super(scope, name);
223
- new ScalewayProvider(this, "scaleway", {
224
- region: "fr-par",
225
- zone: "fr-par-1",
226
- });
227
- const someBucket = new ObjectBucket(this, "some_bucket", {
228
- name: "some-unique-name",
229
- });
230
- new ObjectResource(this, "some_file", {
231
- bucket: someBucket.name,
232
- file: "myfile",
233
- hash: Token.asString(Fn.filemd5("myfile")),
234
- key: "object_path",
235
- });
236
- }
237
- }
238
- "
239
- `;
240
-
241
- exports[`resources handles JSON encoded blocks snapshot typescript 1`] = `
242
- "import { Construct } from "constructs";
243
- import { Token, Fn, TerraformStack } from "cdktn";
244
- /*
245
- * Provider bindings are generated by running \`cdktn get\`.
246
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
247
- */
248
- import { EcsTaskDefinition } from "./.gen/providers/aws/ecs-task-definition";
249
- import { AwsProvider } from "./.gen/providers/aws/provider";
250
- class MyConvertedCode extends TerraformStack {
251
- constructor(scope: Construct, name: string) {
252
- super(scope, name);
253
- new AwsProvider(this, "aws", {
254
- region: "us-east-1",
255
- });
256
- new EcsTaskDefinition(this, "client", {
257
- containerDefinitions: Token.asString(
258
- Fn.jsonencode([
259
- {
260
- cpu: 0,
261
- environment: [
262
- {
263
- name: "NAME",
264
- value: "client",
265
- },
266
- {
267
- name: "MESSAGE",
268
- value: "Hello from the client!",
269
- },
270
- ],
271
- essential: true,
272
- image: "crccheck/hello-world",
273
- name: "client",
274
- portMappings: [
275
- {
276
- containerPort: 8000,
277
- hostPort: 8000,
278
- protocol: "tcp",
279
- },
280
- ],
281
- },
282
- ])
283
- ),
284
- cpu: Token.asString(256),
285
- family: "client",
286
- memory: Token.asString(512),
287
- networkMode: "awsvpc",
288
- requiresCompatibilities: ["FARGATE"],
289
- });
290
- }
291
- }
292
- "
293
- `;
294
-
295
- exports[`resources handles special resource names without schema snapshot typescript 1`] = `
296
- "import { Construct } from "constructs";
297
- import { Fn, TerraformStack } from "cdktn";
298
- /*
299
- * Provider bindings are generated by running \`cdktn get\`.
300
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
301
- */
302
- import { ObjectBucket } from "./.gen/providers/scaleway/object-bucket";
303
- import { ObjectResource } from "./.gen/providers/scaleway/object-resource";
304
- import { ScalewayProvider } from "./.gen/providers/scaleway/provider";
305
- class MyConvertedCode extends TerraformStack {
306
- constructor(scope: Construct, name: string) {
307
- super(scope, name);
308
- /*The following providers are missing schema information and might need manual adjustments to synthesize correctly: scaleway.
309
- For a more precise conversion please use the --provider flag in convert.*/
310
- new ScalewayProvider(this, "scaleway", {
311
- region: "fr-par",
312
- zone: "fr-par-1",
313
- });
314
- const someBucket = new ObjectBucket(this, "some_bucket", {
315
- name: "some-unique-name",
316
- });
317
- new ObjectResource(this, "some_file", {
318
- bucket: someBucket.name,
319
- file: "myfile",
320
- hash: Fn.filemd5("myfile"),
321
- key: "object_path",
322
- });
323
- }
324
- }
325
- "
326
- `;
327
-
328
- exports[`resources maps are not arrays snapshot typescript 1`] = `
329
- "import { Construct } from "constructs";
330
- import { TerraformStack } from "cdktn";
331
- /*
332
- * Provider bindings are generated by running \`cdktn get\`.
333
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
334
- */
335
- import { KubernetesProvider } from "./.gen/providers/kubernetes/provider";
336
- import { Secret } from "./.gen/providers/kubernetes/secret";
337
- class MyConvertedCode extends TerraformStack {
338
- constructor(scope: Construct, name: string) {
339
- super(scope, name);
340
- new KubernetesProvider(this, "kubernetes", {
341
- configContext: "my-context",
342
- configPath: "~/.kube/config",
343
- });
344
- new Secret(this, "secrets-xxx", {
345
- data: {
346
- xxx: "yyy",
347
- },
348
- metadata: {
349
- name: "secrets-xxx",
350
- },
351
- });
352
- }
353
- }
354
- "
355
- `;
356
-
357
- exports[`resources maps dont get camel case keys snapshot typescript 1`] = `
358
- "import { Construct } from "constructs";
359
- import { TerraformStack } from "cdktn";
360
- /*
361
- * Provider bindings are generated by running \`cdktn get\`.
362
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
363
- */
364
- import { KubernetesProvider } from "./.gen/providers/kubernetes/provider";
365
- import { Secret } from "./.gen/providers/kubernetes/secret";
366
- class MyConvertedCode extends TerraformStack {
367
- constructor(scope: Construct, name: string) {
368
- super(scope, name);
369
- new KubernetesProvider(this, "kubernetes", {
370
- configContext: "my-context",
371
- configPath: "~/.kube/config",
372
- });
373
- new Secret(this, "secrets-xxx", {
374
- data: {
375
- camel_cased_key: "yes",
376
- },
377
- metadata: {
378
- name: "secrets-xxx",
379
- },
380
- });
381
- }
382
- }
383
- "
384
- `;
385
-
386
- exports[`resources multiple blocks snapshot typescript 1`] = `
387
- "import { Construct } from "constructs";
388
- import { TerraformStack } from "cdktn";
389
- /*
390
- * Provider bindings are generated by running \`cdktn get\`.
391
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
392
- */
393
- import { AwsProvider } from "./.gen/providers/aws/provider";
394
- import { SecurityGroup } from "./.gen/providers/aws/security-group";
395
- class MyConvertedCode extends TerraformStack {
396
- constructor(scope: Construct, name: string) {
397
- super(scope, name);
398
- new AwsProvider(this, "aws", {
399
- region: "us-east-1",
400
- });
401
- new SecurityGroup(this, "allow_tls", {
402
- description: "Allow TLS inbound traffic",
403
- egress: [
404
- {
405
- cidrBlocks: ["0.0.0.0/0"],
406
- fromPort: 0,
407
- ipv6CidrBlocks: ["::/0"],
408
- protocol: "-1",
409
- toPort: 0,
410
- },
411
- ],
412
- ingress: [
413
- {
414
- description: "TLS from VPC",
415
- fromPort: 443,
416
- protocol: "tcp",
417
- toPort: 443,
418
- },
419
- {
420
- description: "TLS from VPC",
421
- fromPort: 80,
422
- protocol: "tcp",
423
- toPort: 80,
424
- },
425
- {
426
- fromPort: 8080,
427
- protocol: "tcp",
428
- toPort: 8080,
429
- },
430
- ],
431
- name: "allow_tls",
432
- tags: {
433
- Name: "allow_tls",
434
- },
435
- });
436
- }
437
- }
438
- "
439
- `;
440
-
441
- exports[`resources property level renamings snapshot typescript 1`] = `
442
- "import { Construct } from "constructs";
443
- import { TerraformStack } from "cdktn";
444
- /*
445
- * Provider bindings are generated by running \`cdktn get\`.
446
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
447
- */
448
- import { GuarddutyFilter } from "./.gen/providers/aws/guardduty-filter";
449
- import { AwsProvider } from "./.gen/providers/aws/provider";
450
- class MyConvertedCode extends TerraformStack {
451
- constructor(scope: Construct, name: string) {
452
- super(scope, name);
453
- new AwsProvider(this, "aws", {
454
- region: "us-east-1",
455
- });
456
- new GuarddutyFilter(this, "MyFilter", {
457
- action: "ARCHIVE",
458
- detectorId: "id",
459
- findingCriteria: {
460
- criterion: [
461
- {
462
- equalTo: ["eu-west-1"],
463
- field: "region",
464
- },
465
- {
466
- field: "service.additionalInfo.threatListName",
467
- notEquals: ["some-threat", "another-threat"],
468
- },
469
- {
470
- field: "updatedAt",
471
- greaterThan: "2020-01-01T00:00:00Z",
472
- lessThan: "2020-02-01T00:00:00Z",
473
- },
474
- {
475
- field: "severity",
476
- greaterThanOrEqual: "4",
477
- },
478
- ],
479
- },
480
- name: "MyFilter",
481
- rank: 1,
482
- });
483
- }
484
- }
485
- "
486
- `;
487
-
488
- exports[`resources same name local, var, out snapshot typescript 1`] = `
489
- "import { Construct } from "constructs";
490
- import {
491
- VariableType,
492
- TerraformVariable,
493
- TerraformOutput,
494
- TerraformStack,
495
- } from "cdktn";
496
- class MyConvertedCode extends TerraformStack {
497
- constructor(scope: Construct, name: string) {
498
- super(scope, name);
499
- /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
500
- You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
501
- const test = new TerraformVariable(this, "test", {
502
- type: VariableType.STRING,
503
- });
504
- const localTest = "\${" + test.value + "} + 1";
505
- const cdktnTerraformOutputTest = new TerraformOutput(this, "test_1", {
506
- value: localTest,
507
- });
508
- /*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
509
- cdktnTerraformOutputTest.overrideLogicalId("test");
510
- }
511
- }
512
- "
513
- `;
514
-
515
- exports[`resources simple data source snapshot typescript 1`] = `
516
- "import { Construct } from "constructs";
517
- import { TerraformStack } from "cdktn";
518
- /*
519
- * Provider bindings are generated by running \`cdktn get\`.
520
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
521
- */
522
- import { DataAwsSubnet } from "./.gen/providers/aws/data-aws-subnet";
523
- import { AwsProvider } from "./.gen/providers/aws/provider";
524
- class MyConvertedCode extends TerraformStack {
525
- constructor(scope: Construct, name: string) {
526
- super(scope, name);
527
- new AwsProvider(this, "aws", {
528
- region: "us-east-1",
529
- });
530
- new DataAwsSubnet(this, "selected", {
531
- vpcId: "subnet_id",
532
- });
533
- }
534
- }
535
- "
536
- `;
537
-
538
- exports[`resources simple resource snapshot typescript 1`] = `
539
- "import { Construct } from "constructs";
540
- import { TerraformStack } from "cdktn";
541
- /*
542
- * Provider bindings are generated by running \`cdktn get\`.
543
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
544
- */
545
- import { AwsProvider } from "./.gen/providers/aws/provider";
546
- import { Vpc } from "./.gen/providers/aws/vpc";
547
- class MyConvertedCode extends TerraformStack {
548
- constructor(scope: Construct, name: string) {
549
- super(scope, name);
550
- new AwsProvider(this, "aws", {
551
- region: "us-east-1",
552
- });
553
- new Vpc(this, "example", {
554
- cidrBlock: "10.0.0.0/16",
555
- });
556
- }
557
- }
558
- "
559
- `;
560
-
561
- exports[`resources tricky to parse items snapshot typescript 1`] = `
562
- "import { Construct } from "constructs";
563
- import {
564
- VariableType,
565
- TerraformVariable,
566
- Fn,
567
- Token,
568
- TerraformSelf,
569
- TerraformStack,
570
- } from "cdktn";
571
- /*
572
- * Provider bindings are generated by running \`cdktn get\`.
573
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
574
- */
575
- import { Instance } from "./.gen/providers/aws/instance";
576
- import { AwsProvider } from "./.gen/providers/aws/provider";
577
- class MyConvertedCode extends TerraformStack {
578
- constructor(scope: Construct, name: string) {
579
- super(scope, name);
580
- /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
581
- You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
582
- new AwsProvider(this, "aws", {
583
- region: "us-east-1",
584
- });
585
- const tags = new TerraformVariable(this, "tags", {
586
- type: VariableType.ANY,
587
- });
588
- new Instance(this, "play", {
589
- ami: Token.asString(
590
- Fn.join(
591
- "-",
592
- Token.asList([
593
- Fn.lookupNested(tags.value, ["app"]),
594
- Fn.lookupNested(tags.value, ["env"]),
595
- ])
596
- )
597
- ),
598
- associatePublicIpAddress: true,
599
- connection: {
600
- host: TerraformSelf.getAny("public_ip"),
601
- private_key: Fn.file("./terraform_key"),
602
- type: "ssh",
603
- user: "ubuntu",
604
- },
605
- instanceType: "t3.small",
606
- keyName: masterKey.id,
607
- subnetId: main.id,
608
- vpcSecurityGroupIds: [ssh.id],
609
- });
610
- }
611
- }
612
- "
613
- `;