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

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,180 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`granular-imports nested sub-structs snapshot typescript 1`] = `
4
- "import { Construct } from "constructs";
5
- import { 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 { Deployment } from "./.gen/providers/kubernetes/deployment";
11
- import { KubernetesProvider } from "./.gen/providers/kubernetes/provider";
12
- class MyConvertedCode extends TerraformStack {
13
- constructor(scope: Construct, name: string) {
14
- super(scope, name);
15
- new KubernetesProvider(this, "kubernetes", {});
16
- new Deployment(this, "example", {
17
- metadata: {
18
- labels: {
19
- test: "MyExampleApp",
20
- },
21
- name: "terraform-example",
22
- },
23
- spec: {
24
- replicas: Token.asString(3),
25
- selector: {
26
- matchLabels: {
27
- test: "MyExampleApp",
28
- },
29
- },
30
- template: {
31
- metadata: {
32
- labels: {
33
- test: "MyExampleApp",
34
- },
35
- },
36
- spec: {
37
- container: [
38
- {
39
- image: "nginx:1.21.6",
40
- livenessProbe: {
41
- httpGet: {
42
- httpHeader: [
43
- {
44
- name: "X-Custom-Header",
45
- value: "Awesome",
46
- },
47
- ],
48
- path: "/",
49
- port: Token.asString(80),
50
- },
51
- initialDelaySeconds: 3,
52
- periodSeconds: 3,
53
- },
54
- name: "example",
55
- resources: {
56
- limits: {
57
- cpu: "0.5",
58
- memory: "512Mi",
59
- },
60
- requests: {
61
- cpu: "250m",
62
- memory: "50Mi",
63
- },
64
- },
65
- },
66
- ],
67
- },
68
- },
69
- },
70
- });
71
- }
72
- }
73
- "
74
- `;
75
-
76
- exports[`granular-imports should handle most cdktf and provider constructs for granular imports snapshot typescript 1`] = `
77
- "import { Construct } from "constructs";
78
- import {
79
- VariableType,
80
- TerraformVariable,
81
- TerraformOutput,
82
- Token,
83
- TerraformCount,
84
- Op,
85
- RemoteBackend,
86
- TerraformStack,
87
- } from "cdktn";
88
- /*
89
- * Provider bindings are generated by running \`cdktn get\`.
90
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
91
- */
92
- import { ComputeAutoscaler } from "./.gen/providers/google/compute-autoscaler";
93
- import { ComputeInstanceGroupManager } from "./.gen/providers/google/compute-instance-group-manager";
94
- import { GoogleProvider } from "./.gen/providers/google/provider";
95
- import { DataLocalFile } from "./.gen/providers/local/data-local-file";
96
- import { LocalProvider } from "./.gen/providers/local/provider";
97
- class MyConvertedCode extends TerraformStack {
98
- constructor(scope: Construct, name: string) {
99
- super(scope, name);
100
- new RemoteBackend(this, {
101
- organization: "example_corp",
102
- workspaces: [
103
- {
104
- name: "my-app-prod",
105
- },
106
- ],
107
- });
108
- /*Terraform Variables are not always the best fit for getting inputs in the context of Terraform CDK.
109
- You can read more about this at https://cdktn.io/docs/concepts/variables-and-outputs#input-variables*/
110
- new GoogleProvider(this, "google", {
111
- project: "my-project",
112
- region: "us-central1",
113
- });
114
- new LocalProvider(this, "local", {});
115
- const imageId = new TerraformVariable(this, "image_id", {
116
- type: VariableType.STRING,
117
- });
118
- const cdktnTerraformOutputImageId = new TerraformOutput(
119
- this,
120
- "image_id_3",
121
- {
122
- value: imageId.value,
123
- }
124
- );
125
- /*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
126
- cdktnTerraformOutputImageId.overrideLogicalId("image_id");
127
- /*In most cases loops should be handled in the programming language context and
128
- not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
129
- you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
130
- you need to keep this like it is.*/
131
- const exampleCount = TerraformCount.of(Token.asNumber("2"));
132
- new ComputeAutoscaler(this, "example", {
133
- autoscalingPolicy: {
134
- cooldownPeriod: 60,
135
- cpuUtilization: {
136
- target: 0.5,
137
- },
138
- maxReplicas: 8,
139
- minReplicas: 2,
140
- },
141
- name: "example-autoscaler",
142
- target: "target-for-example-autoscaler",
143
- zone: "us-east1-b",
144
- count: exampleCount,
145
- });
146
- const defaultVar = new ComputeInstanceGroupManager(this, "default", {
147
- baseInstanceName: "autoscaler-sample",
148
- name: "my-igm",
149
- targetPools: [],
150
- version: [
151
- {
152
- instanceTemplate: Token.asString(1),
153
- name: "primary",
154
- },
155
- ],
156
- zone: "us-central1-f",
157
- });
158
- new DataLocalFile(this, "foo", {
159
- filename: "./\${" + imageId.value + "}.img",
160
- });
161
- const googleComputeAutoscalerDefault = new ComputeAutoscaler(
162
- this,
163
- "default_7",
164
- {
165
- autoscalingPolicy: {
166
- cooldownPeriod: 60,
167
- maxReplicas: Token.asNumber(Op.add(5, 2)),
168
- minReplicas: 1,
169
- },
170
- name: "my-autoscaler",
171
- target: defaultVar.id,
172
- zone: "us-central1-f",
173
- }
174
- );
175
- /*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
176
- googleComputeAutoscalerDefault.overrideLogicalId("default");
177
- }
178
- }
179
- "
180
- `;
@@ -1,159 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`imports Not supported import into expansion (for_each or count) snapshot typescript 1`] = `
4
- "import { Construct } from "constructs";
5
- import { 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 { AwsProvider } from "./.gen/providers/aws/provider";
11
- class MyConvertedCode extends TerraformStack {
12
- constructor(scope: Construct, name: string) {
13
- super(scope, name);
14
- new AwsProvider(this, "aws", {
15
- region: "us-east-1",
16
- });
17
- /*CDKTN does not support imports into resources with count or for_each yet, please remove the import block importing i-abcd123457 into aws_instance.example[0] from your configuration*/
18
- /*CDKTN does not support imports into resources with count or for_each yet, please remove the import block importing i-abcd1234 into aws_instance.example["foo"] from your configuration*/
19
- }
20
- }
21
- "
22
- `;
23
-
24
- exports[`imports Not supported import into module snapshot typescript 1`] = `
25
- "import { Construct } from "constructs";
26
- import { TerraformStack } from "cdktn";
27
- /*
28
- * Provider bindings are generated by running \`cdktn get\`.
29
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
30
- */
31
- import { AwsProvider } from "./.gen/providers/aws/provider";
32
- class MyConvertedCode extends TerraformStack {
33
- constructor(scope: Construct, name: string) {
34
- super(scope, name);
35
- new AwsProvider(this, "aws", {
36
- region: "us-east-1",
37
- });
38
- /*CDKTN does not support imports into modules yet, please remove the import block importing i-abcd1234 into module.instances.aws_instance.example from your configuration*/
39
- }
40
- }
41
- "
42
- `;
43
-
44
- exports[`imports import with config and provider snapshot typescript 1`] = `
45
- "import { Construct } from "constructs";
46
- import { TerraformStack } from "cdktn";
47
- /*
48
- * Provider bindings are generated by running \`cdktn get\`.
49
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
50
- */
51
- import { Instance } from "./.gen/providers/aws/instance";
52
- import { AwsProvider } from "./.gen/providers/aws/provider";
53
- class MyConvertedCode extends TerraformStack {
54
- constructor(scope: Construct, name: string) {
55
- super(scope, name);
56
- new AwsProvider(this, "aws", {
57
- alias: "us",
58
- region: "us-east-1",
59
- });
60
- const example = new Instance(this, "example", {
61
- ami: "some-ami",
62
- instanceType: "t3.micro",
63
- });
64
- /*This import was configured with a provider. CDKTN does support this, but the cdktn convert command does not yet. Please add the provider reference manually. See https://cdktn.io/docs/concepts/resources#importing-resources for more information.*/
65
- example.importFrom("i-abcd1234");
66
- }
67
- }
68
- "
69
- `;
70
-
71
- exports[`imports import with config snapshot typescript 1`] = `
72
- "import { Construct } from "constructs";
73
- import { TerraformStack } from "cdktn";
74
- /*
75
- * Provider bindings are generated by running \`cdktn get\`.
76
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
77
- */
78
- import { Instance } from "./.gen/providers/aws/instance";
79
- import { AwsProvider } from "./.gen/providers/aws/provider";
80
- class MyConvertedCode extends TerraformStack {
81
- constructor(scope: Construct, name: string) {
82
- super(scope, name);
83
- new AwsProvider(this, "aws", {
84
- region: "us-east-1",
85
- });
86
- const example = new Instance(this, "example", {
87
- ami: "some-ami",
88
- instanceType: "t3.micro",
89
- });
90
- example.importFrom("i-abcd1234");
91
- }
92
- }
93
- "
94
- `;
95
-
96
- exports[`imports multiple imports snapshot typescript 1`] = `
97
- "import { Construct } from "constructs";
98
- import { TerraformStack } from "cdktn";
99
- /*
100
- * Provider bindings are generated by running \`cdktn get\`.
101
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
102
- */
103
- import { Instance } from "./.gen/providers/aws/instance";
104
- import { AwsProvider } from "./.gen/providers/aws/provider";
105
- class MyConvertedCode extends TerraformStack {
106
- constructor(scope: Construct, name: string) {
107
- super(scope, name);
108
- new AwsProvider(this, "aws", {
109
- region: "us-east-1",
110
- });
111
- Instance.generateConfigForImport(this, "example", "i-abcd1234");
112
- Instance.generateConfigForImport(this, "toBeImported", "i-abcd1234567");
113
- }
114
- }
115
- "
116
- `;
117
-
118
- exports[`imports single import snapshot typescript 1`] = `
119
- "import { Construct } from "constructs";
120
- import { TerraformStack } from "cdktn";
121
- /*
122
- * Provider bindings are generated by running \`cdktn get\`.
123
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
124
- */
125
- import { Instance } from "./.gen/providers/aws/instance";
126
- import { AwsProvider } from "./.gen/providers/aws/provider";
127
- class MyConvertedCode extends TerraformStack {
128
- constructor(scope: Construct, name: string) {
129
- super(scope, name);
130
- new AwsProvider(this, "aws", {
131
- region: "us-east-1",
132
- });
133
- Instance.generateConfigForImport(this, "example", "i-abcd1234");
134
- }
135
- }
136
- "
137
- `;
138
-
139
- exports[`imports single import with provider snapshot typescript 1`] = `
140
- "import { Construct } from "constructs";
141
- import { TerraformStack } from "cdktn";
142
- /*
143
- * Provider bindings are generated by running \`cdktn get\`.
144
- * See https://cdktn.io/docs/concepts/providers#import-providers for more details.
145
- */
146
- import { Instance } from "./.gen/providers/aws/instance";
147
- import { AwsProvider } from "./.gen/providers/aws/provider";
148
- class MyConvertedCode extends TerraformStack {
149
- constructor(scope: Construct, name: string) {
150
- super(scope, name);
151
- new AwsProvider(this, "aws", {
152
- alias: "europe",
153
- region: "eu-west-1",
154
- });
155
- Instance.generateConfigForImport(this, "example", "i-abcd1234");
156
- }
157
- }
158
- "
159
- `;