@cdktn/cli-core 0.21.0

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 (154) hide show
  1. package/README.md +3 -0
  2. package/ambient.d.ts +13 -0
  3. package/eslint.config.mjs +82 -0
  4. package/jest.config.js +20 -0
  5. package/package.json +139 -0
  6. package/src/lib/cdktf-config.d.ts +16 -0
  7. package/src/lib/cdktf-config.d.ts.map +1 -0
  8. package/src/lib/cdktf-config.js +108 -0
  9. package/src/lib/cdktf-project-io-handler.d.ts +20 -0
  10. package/src/lib/cdktf-project-io-handler.d.ts.map +1 -0
  11. package/src/lib/cdktf-project-io-handler.js +84 -0
  12. package/src/lib/cdktf-project.d.ts +111 -0
  13. package/src/lib/cdktf-project.d.ts.map +1 -0
  14. package/src/lib/cdktf-project.js +371 -0
  15. package/src/lib/cdktf-stack.d.ts +134 -0
  16. package/src/lib/cdktf-stack.d.ts.map +1 -0
  17. package/src/lib/cdktf-stack.js +386 -0
  18. package/src/lib/convert.d.ts +6 -0
  19. package/src/lib/convert.d.ts.map +1 -0
  20. package/src/lib/convert.js +51 -0
  21. package/src/lib/dependencies/cdktf-config-manager.d.ts +12 -0
  22. package/src/lib/dependencies/cdktf-config-manager.d.ts.map +1 -0
  23. package/src/lib/dependencies/cdktf-config-manager.js +36 -0
  24. package/src/lib/dependencies/dependency-manager.d.ts +95 -0
  25. package/src/lib/dependencies/dependency-manager.d.ts.map +1 -0
  26. package/src/lib/dependencies/dependency-manager.js +393 -0
  27. package/src/lib/dependencies/package-manager.d.ts +18 -0
  28. package/src/lib/dependencies/package-manager.d.ts.map +1 -0
  29. package/src/lib/dependencies/package-manager.js +581 -0
  30. package/src/lib/dependencies/prebuilt-providers.d.ts +23 -0
  31. package/src/lib/dependencies/prebuilt-providers.d.ts.map +1 -0
  32. package/src/lib/dependencies/prebuilt-providers.js +220 -0
  33. package/src/lib/dependencies/registry-api.d.ts +8 -0
  34. package/src/lib/dependencies/registry-api.d.ts.map +1 -0
  35. package/src/lib/dependencies/registry-api.js +77 -0
  36. package/src/lib/dependencies/version-constraints.d.ts +8 -0
  37. package/src/lib/dependencies/version-constraints.d.ts.map +1 -0
  38. package/src/lib/dependencies/version-constraints.js +95 -0
  39. package/src/lib/error-reporting.d.ts +10 -0
  40. package/src/lib/error-reporting.d.ts.map +1 -0
  41. package/src/lib/error-reporting.js +133 -0
  42. package/src/lib/errors.d.ts +6 -0
  43. package/src/lib/errors.d.ts.map +1 -0
  44. package/src/lib/errors.js +10 -0
  45. package/src/lib/execution-logs.d.ts +3 -0
  46. package/src/lib/execution-logs.d.ts.map +1 -0
  47. package/src/lib/execution-logs.js +47 -0
  48. package/src/lib/get.d.ts +25 -0
  49. package/src/lib/get.d.ts.map +1 -0
  50. package/src/lib/get.js +90 -0
  51. package/src/lib/helpers/stack-helpers.d.ts +16 -0
  52. package/src/lib/helpers/stack-helpers.d.ts.map +1 -0
  53. package/src/lib/helpers/stack-helpers.js +155 -0
  54. package/src/lib/index.d.ts +15 -0
  55. package/src/lib/index.d.ts.map +1 -0
  56. package/src/lib/index.js +44 -0
  57. package/src/lib/init.d.ts +37 -0
  58. package/src/lib/init.d.ts.map +1 -0
  59. package/src/lib/init.js +131 -0
  60. package/src/lib/local-provider-constraints.d.ts +28 -0
  61. package/src/lib/local-provider-constraints.d.ts.map +1 -0
  62. package/src/lib/local-provider-constraints.js +95 -0
  63. package/src/lib/local-provider-versions.d.ts +12 -0
  64. package/src/lib/local-provider-versions.d.ts.map +1 -0
  65. package/src/lib/local-provider-versions.js +73 -0
  66. package/src/lib/models/deploy-machine.d.ts +128 -0
  67. package/src/lib/models/deploy-machine.d.ts.map +1 -0
  68. package/src/lib/models/deploy-machine.js +280 -0
  69. package/src/lib/models/pty-process.d.ts +29 -0
  70. package/src/lib/models/pty-process.d.ts.map +1 -0
  71. package/src/lib/models/pty-process.js +132 -0
  72. package/src/lib/models/schema.d.ts +2307 -0
  73. package/src/lib/models/schema.d.ts.map +1 -0
  74. package/src/lib/models/schema.js +181 -0
  75. package/src/lib/models/terraform-cli.d.ts +72 -0
  76. package/src/lib/models/terraform-cli.d.ts.map +1 -0
  77. package/src/lib/models/terraform-cli.js +357 -0
  78. package/src/lib/models/terraform.d.ts +125 -0
  79. package/src/lib/models/terraform.d.ts.map +1 -0
  80. package/src/lib/models/terraform.js +72 -0
  81. package/src/lib/output.d.ts +23 -0
  82. package/src/lib/output.d.ts.map +1 -0
  83. package/src/lib/output.js +211 -0
  84. package/src/lib/provider-add.d.ts +15 -0
  85. package/src/lib/provider-add.d.ts.map +1 -0
  86. package/src/lib/provider-add.js +30 -0
  87. package/src/lib/server/terraform-logs.d.ts +2 -0
  88. package/src/lib/server/terraform-logs.d.ts.map +1 -0
  89. package/src/lib/server/terraform-logs.js +19 -0
  90. package/src/lib/synth-stack.d.ts +29 -0
  91. package/src/lib/synth-stack.d.ts.map +1 -0
  92. package/src/lib/synth-stack.js +251 -0
  93. package/src/lib/synth.d.ts +7 -0
  94. package/src/lib/synth.d.ts.map +1 -0
  95. package/src/lib/synth.js +67 -0
  96. package/src/lib/terraform-json.d.ts +1015 -0
  97. package/src/lib/terraform-json.d.ts.map +1 -0
  98. package/src/lib/terraform-json.js +82 -0
  99. package/src/lib/terraform-provider-lock.d.ts +25 -0
  100. package/src/lib/terraform-provider-lock.d.ts.map +1 -0
  101. package/src/lib/terraform-provider-lock.js +95 -0
  102. package/src/lib/watch.d.ts +16 -0
  103. package/src/lib/watch.d.ts.map +1 -0
  104. package/src/lib/watch.js +155 -0
  105. package/templates/csharp/.hooks.sscaff.js +63 -0
  106. package/templates/csharp/MainStack.cs +15 -0
  107. package/templates/csharp/MyTerraformStack.csproj +13 -0
  108. package/templates/csharp/Program.cs +17 -0
  109. package/templates/csharp/TestProgram.cs +42 -0
  110. package/templates/csharp/cdktf.json +11 -0
  111. package/templates/csharp/help +42 -0
  112. package/templates/csharp/{{}}.gitignore +345 -0
  113. package/templates/go/.hooks.sscaff.js +70 -0
  114. package/templates/go/cdktf.json +12 -0
  115. package/templates/go/go.mod +8 -0
  116. package/templates/go/help +32 -0
  117. package/templates/go/main.go +22 -0
  118. package/templates/go/main_test.go +42 -0
  119. package/templates/go/{{}}.gitignore +21 -0
  120. package/templates/java/.hooks.sscaff.js +64 -0
  121. package/templates/java/build.gradle +55 -0
  122. package/templates/java/cdktf.json +12 -0
  123. package/templates/java/gradle.properties +1 -0
  124. package/templates/java/gradlew +248 -0
  125. package/templates/java/gradlew.bat +92 -0
  126. package/templates/java/help +35 -0
  127. package/templates/java/settings.gradle +5 -0
  128. package/templates/java/src/main/java/com/mycompany/app/Main.java +16 -0
  129. package/templates/java/src/main/java/com/mycompany/app/MainStack.java +14 -0
  130. package/templates/java/src/test/java/com/company/app/MainTest.java +38 -0
  131. package/templates/java/{{}}.gitignore +14 -0
  132. package/templates/python/.hooks.sscaff.js +59 -0
  133. package/templates/python/Pipfile +7 -0
  134. package/templates/python/cdktf.json +12 -0
  135. package/templates/python/help +42 -0
  136. package/templates/python/main-test.py +26 -0
  137. package/templates/python/main.py +16 -0
  138. package/templates/python/{{}}.gitignore +7 -0
  139. package/templates/python-pip/.hooks.sscaff.js +63 -0
  140. package/templates/python-pip/cdktf.json +12 -0
  141. package/templates/python-pip/help +35 -0
  142. package/templates/python-pip/main-test.py +23 -0
  143. package/templates/python-pip/main.py +16 -0
  144. package/templates/python-pip/{{}}.gitignore +7 -0
  145. package/templates/typescript/.hooks.sscaff.js +78 -0
  146. package/templates/typescript/__tests__/main-test.ts +89 -0
  147. package/templates/typescript/cdktf.json +11 -0
  148. package/templates/typescript/help +51 -0
  149. package/templates/typescript/jest.config.js +187 -0
  150. package/templates/typescript/main.ts +14 -0
  151. package/templates/typescript/package.json +22 -0
  152. package/templates/typescript/setup.js +2 -0
  153. package/templates/typescript/tsconfig.json +35 -0
  154. package/templates/typescript/{{}}.gitignore +11 -0
@@ -0,0 +1,345 @@
1
+
2
+ # cdktn and terraform ignores
3
+ .terraform
4
+ cdktf.out
5
+ cdktf.log
6
+ *terraform.*.tfstate*
7
+
8
+ # Created by https://www.gitignore.io/api/csharp
9
+
10
+ ### Csharp ###
11
+ ## Ignore Visual Studio temporary files, build results, and
12
+ ## files generated by popular Visual Studio add-ons.
13
+ ##
14
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
15
+
16
+ # User-specific files
17
+ *.suo
18
+ *.user
19
+ *.userosscache
20
+ *.sln.docstates
21
+
22
+ # User-specific files (MonoDevelop/Xamarin Studio)
23
+ *.userprefs
24
+
25
+ # Build results
26
+ [Dd]ebug/
27
+ [Dd]ebugPublic/
28
+ [Rr]elease/
29
+ [Rr]eleases/
30
+ x64/
31
+ x86/
32
+ bld/
33
+ [Bb]in/
34
+ [Oo]bj/
35
+ [Ll]og/
36
+
37
+ # Visual Studio 2015/2017 cache/options directory
38
+ .vs/
39
+ # Uncomment if you have tasks that create the project's static files in wwwroot
40
+ #wwwroot/
41
+
42
+ # Visual Studio 2017 auto generated files
43
+ Generated\ Files/
44
+
45
+ # MSTest test Results
46
+ [Tt]est[Rr]esult*/
47
+ [Bb]uild[Ll]og.*
48
+
49
+ # NUNIT
50
+ *.VisualState.xml
51
+ TestResult.xml
52
+
53
+ # Build Results of an ATL Project
54
+ [Dd]ebugPS/
55
+ [Rr]eleasePS/
56
+ dlldata.c
57
+
58
+ # Benchmark Results
59
+ BenchmarkDotNet.Artifacts/
60
+
61
+ # .NET Core
62
+ project.lock.json
63
+ project.fragment.lock.json
64
+ artifacts/
65
+
66
+ # StyleCop
67
+ StyleCopReport.xml
68
+
69
+ # Files built by Visual Studio
70
+ *_i.c
71
+ *_p.c
72
+ *_i.h
73
+ *.ilk
74
+ *.meta
75
+ *.obj
76
+ *.iobj
77
+ *.pch
78
+ *.pdb
79
+ *.ipdb
80
+ *.pgc
81
+ *.pgd
82
+ *.rsp
83
+ *.sbr
84
+ *.tlb
85
+ *.tli
86
+ *.tlh
87
+ *.tmp
88
+ *.tmp_proj
89
+ *.log
90
+ *.vspscc
91
+ *.vssscc
92
+ .builds
93
+ *.pidb
94
+ *.svclog
95
+ *.scc
96
+
97
+ # Chutzpah Test files
98
+ _Chutzpah*
99
+
100
+ # Visual C++ cache files
101
+ ipch/
102
+ *.aps
103
+ *.ncb
104
+ *.opendb
105
+ *.opensdf
106
+ *.sdf
107
+ *.cachefile
108
+ *.VC.db
109
+ *.VC.VC.opendb
110
+
111
+ # Visual Studio profiler
112
+ *.psess
113
+ *.vsp
114
+ *.vspx
115
+ *.sap
116
+
117
+ # Visual Studio Trace Files
118
+ *.e2e
119
+
120
+ # TFS 2012 Local Workspace
121
+ $tf/
122
+
123
+ # Guidance Automation Toolkit
124
+ *.gpState
125
+
126
+ # ReSharper is a .NET coding add-in
127
+ _ReSharper*/
128
+ *.[Rr]e[Ss]harper
129
+ *.DotSettings.user
130
+
131
+ # JustCode is a .NET coding add-in
132
+ .JustCode
133
+
134
+ # TeamCity is a build add-in
135
+ _TeamCity*
136
+
137
+ # DotCover is a Code Coverage Tool
138
+ *.dotCover
139
+
140
+ # AxoCover is a Code Coverage Tool
141
+ .axoCover/*
142
+ !.axoCover/settings.json
143
+
144
+ # Visual Studio code coverage results
145
+ *.coverage
146
+ *.coveragexml
147
+
148
+ # NCrunch
149
+ _NCrunch_*
150
+ .*crunch*.local.xml
151
+ nCrunchTemp_*
152
+
153
+ # MightyMoose
154
+ *.mm.*
155
+ AutoTest.Net/
156
+
157
+ # Web workbench (sass)
158
+ .sass-cache/
159
+
160
+ # Installshield output folder
161
+ [Ee]xpress/
162
+
163
+ # DocProject is a documentation generator add-in
164
+ DocProject/buildhelp/
165
+ DocProject/Help/*.HxT
166
+ DocProject/Help/*.HxC
167
+ DocProject/Help/*.hhc
168
+ DocProject/Help/*.hhk
169
+ DocProject/Help/*.hhp
170
+ DocProject/Help/Html2
171
+ DocProject/Help/html
172
+
173
+ # Click-Once directory
174
+ publish/
175
+
176
+ # Publish Web Output
177
+ *.[Pp]ublish.xml
178
+ *.azurePubxml
179
+ # Note: Comment the next line if you want to checkin your web deploy settings,
180
+ # but database connection strings (with potential passwords) will be unencrypted
181
+ *.pubxml
182
+ *.publishproj
183
+
184
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
185
+ # checkin your Azure Web App publish settings, but sensitive information contained
186
+ # in these scripts will be unencrypted
187
+ PublishScripts/
188
+
189
+ # NuGet Packages
190
+ *.nupkg
191
+ # The packages folder can be ignored because of Package Restore
192
+ **/[Pp]ackages/*
193
+ # except build/, which is used as an MSBuild target.
194
+ !**/[Pp]ackages/build/
195
+ # Uncomment if necessary however generally it will be regenerated when needed
196
+ #!**/[Pp]ackages/repositories.config
197
+ # NuGet v3's project.json files produces more ignorable files
198
+ *.nuget.props
199
+ *.nuget.targets
200
+
201
+ # Microsoft Azure Build Output
202
+ csx/
203
+ *.build.csdef
204
+
205
+ # Microsoft Azure Emulator
206
+ ecf/
207
+ rcf/
208
+
209
+ # Windows Store app package directories and files
210
+ AppPackages/
211
+ BundleArtifacts/
212
+ Package.StoreAssociation.xml
213
+ _pkginfo.txt
214
+ *.appx
215
+
216
+ # Visual Studio cache files
217
+ # files ending in .cache can be ignored
218
+ *.[Cc]ache
219
+ # but keep track of directories ending in .cache
220
+ !*.[Cc]ache/
221
+
222
+ # Others
223
+ ClientBin/
224
+ ~$*
225
+ *~
226
+ *.dbmdl
227
+ *.dbproj.schemaview
228
+ *.jfm
229
+ *.pfx
230
+ *.publishsettings
231
+ orleans.codegen.cs
232
+
233
+ # Including strong name files can present a security risk
234
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235
+ #*.snk
236
+
237
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
238
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239
+ #bower_components/
240
+
241
+ # RIA/Silverlight projects
242
+ Generated_Code/
243
+
244
+ # Backup & report files from converting an old project file
245
+ # to a newer Visual Studio version. Backup files are not needed,
246
+ # because we have git ;-)
247
+ _UpgradeReport_Files/
248
+ Backup*/
249
+ UpgradeLog*.XML
250
+ UpgradeLog*.htm
251
+ ServiceFabricBackup/
252
+ *.rptproj.bak
253
+
254
+ # SQL Server files
255
+ *.mdf
256
+ *.ldf
257
+ *.ndf
258
+
259
+ # Business Intelligence projects
260
+ *.rdl.data
261
+ *.bim.layout
262
+ *.bim_*.settings
263
+ *.rptproj.rsuser
264
+
265
+ # Microsoft Fakes
266
+ FakesAssemblies/
267
+
268
+ # GhostDoc plugin setting file
269
+ *.GhostDoc.xml
270
+
271
+ # Node.js Tools for Visual Studio
272
+ .ntvs_analysis.dat
273
+ node_modules/
274
+
275
+ # Visual Studio 6 build log
276
+ *.plg
277
+
278
+ # Visual Studio 6 workspace options file
279
+ *.opt
280
+
281
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
282
+ *.vbw
283
+
284
+ # Visual Studio LightSwitch build output
285
+ **/*.HTMLClient/GeneratedArtifacts
286
+ **/*.DesktopClient/GeneratedArtifacts
287
+ **/*.DesktopClient/ModelManifest.xml
288
+ **/*.Server/GeneratedArtifacts
289
+ **/*.Server/ModelManifest.xml
290
+ _Pvt_Extensions
291
+
292
+ # Paket dependency manager
293
+ .paket/paket.exe
294
+ paket-files/
295
+
296
+ # FAKE - F# Make
297
+ .fake/
298
+
299
+ # JetBrains Rider
300
+ .idea/
301
+ *.sln.iml
302
+
303
+ # CodeRush
304
+ .cr/
305
+
306
+ # Python Tools for Visual Studio (PTVS)
307
+ __pycache__/
308
+ *.pyc
309
+
310
+ # Cake - Uncomment if you are using it
311
+ # tools/**
312
+ # !tools/packages.config
313
+
314
+ # Tabs Studio
315
+ *.tss
316
+
317
+ # Telerik's JustMock configuration file
318
+ *.jmconfig
319
+
320
+ # BizTalk build output
321
+ *.btp.cs
322
+ *.btm.cs
323
+ *.odx.cs
324
+ *.xsd.cs
325
+
326
+ # OpenCover UI analysis results
327
+ OpenCover/
328
+
329
+ # Azure Stream Analytics local run output
330
+ ASALocalRun/
331
+
332
+ # MSBuild Binary and Structured Log
333
+ *.binlog
334
+
335
+ # NVidia Nsight GPU debugger configuration file
336
+ *.nvuser
337
+
338
+ # MFractors (Xamarin productivity tool) working folder
339
+ .mfractor/
340
+
341
+ # Local History for Visual Studio
342
+ .localhistory/
343
+
344
+
345
+ # End of https://www.gitignore.io/api/csharp
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ const { execSync } = require('child_process');
7
+ const { readFileSync, writeFileSync } = require('fs');
8
+ const { readFile } = require('fs-extra');
9
+ const os = require('os');
10
+
11
+ exports.pre = (variables) => {
12
+ try {
13
+ if (os.platform() === 'win32') {
14
+ execSync('where go')
15
+ }
16
+ else {
17
+ execSync('which go')
18
+ }
19
+ } catch {
20
+ console.error(`Unable to find "go" installation. Install from https://golang.org/dl/`);
21
+ process.exit(1);
22
+ }
23
+ // remove caret (^) from constructs_version as Go needs a specific version
24
+ variables.constructs_version = variables.constructs_version.replace('^', '');
25
+ };
26
+
27
+ exports.post = options => {
28
+ const { go_cdktf, cdktf_version } = options;
29
+ if (!go_cdktf) {
30
+ throw new Error(`missing context "go_cdktf"`);
31
+ }
32
+
33
+ // Terraform Cloud configuration settings if the organization name and workspace is set.
34
+ if (options.OrganizationName != '') {
35
+ console.log(`\nGenerating Terraform Cloud configuration for '${options.OrganizationName}' organization and '${options.WorkspaceName}' workspace.....`)
36
+ terraformCloudConfig(options.$base, options.OrganizationName, options.WorkspaceName, options.TerraformRemoteHostname)
37
+ }
38
+
39
+ // dist package
40
+ if (go_cdktf.endsWith('cdktn')) {
41
+ const gomod = readFileSync('./go.mod', 'utf-8');
42
+
43
+ // set the version of the package to the version of the CDKTN CLI as the package itself
44
+ // will be replaced and have no version on its own
45
+ let result = gomod.replace(go_cdktf, `v${cdktf_version}`);
46
+ result += `\n\nreplace github.com/open-constructs/cdk-terrain-go/cdktn => ${go_cdktf}\n`;
47
+
48
+ writeFileSync('./go.mod', result, 'utf-8');
49
+ }
50
+
51
+ execSync(`go get`, { stdio: 'inherit' });
52
+
53
+ console.log(readFileSync('./help', 'utf-8'));
54
+ };
55
+
56
+ function terraformCloudConfig(baseName, organizationName, workspaceName, terraformRemoteHostname) {
57
+ template = readFileSync('./main.go', 'utf-8');
58
+
59
+ result = template.replace(`NewMyStack(app, "${baseName}")`, `stack := NewMyStack(app, "${baseName}")
60
+ cdktn.NewCloudBackend(stack, &cdktn.CloudBackendConfig{
61
+ Hostname: jsii.String("${terraformRemoteHostname}"),
62
+ Organization: jsii.String("${organizationName}"),
63
+ Workspaces: cdktn.NewNamedCloudWorkspace(jsii.String("${workspaceName}"), nil),
64
+ })`);
65
+
66
+ // add import for jsii helper used above
67
+ result = result.replace(`"github.com/aws/constructs-go/constructs/v10"`, `"github.com/aws/constructs-go/constructs/v10"\n "github.com/aws/jsii-runtime-go"`);
68
+
69
+ writeFileSync('./main.go', result, 'utf-8');
70
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "language": "go",
3
+ "app": "go run main.go",
4
+ "codeMakerOutput": "generated",
5
+ "projectId": "{{projectId}}",
6
+ "sendCrashReports": "{{sendCrashReports}}",
7
+ "terraformProviders": [],
8
+ "terraformModules": [],
9
+ "context": {
10
+ {{futureFlags}}
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ module cdk.tf/go/stack
2
+
3
+ go 1.18
4
+
5
+ require github.com/aws/constructs-go/constructs/v10 v{{ constructs_version }}
6
+
7
+ require github.com/open-constructs/cdk-terrain-go/cdktn {{ go_cdktf }}
8
+ require github.com/aws/jsii-runtime-go v1.67.0
@@ -0,0 +1,32 @@
1
+ ========================================================================================================
2
+
3
+ Your cdktn go project is ready!
4
+
5
+ cat help Prints this message
6
+
7
+ Compile:
8
+ go build Builds your go project
9
+
10
+ Synthesize:
11
+ cdktn synth [stack] Synthesize Terraform resources to cdktf.out/
12
+
13
+ Diff:
14
+ cdktn diff [stack] Perform a diff (terraform plan) for the given stack
15
+
16
+ Deploy:
17
+ cdktn deploy [stack] Deploy the given stack
18
+
19
+ Destroy:
20
+ cdktn destroy [stack] Destroy the given stack
21
+
22
+ Learn more about using modules and providers https://cdk.tf/modules-and-providers
23
+
24
+ Use Providers:
25
+
26
+ Use the add command to add providers:
27
+
28
+ cdktn provider add "aws@~>3.0" null kreuzwerker/docker
29
+
30
+ Learn more: https://cdk.tf/modules-and-providers
31
+
32
+ ========================================================================================================
@@ -0,0 +1,22 @@
1
+ package main
2
+
3
+ import (
4
+ "github.com/aws/constructs-go/constructs/v10"
5
+ "github.com/open-constructs/cdk-terrain-go/cdktn"
6
+ )
7
+
8
+ func NewMyStack(scope constructs.Construct, id string) cdktn.TerraformStack {
9
+ stack := cdktn.NewTerraformStack(scope, &id)
10
+
11
+ // The code that defines your stack goes here
12
+
13
+ return stack
14
+ }
15
+
16
+ func main() {
17
+ app := cdktn.NewApp(nil)
18
+
19
+ NewMyStack(app, "{{ $base }}")
20
+
21
+ app.Synth()
22
+ }
@@ -0,0 +1,42 @@
1
+ package main
2
+
3
+ import (
4
+ "github.com/aws/jsii-runtime-go"
5
+ "github.com/open-constructs/cdk-terrain-go/cdktn"
6
+ "testing"
7
+ )
8
+
9
+ // The tests below are example tests, you can find more information at
10
+ // https://cdk.tf/testing
11
+
12
+ /*
13
+ var stack = NewMyApplicationsAbstraction(cdktn.Testing_App(nil), "stack")
14
+ var synth = cdktn.Testing_Synth(stack)
15
+
16
+ func TestShouldContainContainer(t *testing.T){
17
+ assertion := cdktn.Testing_ToHaveResource(synth, docker.Container_TfResourceType())
18
+
19
+ if !*assertion {
20
+ t.Error("Assertion Failed")
21
+ }
22
+ }
23
+
24
+ func TestShouldUseUbuntuImage(t *testing.T){
25
+ properties := map[string]interface{}{
26
+ "name": "ubuntu:latest",
27
+ }
28
+ assertion := cdktn.Testing_ToHaveResourceWithProperties(synth, docker.Image_TfResourceType(), &properties)
29
+
30
+ if !*assertion {
31
+ t.Error("Assertion Failed")
32
+ }
33
+ }
34
+
35
+ func TestCheckValidity(t *testing.T){
36
+ assertion := cdktn.Testing_ToBeValidTerraform(cdktn.Testing_FullSynth(stack))
37
+
38
+ if !*assertion {
39
+ t.Error("Assertion Failed")
40
+ }
41
+ }
42
+ */
@@ -0,0 +1,21 @@
1
+
2
+ # cdktn and terraform ignores
3
+ .terraform
4
+ cdktf.out
5
+ cdktf.log
6
+ *terraform.*.tfstate*
7
+ generated
8
+
9
+ # src https://github.com/github/gitignore/blob/master/Go.gitignore
10
+ # Binaries for programs and plugins
11
+ *.exe
12
+ *.exe~
13
+ *.dll
14
+ *.so
15
+ *.dylib
16
+
17
+ # Test binary, built with `go test -c`
18
+ *.test
19
+
20
+ # Output of the go coverage tool, specifically when used with LiteIDE
21
+ *.out
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ const { execSync } = require('child_process');
7
+ const { readFileSync, writeFileSync } = require('fs');
8
+ const os = require('os');
9
+
10
+ exports.pre = (variables) => {
11
+ try {
12
+ if (os.platform() === 'win32') {
13
+ execSync('where gradle')
14
+ }
15
+ else {
16
+ execSync('which gradle')
17
+ }
18
+ } catch {
19
+ console.error(`Unable to find "gradle". Install from https://maven.apache.org/install.html`);
20
+ process.exit(1);
21
+ }
22
+ variables.constructs_version = variables.constructs_version.replace('^', '').replace('~', '');
23
+ };
24
+
25
+ exports.post = options => {
26
+ const { mvn_cdktf, cdktf_version } = options;
27
+ if (!mvn_cdktf) {
28
+ throw new Error(`missing context "mvn_cdktf"`);
29
+ }
30
+
31
+ // Terraform Cloud configuration settings if the organization name and workspace is set.
32
+ if (options.OrganizationName != '') {
33
+ console.log(`\nGenerating Terraform Cloud configuration for '${options.OrganizationName}' organization and '${options.WorkspaceName}' workspace.....`)
34
+ terraformCloudConfig(options.$base, options.OrganizationName, options.WorkspaceName, options.TerraformRemoteHostname)
35
+ }
36
+
37
+ // This is used for installing artifacts that are local (not from Maven)
38
+ // https://maven.apache.org/plugins/maven-install-plugin/usage.html
39
+ if (mvn_cdktf.endsWith('.jar')) {
40
+ writeFileSync('./build.gradle',
41
+ readFileSync('./build.gradle', 'utf-8').replace(
42
+ `implementation "io.cdktn:cdktn:${cdktf_version}"`,
43
+ `implementation files("${mvn_cdktf.replaceAll('\\', '/')}")`
44
+ )
45
+ );
46
+ }
47
+
48
+ execSync(`gradle wrapper`, { stdio: 'inherit' });
49
+ execSync(`./gradlew install`, { stdio: 'inherit' });
50
+ console.log(readFileSync('./help', 'utf-8'));
51
+ };
52
+
53
+ function terraformCloudConfig(baseName, organizationName, workspaceName, terraformRemoteHostname) {
54
+ template = readFileSync('./src/main/java/com/mycompany/app/Main.java', 'utf-8');
55
+
56
+ result = template.replace(`import io.cdktn.cdktn.App;`, `import io.cdktn.cdktn.App;
57
+ import io.cdktn.cdktn.NamedCloudWorkspace;
58
+ import io.cdktn.cdktn.CloudBackend;
59
+ import io.cdktn.cdktn.CloudBackendConfig;`);
60
+ result = result.replace(`new MainStack(app, "${baseName}");`, `MainStack stack = new MainStack(app, "${baseName}");
61
+ new CloudBackend(stack, CloudBackendConfig.builder().hostname("${terraformRemoteHostname}").organization("${organizationName}").workspaces(new NamedCloudWorkspace("${workspaceName}")).build());`);
62
+
63
+ writeFileSync('./src/main/java/com/mycompany/app/Main.java', result, 'utf-8');
64
+ }
@@ -0,0 +1,55 @@
1
+ plugins {
2
+ id "application"
3
+ id "java-library"
4
+ id "maven-publish"
5
+ }
6
+ apply plugin : "java"
7
+ ext {
8
+ javaMainClass = "com.mycompany.app.Main"
9
+ }
10
+
11
+ application {
12
+ mainClassName = javaMainClass
13
+ }
14
+
15
+ repositories {
16
+ mavenLocal()
17
+ maven {
18
+ url = uri("https://repo.maven.apache.org/maven2/")
19
+ }
20
+ }
21
+
22
+ dependencies {
23
+ implementation "io.cdktn:cdktn:{{ cdktf_version }}"
24
+ implementation "software.constructs:constructs:{{ constructs_version }}"
25
+ testImplementation "junit:junit:4.13.2"
26
+ testImplementation "org.junit.jupiter:junit-jupiter:5.8.0"
27
+ }
28
+
29
+ group = "com.mycompany.app"
30
+ version = "0.1"
31
+ description = "{{ $base }}"
32
+ java.sourceCompatibility = JavaVersion.VERSION_1_8
33
+
34
+
35
+
36
+ publishing {
37
+ publications {
38
+ maven(MavenPublication) {
39
+ from(components.java)
40
+ }
41
+ }
42
+ }
43
+
44
+ tasks.withType(JavaCompile) {
45
+ options.encoding = "UTF-8"
46
+ }
47
+
48
+ tasks.withType(Javadoc) {
49
+ options.encoding = "UTF-8"
50
+ }
51
+
52
+ test {
53
+ useJUnit()
54
+ useJUnitPlatform()
55
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "language": "java",
3
+ "app": "./gradlew run",
4
+ "projectId": "{{projectId}}",
5
+ "sendCrashReports": "{{sendCrashReports}}",
6
+ "codeMakerOutput": "imports",
7
+ "terraformProviders": [],
8
+ "terraformModules": [],
9
+ "context": {
10
+ {{futureFlags}}
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ org.gradle.jvmargs=-Xmx4096m