@cdktn/hcl2cdk 0.24.0-pre.43 → 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.
Files changed (89) hide show
  1. package/LICENSE +355 -0
  2. package/README.md +1 -1
  3. package/build/__tests__/expressions.test.js +10 -19
  4. package/build/__tests__/functions.test.js +8 -18
  5. package/build/__tests__/testHelpers.js +3 -2
  6. package/build/coerceType.js +11 -21
  7. package/build/dynamic-blocks.js +3 -3
  8. package/build/expressions.js +13 -22
  9. package/build/function-bindings/functions.generated.js +2 -2
  10. package/build/generation.js +24 -34
  11. package/build/index.js +15 -25
  12. package/build/iteration.js +7 -6
  13. package/build/jsii-rosetta-workarounds.js +6 -5
  14. package/build/partialCode.js +11 -20
  15. package/build/provider.js +4 -3
  16. package/build/references.js +6 -5
  17. package/build/schema.js +8 -18
  18. package/build/terraformSchema.js +4 -4
  19. package/build/utils.js +3 -3
  20. package/build/variables.js +12 -21
  21. package/package.json +20 -17
  22. package/package.sh +1 -1
  23. package/src/__tests__/coerceType.test.ts +207 -0
  24. package/src/__tests__/expressionToTs.test.ts +1167 -0
  25. package/src/__tests__/expressions.test.ts +541 -0
  26. package/src/__tests__/findExpressionType.test.ts +112 -0
  27. package/src/__tests__/functions.test.ts +768 -0
  28. package/src/__tests__/generation.test.ts +72 -0
  29. package/src/__tests__/jsii-rosetta-workarounds.test.ts +145 -0
  30. package/src/__tests__/partialCode.test.ts +432 -0
  31. package/src/__tests__/terraformSchema.test.ts +107 -0
  32. package/src/__tests__/testHelpers.ts +11 -0
  33. package/src/coerceType.ts +261 -0
  34. package/src/dynamic-blocks.ts +61 -0
  35. package/src/expressions.ts +968 -0
  36. package/src/function-bindings/functions.generated.ts +1139 -0
  37. package/src/function-bindings/functions.ts +104 -0
  38. package/src/generation.ts +1189 -0
  39. package/src/index.ts +584 -0
  40. package/src/iteration.ts +156 -0
  41. package/src/jsii-rosetta-workarounds.ts +145 -0
  42. package/src/partialCode.ts +132 -0
  43. package/src/provider.ts +60 -0
  44. package/src/references.ts +193 -0
  45. package/src/schema.ts +74 -0
  46. package/src/terraformSchema.ts +182 -0
  47. package/src/types.ts +58 -0
  48. package/src/utils.ts +19 -0
  49. package/src/variables.ts +214 -0
  50. package/test/__snapshots__/backends.test.ts.snap +70 -0
  51. package/test/__snapshots__/externals.test.ts.snap +37 -0
  52. package/test/__snapshots__/granular-imports.test.ts.snap +180 -0
  53. package/test/__snapshots__/imports.test.ts.snap +159 -0
  54. package/test/__snapshots__/iteration.test.ts.snap +532 -0
  55. package/test/__snapshots__/jsiiLanguage.test.ts.snap +347 -0
  56. package/test/__snapshots__/locals.test.ts.snap +55 -0
  57. package/test/__snapshots__/modules.test.ts.snap +127 -0
  58. package/test/__snapshots__/outputs.test.ts.snap +77 -0
  59. package/test/__snapshots__/partialCode.test.ts.snap +120 -0
  60. package/test/__snapshots__/provider.test.ts.snap +128 -0
  61. package/test/__snapshots__/references.test.ts.snap +376 -0
  62. package/test/__snapshots__/resource-meta-properties.test.ts.snap +342 -0
  63. package/test/__snapshots__/resources.test.ts.snap +613 -0
  64. package/test/__snapshots__/tfExpressions.test.ts.snap +537 -0
  65. package/test/__snapshots__/typeCoercion.test.ts.snap +253 -0
  66. package/test/__snapshots__/variables.test.ts.snap +150 -0
  67. package/test/backends.test.ts +75 -0
  68. package/test/convertProject.test.ts +257 -0
  69. package/test/externals.test.ts +35 -0
  70. package/test/globalSetup.ts +224 -0
  71. package/test/globalTeardown.ts +11 -0
  72. package/test/granular-imports.test.ts +161 -0
  73. package/test/hcl2cdk.test.ts +88 -0
  74. package/test/helpers/convert.ts +543 -0
  75. package/test/helpers/tmp.ts +25 -0
  76. package/test/imports.test.ts +141 -0
  77. package/test/iteration.test.ts +342 -0
  78. package/test/jsiiLanguage.test.ts +73 -0
  79. package/test/locals.test.ts +47 -0
  80. package/test/modules.test.ts +143 -0
  81. package/test/outputs.test.ts +69 -0
  82. package/test/partialCode.test.ts +25 -0
  83. package/test/provider.test.ts +106 -0
  84. package/test/references.test.ts +287 -0
  85. package/test/resource-meta-properties.test.ts +288 -0
  86. package/test/resources.test.ts +551 -0
  87. package/test/tfExpressions.test.ts +300 -0
  88. package/test/typeCoercion.test.ts +154 -0
  89. package/test/variables.test.ts +96 -0
@@ -0,0 +1,537 @@
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
+
3
+ exports[`tfExpressions arithmetics snapshot typescript 1`] = `
4
+ "import { Construct } from "constructs";
5
+ import {
6
+ VariableType,
7
+ TerraformVariable,
8
+ TerraformOutput,
9
+ Op,
10
+ TerraformStack,
11
+ } from "cdktn";
12
+ class MyConvertedCode extends TerraformStack {
13
+ constructor(scope: Construct, name: string) {
14
+ super(scope, name);
15
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
16
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
17
+ const admins = new TerraformVariable(this, "admins", {
18
+ type: VariableType.NUMBER,
19
+ });
20
+ const members = new TerraformVariable(this, "members", {
21
+ type: VariableType.NUMBER,
22
+ });
23
+ new TerraformOutput(this, "arithmetics", {
24
+ value: Op.add(members.value, admins.value),
25
+ });
26
+ }
27
+ }
28
+ "
29
+ `;
30
+
31
+ exports[`tfExpressions conditionals snapshot typescript 1`] = `
32
+ "import { Construct } from "constructs";
33
+ import { Op, conditional, Token, TerraformStack } from "cdktn";
34
+ /*
35
+ * Provider bindings are generated by running \`cdktn get\`.
36
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
37
+ */
38
+ import { KmsKey } from "./.gen/providers/aws/kms-key";
39
+ import { AwsProvider } from "./.gen/providers/aws/provider";
40
+ import { S3Bucket } from "./.gen/providers/aws/s3-bucket";
41
+ import { S3BucketObject } from "./.gen/providers/aws/s3-bucket-object";
42
+ class MyConvertedCode extends TerraformStack {
43
+ constructor(scope: Construct, name: string) {
44
+ super(scope, name);
45
+ new AwsProvider(this, "aws", {
46
+ region: "us-east-1",
47
+ });
48
+ const examplekms = new KmsKey(this, "examplekms", {
49
+ deletionWindowInDays: 7,
50
+ description: "KMS key 1",
51
+ });
52
+ const examplebucket = new S3Bucket(this, "examplebucket", {
53
+ acl: "private",
54
+ bucket: "examplebuckettftest",
55
+ });
56
+ new S3BucketObject(this, "examplebucket_object", {
57
+ bucket: Token.asString(
58
+ conditional(
59
+ Op.gt(examplekms.deletionWindowInDays, 3),
60
+ examplebucket.id,
61
+ []
62
+ )
63
+ ),
64
+ key: "someobject",
65
+ kmsKeyId: examplekms.arn,
66
+ source: "index.html",
67
+ });
68
+ }
69
+ }
70
+ "
71
+ `;
72
+
73
+ exports[`tfExpressions escaping dollar-curly in template strings works snapshot typescript 1`] = `
74
+ "import { Construct } from "constructs";
75
+ import { TerraformStack } from "cdktn";
76
+ /*
77
+ * Provider bindings are generated by running \`cdktn get\`.
78
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
79
+ */
80
+ import { SsoadminInstanceAccessControlAttributes } from "./.gen/providers/aws/ssoadmin-instance-access-control-attributes";
81
+ interface MyConfig {
82
+ key: any;
83
+ instanceArn: any;
84
+ }
85
+ class MyConvertedCode extends TerraformStack {
86
+ constructor(scope: Construct, name: string, config: MyConfig) {
87
+ super(scope, name);
88
+ new SsoadminInstanceAccessControlAttributes(this, "example", {
89
+ attribute: [
90
+ {
91
+ value: [
92
+ {
93
+ source: ["$\${path:name.givenName}"],
94
+ },
95
+ ],
96
+ key: config.key,
97
+ },
98
+ ],
99
+ instanceArn: config.instanceArn,
100
+ });
101
+ }
102
+ }
103
+ "
104
+ `;
105
+
106
+ exports[`tfExpressions for expression 1 snapshot typescript 1`] = `
107
+ "import { Construct } from "constructs";
108
+ import {
109
+ VariableType,
110
+ TerraformVariable,
111
+ TerraformOutput,
112
+ TerraformStack,
113
+ } from "cdktn";
114
+ class MyConvertedCode extends TerraformStack {
115
+ constructor(scope: Construct, name: string) {
116
+ super(scope, name);
117
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
118
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
119
+ const users = new TerraformVariable(this, "users", {
120
+ type: VariableType.map(
121
+ VariableType.object({
122
+ is_admin: VariableType.ANY,
123
+ })
124
+ ),
125
+ });
126
+ const adminUsers =
127
+ "\${{ for name, user in \${" +
128
+ users.value +
129
+ "} : name => user if user.is_admin}}";
130
+ const regularUsers =
131
+ "\${{ for name, user in \${" +
132
+ users.value +
133
+ "} : name => user if !user.is_admin}}";
134
+ new TerraformOutput(this, "combined-so-it-does-not-get-removed", {
135
+ value: "\${" + adminUsers + "},\${" + regularUsers + "}",
136
+ });
137
+ }
138
+ }
139
+ "
140
+ `;
141
+
142
+ exports[`tfExpressions for expression 2 snapshot typescript 1`] = `
143
+ "import { Construct } from "constructs";
144
+ import {
145
+ VariableType,
146
+ TerraformVariable,
147
+ TerraformOutput,
148
+ TerraformStack,
149
+ } from "cdktn";
150
+ class MyConvertedCode extends TerraformStack {
151
+ constructor(scope: Construct, name: string) {
152
+ super(scope, name);
153
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
154
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
155
+ const users = new TerraformVariable(this, "users", {
156
+ type: VariableType.map(
157
+ VariableType.object({
158
+ role: VariableType.STRING,
159
+ })
160
+ ),
161
+ });
162
+ const usersByRole =
163
+ "\${{ for name, user in \${" + users.value + "} : user.role => name...}}";
164
+ new TerraformOutput(this, "so-it-does-not-get-removed", {
165
+ value: usersByRole,
166
+ });
167
+ }
168
+ }
169
+ "
170
+ `;
171
+
172
+ exports[`tfExpressions for expression 3 snapshot typescript 1`] = `
173
+ "import { Construct } from "constructs";
174
+ import {
175
+ VariableType,
176
+ TerraformVariable,
177
+ Fn,
178
+ Token,
179
+ TerraformStack,
180
+ } from "cdktn";
181
+ /*
182
+ * Provider bindings are generated by running \`cdktn get\`.
183
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
184
+ */
185
+ import { Monitor } from "./.gen/providers/datadog/monitor";
186
+ import { DatadogProvider } from "./.gen/providers/datadog/provider";
187
+ class MyConvertedCode extends TerraformStack {
188
+ constructor(scope: Construct, name: string) {
189
+ super(scope, name);
190
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
191
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
192
+ new DatadogProvider(this, "datadog", {
193
+ apiKey: "api_key",
194
+ appKey: "app_key",
195
+ });
196
+ const users = new TerraformVariable(this, "users", {
197
+ type: VariableType.list(
198
+ VariableType.object({
199
+ id: VariableType.STRING,
200
+ })
201
+ ),
202
+ });
203
+ new Monitor(this, "hard_query", {
204
+ message: "here we go",
205
+ name: "queries are hard",
206
+ query: Token.asString(
207
+ Fn.join(
208
+ " && ",
209
+ Token.asList("\${[ for o in \${" + users.value + '} : "!(!\${o.id})"]}')
210
+ )
211
+ ),
212
+ type: "metric alert",
213
+ });
214
+ }
215
+ }
216
+ "
217
+ `;
218
+
219
+ exports[`tfExpressions list access through square brackets snapshot typescript 1`] = `
220
+ "import { Construct } from "constructs";
221
+ import {
222
+ VariableType,
223
+ TerraformVariable,
224
+ Fn,
225
+ Token,
226
+ TerraformStack,
227
+ } from "cdktn";
228
+ /*
229
+ * Provider bindings are generated by running \`cdktn get\`.
230
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
231
+ */
232
+ import { AwsProvider } from "./.gen/providers/aws/provider";
233
+ import { S3Bucket } from "./.gen/providers/aws/s3-bucket";
234
+ class MyConvertedCode extends TerraformStack {
235
+ constructor(scope: Construct, name: string) {
236
+ super(scope, name);
237
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
238
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
239
+ new AwsProvider(this, "aws", {
240
+ region: "us-east-1",
241
+ });
242
+ const settings = new TerraformVariable(this, "settings", {
243
+ type: VariableType.list(VariableType.map(VariableType.STRING)),
244
+ });
245
+ new S3Bucket(this, "examplebucket", {
246
+ acl: "private",
247
+ bucket: Token.asString(
248
+ Fn.lookupNested(settings.value, ["0", '"bucket_name"'])
249
+ ),
250
+ });
251
+ }
252
+ }
253
+ "
254
+ `;
255
+
256
+ exports[`tfExpressions multi-line strings are supported snapshot typescript 1`] = `
257
+ "import { Construct } from "constructs";
258
+ import { TerraformOutput, TerraformStack } from "cdktn";
259
+ class MyConvertedCode extends TerraformStack {
260
+ constructor(scope: Construct, name: string) {
261
+ super(scope, name);
262
+ new TerraformOutput(this, "hash", {
263
+ value:
264
+ '{\\n "example_hash_key": {"S": "something"},\\n "example_attribute": {"N": "11111"}\\n}\\n\\n',
265
+ });
266
+ }
267
+ }
268
+ "
269
+ `;
270
+
271
+ exports[`tfExpressions numeric property access snapshot typescript 1`] = `
272
+ "import { Construct } from "constructs";
273
+ import { TerraformOutput, Fn, TerraformStack } from "cdktn";
274
+ /*
275
+ * Provider bindings are generated by running \`cdktn get\`.
276
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
277
+ */
278
+ import { ComputeInstance } from "./.gen/providers/google/compute-instance";
279
+ import { GoogleProvider } from "./.gen/providers/google/provider";
280
+ class MyConvertedCode extends TerraformStack {
281
+ constructor(scope: Construct, name: string) {
282
+ super(scope, name);
283
+ new GoogleProvider(this, "google", {
284
+ project: "my-project",
285
+ region: "us-central1",
286
+ });
287
+ const example = new ComputeInstance(this, "example", {
288
+ bootDisk: {
289
+ initializeParams: {
290
+ image: "debian-cloud/debian-9",
291
+ },
292
+ },
293
+ machineType: "f1-micro",
294
+ name: "example",
295
+ networkInterface: [
296
+ {
297
+ accessConfig: [{}],
298
+ network: "default",
299
+ },
300
+ ],
301
+ zone: "us-east1-b",
302
+ });
303
+ new TerraformOutput(this, "public_ip", {
304
+ value: Fn.lookupNested(example.networkInterface, [
305
+ "0",
306
+ "access_config",
307
+ "0",
308
+ "assigned_nat_ip",
309
+ ]),
310
+ });
311
+ }
312
+ }
313
+ "
314
+ `;
315
+
316
+ exports[`tfExpressions property access in maps works snapshot csharp 1`] = `
317
+ "using Constructs;
318
+ using Io.Cdktn;
319
+ /*
320
+ * Provider bindings are generated by running \`cdktn get\`.
321
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
322
+ */
323
+ using aws.Eip;
324
+ class MyConvertedCode : TerraformStack
325
+ {
326
+ public MyConvertedCode(Construct scope, string name) : base(scope, name)
327
+ {
328
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
329
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
330
+ var defaultTags = new TerraformVariable(this, "default_tags", new TerraformVariableConfig {
331
+ Default = new [] { new Dictionary<string, string> {
332
+ { "project", "Learning Live with AWS & HashiCorp" }
333
+ } },
334
+ Description = "Map of default tags to apply to resources",
335
+ Type = VariableType.Map(VariableType.STRING)
336
+ });
337
+ new Eip(this, "nat", new EipConfig {
338
+ Tags = new Dictionary<string, string> {
339
+ { "Name", Token.AsString(Fn.LookupNested(defaultTags.Value, new [] { "project" })) + "-nat-eip" }
340
+ },
341
+ Vpc = true
342
+ });
343
+ }
344
+ }"
345
+ `;
346
+
347
+ exports[`tfExpressions property access in maps works snapshot go 1`] = `
348
+ "import "github.com/aws/constructs-go/constructs"
349
+ import "github.com/open-constructs/cdk-terrain-go/cdktn"
350
+ /*
351
+ * Provider bindings are generated by running \`cdktn get\`.
352
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
353
+ */
354
+ import "cdk.tf/go/stack/generated/aws/eip"
355
+ type myConvertedCode struct {
356
+ TerraformStack
357
+ }
358
+
359
+ func newMyConvertedCode(scope Construct, name *string) *myConvertedCode {
360
+ this := &myConvertedCode{}
361
+ newTerraformStack_Override(this, scope, name)
362
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
363
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
364
+ defaultTags := cdktn.NewTerraformVariable(this, jsii.String("default_tags"), &TerraformVariableConfig{
365
+ Default: []interface{}{
366
+ map[string]*string{
367
+ "project": jsii.String("Learning Live with AWS & HashiCorp"),
368
+ },
369
+ },
370
+ Description: jsii.String("Map of default tags to apply to resources"),
371
+ Type: cdktn.VariableType_Map(cdktn.VariableType_STRING()),
372
+ })
373
+ genprovidersawseip.NewEip(this, jsii.String("nat"), &EipConfig{
374
+ tags: map[string]*string{
375
+ "Name": jsii.String(cdktn.Token_asString(cdktn.Fn_lookupNested(defaultTags.value, []interface{}{
376
+ jsii.String("project"),
377
+ })) + "-nat-eip"),
378
+ },
379
+ vpc: jsii.Boolean(true),
380
+ })
381
+ return this
382
+ }"
383
+ `;
384
+
385
+ exports[`tfExpressions property access in maps works snapshot java 1`] = `
386
+ "import software.constructs.Construct;
387
+ import io.cdktn.cdktn.VariableType;
388
+ import io.cdktn.cdktn.TerraformVariable;
389
+ import io.cdktn.cdktn.Fn;
390
+ import io.cdktn.cdktn.Token;
391
+ import io.cdktn.cdktn.TerraformStack;
392
+ /*
393
+ * Provider bindings are generated by running \`cdktn get\`.
394
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
395
+ */
396
+ import imports.aws.eip.Eip;
397
+ public class MyConvertedCode extends TerraformStack {
398
+ public MyConvertedCode(Construct scope, String name) {
399
+ super(scope, name);
400
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
401
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
402
+ TerraformVariable defaultTags = TerraformVariable.Builder.create(this, "default_tags")
403
+ .default(List.of(Map.of(
404
+ "project", "Learning Live with AWS & HashiCorp")))
405
+ .description("Map of default tags to apply to resources")
406
+ .type(VariableType.map(VariableType.STRING))
407
+ .build();
408
+ new Eip(this, "nat", new EipConfig()
409
+ .tags(Map.of(
410
+ "Name", Token.asString(Fn.lookupNested(defaultTags.getValue(), List.of("project"))) + "-nat-eip"))
411
+ .vpc(true)
412
+ );
413
+ }
414
+ }"
415
+ `;
416
+
417
+ exports[`tfExpressions property access in maps works snapshot python 1`] = `
418
+ "from constructs import Construct
419
+ from cdktn import VariableType, TerraformVariable, Fn, Token, TerraformStack
420
+ #
421
+ # Provider bindings are generated by running \`cdktn get\`.
422
+ # See https://cdktn.io/docs/concepts/providers#import-providers for more details.
423
+ #
424
+ from imports.aws.eip import Eip
425
+ class MyConvertedCode(TerraformStack):
426
+ def __init__(self, scope, name):
427
+ super().__init__(scope, name)
428
+ # Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
429
+ # You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables
430
+ default_tags = TerraformVariable(self, "default_tags",
431
+ default=[{
432
+ "project": "Learning Live with AWS & HashiCorp"
433
+ }
434
+ ],
435
+ description="Map of default tags to apply to resources",
436
+ type=VariableType.map(VariableType.STRING)
437
+ )
438
+ Eip(self, "nat",
439
+ tags={
440
+ "Name":
441
+ Token.as_string(Fn.lookup_nested(default_tags.value, ["project"])) + "-nat-eip"
442
+ },
443
+ vpc=True
444
+ )"
445
+ `;
446
+
447
+ exports[`tfExpressions property access in maps works snapshot typescript 1`] = `
448
+ "import { Construct } from "constructs";
449
+ import {
450
+ VariableType,
451
+ TerraformVariable,
452
+ Fn,
453
+ Token,
454
+ TerraformStack,
455
+ } from "cdktn";
456
+ /*
457
+ * Provider bindings are generated by running \`cdktn get\`.
458
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
459
+ */
460
+ import { Eip } from "./.gen/providers/aws/eip";
461
+ class MyConvertedCode extends TerraformStack {
462
+ constructor(scope: Construct, name: string) {
463
+ super(scope, name);
464
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
465
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
466
+ const defaultTags = new TerraformVariable(this, "default_tags", {
467
+ default: [
468
+ {
469
+ project: "Learning Live with AWS & HashiCorp",
470
+ },
471
+ ],
472
+ description: "Map of default tags to apply to resources",
473
+ type: VariableType.map(VariableType.STRING),
474
+ });
475
+ new Eip(this, "nat", {
476
+ tags: {
477
+ Name:
478
+ Token.asString(Fn.lookupNested(defaultTags.value, ["project"])) +
479
+ "-nat-eip",
480
+ },
481
+ vpc: true,
482
+ });
483
+ }
484
+ }
485
+ "
486
+ `;
487
+
488
+ exports[`tfExpressions property access through square brackets snapshot typescript 1`] = `
489
+ "import { Construct } from "constructs";
490
+ import {
491
+ VariableType,
492
+ TerraformVariable,
493
+ Fn,
494
+ Token,
495
+ TerraformStack,
496
+ } from "cdktn";
497
+ /*
498
+ * Provider bindings are generated by running \`cdktn get\`.
499
+ * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
500
+ */
501
+ import { AwsProvider } from "./.gen/providers/aws/provider";
502
+ import { S3Bucket } from "./.gen/providers/aws/s3-bucket";
503
+ class MyConvertedCode extends TerraformStack {
504
+ constructor(scope: Construct, name: string) {
505
+ super(scope, name);
506
+ /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
507
+ You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
508
+ new AwsProvider(this, "aws", {
509
+ region: "us-east-1",
510
+ });
511
+ const settings = new TerraformVariable(this, "settings", {
512
+ type: VariableType.map(VariableType.STRING),
513
+ });
514
+ new S3Bucket(this, "examplebucket", {
515
+ acl: "private",
516
+ bucket: Token.asString(
517
+ Fn.lookupNested(settings.value, ['"bucket_name"'])
518
+ ),
519
+ });
520
+ }
521
+ }
522
+ "
523
+ `;
524
+
525
+ exports[`tfExpressions strings containing single outer quotes are supported snapshot typescript 1`] = `
526
+ "import { Construct } from "constructs";
527
+ import { TerraformOutput, TerraformStack } from "cdktn";
528
+ class MyConvertedCode extends TerraformStack {
529
+ constructor(scope: Construct, name: string) {
530
+ super(scope, name);
531
+ new TerraformOutput(this, "hash", {
532
+ value: "'static'",
533
+ });
534
+ }
535
+ }
536
+ "
537
+ `;