@cdktn/hcl2cdk 0.26.0-pre.20 → 0.26.0-pre.21

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 (92) hide show
  1. package/package.json +8 -7
  2. package/.spec.swcrc +0 -22
  3. package/build/__tests__/coerceType.test.d.ts +0 -2
  4. package/build/__tests__/coerceType.test.js +0 -165
  5. package/build/__tests__/expressionToTs.test.d.ts +0 -6
  6. package/build/__tests__/expressionToTs.test.js +0 -693
  7. package/build/__tests__/expressions.test.d.ts +0 -4
  8. package/build/__tests__/expressions.test.js +0 -424
  9. package/build/__tests__/findExpressionType.test.d.ts +0 -6
  10. package/build/__tests__/findExpressionType.test.js +0 -105
  11. package/build/__tests__/functions.test.d.ts +0 -6
  12. package/build/__tests__/functions.test.js +0 -615
  13. package/build/__tests__/generation.test.d.ts +0 -6
  14. package/build/__tests__/generation.test.js +0 -45
  15. package/build/__tests__/jsii-rosetta-workarounds.test.d.ts +0 -2
  16. package/build/__tests__/jsii-rosetta-workarounds.test.js +0 -86
  17. package/build/__tests__/partialCode.test.d.ts +0 -6
  18. package/build/__tests__/partialCode.test.js +0 -390
  19. package/build/__tests__/terraformSchema.test.d.ts +0 -6
  20. package/build/__tests__/terraformSchema.test.js +0 -105
  21. package/build/__tests__/testHelpers.d.ts +0 -7
  22. package/build/__tests__/testHelpers.js +0 -15
  23. package/jest.config.js +0 -25
  24. package/package.sh +0 -9
  25. package/src/__tests__/coerceType.test.ts +0 -207
  26. package/src/__tests__/expressionToTs.test.ts +0 -1167
  27. package/src/__tests__/expressions.test.ts +0 -541
  28. package/src/__tests__/findExpressionType.test.ts +0 -112
  29. package/src/__tests__/functions.test.ts +0 -764
  30. package/src/__tests__/generation.test.ts +0 -72
  31. package/src/__tests__/jsii-rosetta-workarounds.test.ts +0 -145
  32. package/src/__tests__/partialCode.test.ts +0 -432
  33. package/src/__tests__/terraformSchema.test.ts +0 -107
  34. package/src/__tests__/testHelpers.ts +0 -11
  35. package/src/coerceType.ts +0 -261
  36. package/src/dynamic-blocks.ts +0 -61
  37. package/src/expressions.ts +0 -968
  38. package/src/function-bindings/functions.generated.ts +0 -1211
  39. package/src/function-bindings/functions.ts +0 -104
  40. package/src/generation.ts +0 -1189
  41. package/src/index.ts +0 -584
  42. package/src/iteration.ts +0 -156
  43. package/src/jsii-rosetta-workarounds.ts +0 -145
  44. package/src/partialCode.ts +0 -132
  45. package/src/provider.ts +0 -60
  46. package/src/references.ts +0 -193
  47. package/src/schema.ts +0 -74
  48. package/src/terraformSchema.ts +0 -182
  49. package/src/types.ts +0 -58
  50. package/src/utils.ts +0 -19
  51. package/src/variables.ts +0 -214
  52. package/test/__snapshots__/backends.test.ts.snap +0 -70
  53. package/test/__snapshots__/externals.test.ts.snap +0 -37
  54. package/test/__snapshots__/granular-imports.test.ts.snap +0 -180
  55. package/test/__snapshots__/imports.test.ts.snap +0 -159
  56. package/test/__snapshots__/iteration.test.ts.snap +0 -532
  57. package/test/__snapshots__/jsiiLanguage.test.ts.snap +0 -347
  58. package/test/__snapshots__/locals.test.ts.snap +0 -55
  59. package/test/__snapshots__/modules.test.ts.snap +0 -127
  60. package/test/__snapshots__/outputs.test.ts.snap +0 -77
  61. package/test/__snapshots__/partialCode.test.ts.snap +0 -120
  62. package/test/__snapshots__/provider.test.ts.snap +0 -128
  63. package/test/__snapshots__/references.test.ts.snap +0 -376
  64. package/test/__snapshots__/resource-meta-properties.test.ts.snap +0 -342
  65. package/test/__snapshots__/resources.test.ts.snap +0 -613
  66. package/test/__snapshots__/tfExpressions.test.ts.snap +0 -537
  67. package/test/__snapshots__/typeCoercion.test.ts.snap +0 -253
  68. package/test/__snapshots__/variables.test.ts.snap +0 -150
  69. package/test/backends.test.ts +0 -75
  70. package/test/convertProject.test.ts +0 -256
  71. package/test/externals.test.ts +0 -35
  72. package/test/globalSetup.ts +0 -224
  73. package/test/globalTeardown.ts +0 -11
  74. package/test/granular-imports.test.ts +0 -161
  75. package/test/hcl2cdk.test.ts +0 -88
  76. package/test/helpers/convert.ts +0 -544
  77. package/test/helpers/tmp.ts +0 -40
  78. package/test/imports.test.ts +0 -141
  79. package/test/iteration.test.ts +0 -342
  80. package/test/jsiiLanguage.test.ts +0 -73
  81. package/test/locals.test.ts +0 -47
  82. package/test/modules.test.ts +0 -143
  83. package/test/outputs.test.ts +0 -69
  84. package/test/partialCode.test.ts +0 -25
  85. package/test/provider.test.ts +0 -106
  86. package/test/references.test.ts +0 -287
  87. package/test/resource-meta-properties.test.ts +0 -288
  88. package/test/resources.test.ts +0 -551
  89. package/test/tfExpressions.test.ts +0 -300
  90. package/test/typeCoercion.test.ts +0 -154
  91. package/test/variables.test.ts +0 -96
  92. package/tsconfig.json +0 -47
@@ -1,141 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import { testCase, Synth, Snapshot, binding } from "./helpers/convert";
4
-
5
- describe("imports", () => {
6
- testCase.test(
7
- "single import",
8
- `
9
- provider "aws" {
10
- region = "us-east-1"
11
- }
12
- import {
13
- to = aws_instance.example
14
- id = "i-abcd1234"
15
- }
16
- `,
17
- [binding.aws],
18
- Snapshot.yes,
19
- Synth.yes,
20
- );
21
-
22
- testCase.test(
23
- "single import with provider",
24
- `
25
- provider "aws" {
26
- alias = "europe"
27
- region = "eu-west-1"
28
- }
29
- import {
30
- to = aws_instance.example
31
- id = "i-abcd1234"
32
- provider = aws.europe
33
- }
34
- `,
35
- [binding.aws],
36
- Snapshot.yes,
37
- Synth.yes,
38
- );
39
-
40
- testCase.test(
41
- "multiple imports",
42
- `
43
- provider "aws" {
44
- region = "us-east-1"
45
- }
46
- import {
47
- to = aws_instance.example
48
- id = "i-abcd1234"
49
- }
50
- import {
51
- to = aws_instance.to_be_imported
52
- id = "i-abcd1234567"
53
- }
54
- `,
55
- [binding.aws],
56
- Snapshot.yes,
57
- Synth.yes,
58
- );
59
-
60
- testCase.test(
61
- "import with config",
62
- `
63
- provider "aws" {
64
- region = "us-east-1"
65
- }
66
- import {
67
- to = aws_instance.example
68
- id = "i-abcd1234"
69
- }
70
-
71
- resource "aws_instance" "example" {
72
- ami = "some-ami"
73
- instance_type = "t3.micro"
74
- }
75
- `,
76
- [binding.aws],
77
- Snapshot.yes,
78
- Synth.yes,
79
- );
80
-
81
- testCase.test(
82
- "import with config and provider",
83
- `
84
- provider "aws" {
85
- region = "us-east-1"
86
- alias = "us"
87
- }
88
- import {
89
- to = aws_instance.example
90
- id = "i-abcd1234"
91
- provider = aws.us
92
- }
93
-
94
- resource "aws_instance" "example" {
95
- ami = "some-ami"
96
- instance_type = "t3.micro"
97
- }
98
- `,
99
- [binding.aws],
100
- Snapshot.yes,
101
- Synth.yes,
102
- );
103
-
104
- describe("Not supported", () => {
105
- testCase.test(
106
- "import into module",
107
- `
108
- provider "aws" {
109
- region = "us-east-1"
110
- }
111
- import {
112
- to = module.instances.aws_instance.example
113
- id = "i-abcd1234"
114
- }
115
- `,
116
- [binding.aws],
117
- Snapshot.yes,
118
- Synth.never,
119
- );
120
-
121
- testCase.test(
122
- "import into expansion (for_each or count)",
123
- `
124
- provider "aws" {
125
- region = "us-east-1"
126
- }
127
- import {
128
- to = aws_instance.example[0]
129
- id = "i-abcd123457"
130
- }
131
- import {
132
- to = aws_instance.example["foo"]
133
- id = "i-abcd1234"
134
- }
135
- `,
136
- [binding.aws],
137
- Snapshot.yes,
138
- Synth.never,
139
- );
140
- });
141
- });
@@ -1,342 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import { testCase, Synth, binding, Snapshot } from "./helpers/convert";
4
-
5
- describe("iteration", () => {
6
- testCase.test(
7
- "for each on list using splat",
8
- `
9
- provider "aws" {
10
- region = "us-east-1"
11
- }
12
- variable "buckets" {
13
- type = list(string)
14
- }
15
-
16
- resource "aws_kms_key" "examplekms" {
17
- description = "KMS key 1"
18
- deletion_window_in_days = 7
19
- }
20
-
21
- resource "aws_s3_bucket" "examplebucket" {
22
- for_each = toset(var.buckets.*)
23
-
24
- bucket = each.key
25
- acl = "private"
26
- }
27
-
28
- resource "aws_s3_bucket_object" "examplebucket_object" {
29
- for_each = toset(aws_s3_bucket.examplebucket.*)
30
-
31
- key = "someobject"
32
- bucket = each.key
33
- source = "index.html"
34
- kms_key_id = aws_kms_key.examplekms.arn
35
- }
36
- `,
37
- [binding.aws],
38
- Snapshot.yes,
39
- Synth.yes,
40
- {
41
- resources: ["aws_kms_key", "aws_s3_bucket", "aws_s3_bucket_object"],
42
- },
43
- );
44
-
45
- testCase.test(
46
- "for_each loops",
47
- `
48
- provider "aws" {
49
- region = "us-east-1"
50
- }
51
- variable "users" {
52
- type = set(string)
53
- }
54
-
55
- resource "aws_iam_user" "lb" {
56
- for_each = var.users
57
- name = each.key
58
- path = "/system/"
59
-
60
- tags = {
61
- tag-key = "tag-value"
62
- }
63
- }
64
- `,
65
- [binding.aws],
66
- Snapshot.yes,
67
- Synth.yes,
68
- {
69
- resources: ["aws_iam_user"],
70
- },
71
- );
72
-
73
- testCase.test(
74
- "count loops",
75
- `
76
- provider "aws" {
77
- region = "us-east-1"
78
- }
79
- variable "users" {
80
- type = set(string)
81
- }
82
-
83
- resource "aws_iam_user" "lb" {
84
- count = length(var.users)
85
- name = element(var.users, count.index)
86
- path = "/system/"
87
-
88
- tags = {
89
- tag-key = "tag-value"
90
- }
91
- }`,
92
- [binding.aws],
93
- Snapshot.yes,
94
- Synth.yes,
95
- {
96
- resources: ["aws_iam_user"],
97
- },
98
- );
99
-
100
- testCase.test(
101
- "simple count",
102
- `
103
- provider "aws" {
104
- region = "us-east-1"
105
- }
106
- resource "aws_instance" "multiple_servers" {
107
- count = 4
108
-
109
- ami = "ami-0c2b8ca1dad447f8a"
110
- instance_type = "t2.micro"
111
-
112
- tags = {
113
- Name = "Server \${count.index}"
114
- }
115
- }
116
- `,
117
- [binding.aws],
118
- Snapshot.yes,
119
- Synth.yes,
120
- {
121
- resources: ["aws_instance"],
122
- },
123
- );
124
-
125
- testCase.test(
126
- "dynamic blocks",
127
- `
128
- provider "aws" {
129
- region = "us-east-1"
130
- }
131
- variable "settings" {
132
- type = list(map(string))
133
- }
134
-
135
- variable "namespace" {
136
- type = string
137
- }
138
-
139
- resource "aws_elastic_beanstalk_environment" "tfenvtest" {
140
- name = "tf-test-name"
141
- application = "best-app"
142
- solution_stack_name = "64bit Amazon Linux 2018.03 v2.11.4 running Go 1.12.6"
143
-
144
- dynamic "setting" {
145
- for_each = var.settings
146
- content {
147
- namespace = var.namespace
148
- name = setting.value["name"]
149
- value = setting.value["value"]
150
- }
151
- }
152
- }`,
153
- [binding.aws],
154
- Snapshot.yes,
155
- Synth.yes,
156
- {
157
- resources: ["aws_elastic_beanstalk_environment"],
158
- },
159
- );
160
-
161
- testCase.test(
162
- "nested dynamic blocks",
163
- `
164
- provider "azuread" {
165
- tenant_id = "00000000-0000-0000-0000-000000000000"
166
- }
167
-
168
- variable required_resource_access {
169
- type = list(object({
170
- resource_app_id = string
171
- resource_access = list(object({
172
- id = string
173
- type = string
174
- }))
175
- }))
176
-
177
- default = [{
178
- resource_app_id = "00000003-0000-0000-c000-000000000000"
179
- resource_access = [{
180
- id = "7ab1d382-f21e-4acd-a863-ba3e13f7da61"
181
- type = "Role"
182
- }]
183
- }]
184
- }
185
-
186
- resource "azuread_application" "bootstrap" {
187
- display_name = "test"
188
- group_membership_claims = "All"
189
-
190
- dynamic "required_resource_access" {
191
- for_each = var.required_resource_access
192
- content {
193
- resource_app_id = required_resource_access.value["resource_app_id"]
194
-
195
- dynamic "resource_access" {
196
- for_each = required_resource_access.value["resource_access"]
197
- content {
198
- id = resource_access.value["id"]
199
- type = resource_access.value["type"]
200
- }
201
- }
202
- }
203
- }
204
- }
205
- `,
206
- [binding.azuread],
207
- Snapshot.yes,
208
- Synth.yes,
209
- {
210
- resources: ["azuread_application"],
211
- },
212
- );
213
- testCase.test(
214
- "complex for each loops",
215
- `
216
- provider "aws" {
217
- region = "us-east-1"
218
- }
219
-
220
- resource "aws_acm_certificate" "example" {
221
- domain_name = "example.com"
222
- validation_method = "DNS"
223
- }
224
-
225
- data "aws_route53_zone" "example" {
226
- name = "example.com"
227
- private_zone = false
228
- }
229
-
230
- resource "aws_route53_record" "example" {
231
- for_each = {
232
- for dvo in aws_acm_certificate.example.domain_validation_options : dvo.domain_name => {
233
- name = dvo.resource_record_name
234
- record = dvo.resource_record_value
235
- type = dvo.resource_record_type
236
- }
237
- }
238
-
239
- allow_overwrite = true
240
- name = each.value.name
241
- records = [each.value.record]
242
- ttl = 60
243
- type = each.value.type
244
- zone_id = data.aws_route53_zone.example.zone_id
245
- }
246
-
247
- resource "aws_acm_certificate_validation" "example" {
248
- certificate_arn = aws_acm_certificate.example.arn
249
- validation_record_fqdns = [for record in aws_route53_record.example : record.fqdn]
250
- }
251
-
252
- resource "aws_lb_listener" "example" {
253
- # ... other configuration ...
254
-
255
- certificate_arn = aws_acm_certificate_validation.example.certificate_arn
256
- load_balancer_arn = "best-lb-arn"
257
- default_action {
258
- type = "forward"
259
- target_group_arn = "best-target"
260
- }
261
- }
262
- `,
263
- [binding.aws],
264
- Snapshot.yes,
265
- Synth.yes,
266
- {
267
- resources: [
268
- "aws_lb_listener",
269
- "aws_acm_certificate_validation",
270
- "aws_route53_record",
271
- "aws_acm_certificate",
272
- ],
273
- dataSources: ["aws_route53_zone"],
274
- },
275
- );
276
-
277
- testCase.test(
278
- "for_each with var usage",
279
- `
280
- provider "azuread" {
281
- tenant_id = "00000000-0000-0000-0000-000000000000"
282
- }
283
- variable "one_set_of_users" {
284
- description = "users"
285
- }
286
- variable "other_set_of_users" {
287
- description = "users"
288
- }
289
- variable "azure_ad_domain_name" {
290
- description = "domain"
291
- }
292
- resource "azuread_user" "azure_users" {
293
- for_each = merge(
294
- var.one_set_of_users,
295
- var.other_set_of_users,
296
- )
297
-
298
- user_principal_name = "\${each.value}\${var.azure_ad_domain_name}"
299
- display_name = each.key
300
- }
301
- `,
302
- [binding.azuread],
303
- Snapshot.yes,
304
- Synth.yes,
305
- {
306
- resources: ["azuread_user"],
307
- },
308
- );
309
-
310
- testCase.test(
311
- "ensure availability zone is not ignored",
312
- `
313
- provider "aws" {
314
- region = "us-east-1"
315
- }
316
-
317
- data "aws_availability_zones" "available" {
318
- state = "available"
319
- }
320
-
321
- variable "public_subnet_count" {
322
- type = number
323
- description = "Number of public subnets to create"
324
- default = 2
325
- }
326
-
327
- resource "aws_subnet" "public" {
328
- count = var.public_subnet_count
329
- vpc_id = "10123"
330
- cidr_block = "10.0.1.0/24"
331
- availability_zone = data.aws_availability_zones.available.names[count.index]
332
- }
333
- `,
334
- [binding.aws],
335
- Snapshot.yes,
336
- Synth.yes,
337
- {
338
- resources: ["aws_subnet"],
339
- dataSources: ["aws_availability_zones"],
340
- },
341
- );
342
- });
@@ -1,73 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import { binding, Snapshot, Synth, testCase } from "./helpers/convert";
7
-
8
- describe("JSII Language Support", () => {
9
- testCase.test(
10
- "complex aws example",
11
- `
12
- provider "aws" {
13
- region = "us-east-1"
14
- }
15
- resource "aws_kms_key" "examplekms" {
16
- description = "KMS key 1"
17
- deletion_window_in_days = 7
18
- }
19
-
20
- resource "aws_s3_bucket" "examplebucket" {
21
- bucket = "examplebuckettftest"
22
- acl = "private"
23
- }
24
-
25
- resource "aws_s3_bucket_object" "examplebucket_object" {
26
- key = "someobject"
27
- bucket = aws_s3_bucket.examplebucket.bucket
28
- source = "index.html"
29
- kms_key_id = aws_kms_key.examplekms.arn
30
- }
31
-
32
- resource "aws_security_group" "allow_tls" {
33
- name = "allow_tls"
34
- description = "Allow TLS inbound traffic"
35
-
36
- ingress {
37
- description = "TLS from VPC"
38
- from_port = 443
39
- to_port = 443
40
- protocol = "tcp"
41
- }
42
-
43
- ingress {
44
- description = "TLS from VPC"
45
- from_port = 80
46
- to_port = 80
47
- protocol = "tcp"
48
- }
49
-
50
- ingress {
51
- from_port = 8080
52
- to_port = 8080
53
- protocol = "tcp"
54
- }
55
-
56
- egress {
57
- from_port = 0
58
- to_port = 0
59
- protocol = "-1"
60
- cidr_blocks = ["0.0.0.0/0"]
61
- ipv6_cidr_blocks = ["::/0"]
62
- }
63
-
64
- tags = {
65
- Name = "allow_tls"
66
- }
67
- }
68
- `,
69
- [binding.aws],
70
- Snapshot.yes_all_languages,
71
- Synth.yes_but_only_typescript_right_now_because_it_breaks,
72
- );
73
- });
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import { testCase, Synth, Snapshot } from "./helpers/convert";
7
-
8
- describe("locals", () => {
9
- testCase.test(
10
- "locals",
11
- `
12
- locals {
13
- service_name = "forum"
14
- owner = "Community Team"
15
- is_it_great = true
16
- how_many = 42
17
- }
18
- output "combined-so-it-does-not-get-removed" {
19
- value = "\${local.service_name},\${local.owner},\${local.is_it_great},\${local.how_many}"
20
- }
21
- `,
22
- [],
23
- Snapshot.yes,
24
- Synth.yes,
25
- );
26
-
27
- testCase.test(
28
- "multiple locals blocks",
29
- `
30
- locals {
31
- service_name = "forum"
32
- owner = "Community Team"
33
- }
34
-
35
- locals {
36
- is_it_great = true
37
- how_many = 42
38
- }
39
-
40
- output "combined-so-it-does-not-get-removed" {
41
- value = "\${local.service_name},\${local.owner},\${local.is_it_great},\${local.how_many}"
42
- }`,
43
- [],
44
- Snapshot.yes,
45
- Synth.yes,
46
- );
47
- });