@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,141 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
});
|