aws-cdk 0.0.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 (402) hide show
  1. package/CONTRIBUTING.md +276 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +16 -0
  4. package/README.md +1274 -0
  5. package/THIRD_PARTY_LICENSES +26821 -0
  6. package/bin/cdk +6 -0
  7. package/build-info.json +4 -0
  8. package/db.json.gz +0 -0
  9. package/generate.sh +25 -0
  10. package/images/garbage-collection.png +0 -0
  11. package/lib/api/aws-auth/account-cache.d.ts +39 -0
  12. package/lib/api/aws-auth/account-cache.js +102 -0
  13. package/lib/api/aws-auth/awscli-compatible.d.ts +42 -0
  14. package/lib/api/aws-auth/awscli-compatible.js +264 -0
  15. package/lib/api/aws-auth/cached.d.ts +11 -0
  16. package/lib/api/aws-auth/cached.js +26 -0
  17. package/lib/api/aws-auth/credential-plugins.d.ts +36 -0
  18. package/lib/api/aws-auth/credential-plugins.js +153 -0
  19. package/lib/api/aws-auth/index.d.ts +3 -0
  20. package/lib/api/aws-auth/index.js +20 -0
  21. package/lib/api/aws-auth/provider-caching.d.ts +13 -0
  22. package/lib/api/aws-auth/provider-caching.js +24 -0
  23. package/lib/api/aws-auth/sdk-logger.d.ts +69 -0
  24. package/lib/api/aws-auth/sdk-logger.js +130 -0
  25. package/lib/api/aws-auth/sdk-provider.d.ts +207 -0
  26. package/lib/api/aws-auth/sdk-provider.js +359 -0
  27. package/lib/api/aws-auth/sdk.d.ts +223 -0
  28. package/lib/api/aws-auth/sdk.js +366 -0
  29. package/lib/api/aws-auth/tracing.d.ts +11 -0
  30. package/lib/api/aws-auth/tracing.js +61 -0
  31. package/lib/api/aws-auth/user-agent.d.ts +7 -0
  32. package/lib/api/aws-auth/user-agent.js +21 -0
  33. package/lib/api/aws-auth/util.d.ts +6 -0
  34. package/lib/api/aws-auth/util.js +23 -0
  35. package/lib/api/bootstrap/bootstrap-environment.d.ts +33 -0
  36. package/lib/api/bootstrap/bootstrap-environment.js +322 -0
  37. package/lib/api/bootstrap/bootstrap-props.d.ts +130 -0
  38. package/lib/api/bootstrap/bootstrap-props.js +14 -0
  39. package/lib/api/bootstrap/bootstrap-template.yaml +692 -0
  40. package/lib/api/bootstrap/deploy-bootstrap.d.ts +37 -0
  41. package/lib/api/bootstrap/deploy-bootstrap.js +143 -0
  42. package/lib/api/bootstrap/index.d.ts +2 -0
  43. package/lib/api/bootstrap/index.js +19 -0
  44. package/lib/api/bootstrap/legacy-template.d.ts +2 -0
  45. package/lib/api/bootstrap/legacy-template.js +82 -0
  46. package/lib/api/context.d.ts +40 -0
  47. package/lib/api/context.js +82 -0
  48. package/lib/api/cxapp/cloud-assembly.d.ts +150 -0
  49. package/lib/api/cxapp/cloud-assembly.js +305 -0
  50. package/lib/api/cxapp/cloud-executable.d.ts +44 -0
  51. package/lib/api/cxapp/cloud-executable.js +90 -0
  52. package/lib/api/cxapp/environments.d.ts +9 -0
  53. package/lib/api/cxapp/environments.js +66 -0
  54. package/lib/api/cxapp/exec.d.ts +56 -0
  55. package/lib/api/cxapp/exec.js +275 -0
  56. package/lib/api/deployments/asset-manifest-builder.d.ts +8 -0
  57. package/lib/api/deployments/asset-manifest-builder.js +35 -0
  58. package/lib/api/deployments/asset-publishing.d.ts +77 -0
  59. package/lib/api/deployments/asset-publishing.js +163 -0
  60. package/lib/api/deployments/assets.d.ts +10 -0
  61. package/lib/api/deployments/assets.js +111 -0
  62. package/lib/api/deployments/checks.d.ts +8 -0
  63. package/lib/api/deployments/checks.js +73 -0
  64. package/lib/api/deployments/cloudformation.d.ts +235 -0
  65. package/lib/api/deployments/cloudformation.js +598 -0
  66. package/lib/api/deployments/deploy-stack.d.ts +177 -0
  67. package/lib/api/deployments/deploy-stack.js +484 -0
  68. package/lib/api/deployments/deployment-method.d.ts +24 -0
  69. package/lib/api/deployments/deployment-method.js +3 -0
  70. package/lib/api/deployments/deployment-result.d.ts +21 -0
  71. package/lib/api/deployments/deployment-result.js +10 -0
  72. package/lib/api/deployments/deployments.d.ts +340 -0
  73. package/lib/api/deployments/deployments.js +369 -0
  74. package/lib/api/deployments/hotswap-deployments.d.ts +14 -0
  75. package/lib/api/deployments/hotswap-deployments.js +357 -0
  76. package/lib/api/deployments/index.d.ts +6 -0
  77. package/lib/api/deployments/index.js +23 -0
  78. package/lib/api/deployments/nested-stack-helpers.d.ts +25 -0
  79. package/lib/api/deployments/nested-stack-helpers.js +88 -0
  80. package/lib/api/environment-access.d.ts +138 -0
  81. package/lib/api/environment-access.js +203 -0
  82. package/lib/api/environment-resources.d.ts +73 -0
  83. package/lib/api/environment-resources.js +208 -0
  84. package/lib/api/evaluate-cloudformation-template.d.ts +84 -0
  85. package/lib/api/evaluate-cloudformation-template.js +443 -0
  86. package/lib/api/garbage-collection/garbage-collector.d.ts +152 -0
  87. package/lib/api/garbage-collection/garbage-collector.js +607 -0
  88. package/lib/api/garbage-collection/progress-printer.d.ts +21 -0
  89. package/lib/api/garbage-collection/progress-printer.js +69 -0
  90. package/lib/api/garbage-collection/stack-refresh.d.ts +44 -0
  91. package/lib/api/garbage-collection/stack-refresh.js +154 -0
  92. package/lib/api/hotswap/appsync-mapping-templates.d.ts +3 -0
  93. package/lib/api/hotswap/appsync-mapping-templates.js +157 -0
  94. package/lib/api/hotswap/code-build-projects.d.ts +3 -0
  95. package/lib/api/hotswap/code-build-projects.js +55 -0
  96. package/lib/api/hotswap/common.d.ts +126 -0
  97. package/lib/api/hotswap/common.js +170 -0
  98. package/lib/api/hotswap/ecs-services.d.ts +3 -0
  99. package/lib/api/hotswap/ecs-services.js +140 -0
  100. package/lib/api/hotswap/lambda-functions.d.ts +3 -0
  101. package/lib/api/hotswap/lambda-functions.js +309 -0
  102. package/lib/api/hotswap/s3-bucket-deployments.d.ts +9 -0
  103. package/lib/api/hotswap/s3-bucket-deployments.js +112 -0
  104. package/lib/api/hotswap/stepfunctions-state-machines.d.ts +3 -0
  105. package/lib/api/hotswap/stepfunctions-state-machines.js +42 -0
  106. package/lib/api/index.d.ts +5 -0
  107. package/lib/api/index.js +22 -0
  108. package/lib/api/logs/find-cloudwatch-logs.d.ts +24 -0
  109. package/lib/api/logs/find-cloudwatch-logs.js +97 -0
  110. package/lib/api/logs/logs-monitor.d.ts +53 -0
  111. package/lib/api/logs/logs-monitor.js +169 -0
  112. package/lib/api/plugin/context-provider-plugin.d.ts +6 -0
  113. package/lib/api/plugin/context-provider-plugin.js +7 -0
  114. package/lib/api/plugin/index.d.ts +3 -0
  115. package/lib/api/plugin/index.js +20 -0
  116. package/lib/api/plugin/mode.d.ts +4 -0
  117. package/lib/api/plugin/mode.js +9 -0
  118. package/lib/api/plugin/plugin.d.ts +63 -0
  119. package/lib/api/plugin/plugin.js +106 -0
  120. package/lib/api/settings.d.ts +29 -0
  121. package/lib/api/settings.js +141 -0
  122. package/lib/api/tags.d.ts +9 -0
  123. package/lib/api/tags.js +10 -0
  124. package/lib/api/toolkit-info.d.ts +51 -0
  125. package/lib/api/toolkit-info.js +156 -0
  126. package/lib/api/util/cloudformation/stack-activity-monitor.d.ts +237 -0
  127. package/lib/api/util/cloudformation/stack-activity-monitor.js +550 -0
  128. package/lib/api/util/cloudformation/stack-event-poller.d.ts +63 -0
  129. package/lib/api/util/cloudformation/stack-event-poller.js +129 -0
  130. package/lib/api/util/cloudformation/stack-status.d.ts +42 -0
  131. package/lib/api/util/cloudformation/stack-status.js +88 -0
  132. package/lib/api/util/display.d.ts +13 -0
  133. package/lib/api/util/display.js +80 -0
  134. package/lib/api/util/placeholders.d.ts +10 -0
  135. package/lib/api/util/placeholders.js +24 -0
  136. package/lib/api/util/rwlock.d.ts +65 -0
  137. package/lib/api/util/rwlock.js +179 -0
  138. package/lib/api/util/string-manipulation.d.ts +10 -0
  139. package/lib/api/util/string-manipulation.js +33 -0
  140. package/lib/api/util/template-body-parameter.d.ts +21 -0
  141. package/lib/api/util/template-body-parameter.js +104 -0
  142. package/lib/cli/cdk-toolkit.d.ts +594 -0
  143. package/lib/cli/cdk-toolkit.js +1019 -0
  144. package/lib/cli/cli-config.d.ts +10 -0
  145. package/lib/cli/cli-config.js +406 -0
  146. package/lib/cli/cli.d.ts +4 -0
  147. package/lib/cli/cli.js +538 -0
  148. package/lib/cli/convert-to-user-input.d.ts +3 -0
  149. package/lib/cli/convert-to-user-input.js +434 -0
  150. package/lib/cli/parse-command-line-arguments.d.ts +1 -0
  151. package/lib/cli/parse-command-line-arguments.js +806 -0
  152. package/lib/cli/platform-warnings.d.ts +2 -0
  153. package/lib/cli/platform-warnings.js +45 -0
  154. package/lib/cli/user-configuration.d.ts +90 -0
  155. package/lib/cli/user-configuration.js +272 -0
  156. package/lib/cli/user-input.d.ts +1163 -0
  157. package/lib/cli/user-input.js +3 -0
  158. package/lib/cli/util/console-formatters.d.ts +18 -0
  159. package/lib/cli/util/console-formatters.js +42 -0
  160. package/lib/cli/util/npm.d.ts +1 -0
  161. package/lib/cli/util/npm.js +22 -0
  162. package/lib/cli/util/yargs-helpers.d.ts +22 -0
  163. package/lib/cli/util/yargs-helpers.js +49 -0
  164. package/lib/cli/version.d.ts +13 -0
  165. package/lib/cli/version.js +120 -0
  166. package/lib/commands/context.d.ts +35 -0
  167. package/lib/commands/context.js +156 -0
  168. package/lib/commands/docs.d.ts +13 -0
  169. package/lib/commands/docs.js +32 -0
  170. package/lib/commands/doctor.d.ts +1 -0
  171. package/lib/commands/doctor.js +69 -0
  172. package/lib/commands/migrate.d.ts +327 -0
  173. package/lib/commands/migrate.js +804 -0
  174. package/lib/context-providers/ami.d.ts +11 -0
  175. package/lib/context-providers/ami.js +50 -0
  176. package/lib/context-providers/availability-zones.d.ts +11 -0
  177. package/lib/context-providers/availability-zones.js +27 -0
  178. package/lib/context-providers/endpoint-service-availability-zones.d.ts +11 -0
  179. package/lib/context-providers/endpoint-service-availability-zones.js +33 -0
  180. package/lib/context-providers/hosted-zones.d.ts +10 -0
  181. package/lib/context-providers/hosted-zones.js +67 -0
  182. package/lib/context-providers/index.d.ts +30 -0
  183. package/lib/context-providers/index.js +109 -0
  184. package/lib/context-providers/keys.d.ts +11 -0
  185. package/lib/context-providers/keys.js +52 -0
  186. package/lib/context-providers/load-balancers.d.ts +20 -0
  187. package/lib/context-providers/load-balancers.js +159 -0
  188. package/lib/context-providers/security-groups.d.ts +9 -0
  189. package/lib/context-providers/security-groups.js +70 -0
  190. package/lib/context-providers/ssm-parameters.d.ts +23 -0
  191. package/lib/context-providers/ssm-parameters.js +59 -0
  192. package/lib/context-providers/vpcs.d.ts +11 -0
  193. package/lib/context-providers/vpcs.js +288 -0
  194. package/lib/diff.d.ts +28 -0
  195. package/lib/diff.js +165 -0
  196. package/lib/import.d.ts +182 -0
  197. package/lib/import.js +335 -0
  198. package/lib/index.d.ts +3 -0
  199. package/lib/index.js +348304 -0
  200. package/lib/index_bg.wasm +0 -0
  201. package/lib/init-hooks.d.ts +40 -0
  202. package/lib/init-hooks.js +64 -0
  203. package/lib/init-templates/.init-version.json +1 -0
  204. package/lib/init-templates/.no-packagejson-validator +0 -0
  205. package/lib/init-templates/.recommended-feature-flags.json +68 -0
  206. package/lib/init-templates/LICENSE +16 -0
  207. package/lib/init-templates/app/csharp/.template.gitignore +342 -0
  208. package/lib/init-templates/app/csharp/README.md +14 -0
  209. package/lib/init-templates/app/csharp/cdk.template.json +15 -0
  210. package/lib/init-templates/app/csharp/src/%name.PascalCased%/%name.PascalCased%.template.csproj +20 -0
  211. package/lib/init-templates/app/csharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.cs +13 -0
  212. package/lib/init-templates/app/csharp/src/%name.PascalCased%/GlobalSuppressions.cs +1 -0
  213. package/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs +44 -0
  214. package/lib/init-templates/app/csharp/src/%name.PascalCased%.template.sln +18 -0
  215. package/lib/init-templates/app/fsharp/.template.gitignore +342 -0
  216. package/lib/init-templates/app/fsharp/README.md +18 -0
  217. package/lib/init-templates/app/fsharp/cdk.template.json +14 -0
  218. package/lib/init-templates/app/fsharp/src/%name.PascalCased%/%name.PascalCased%.template.fsproj +25 -0
  219. package/lib/init-templates/app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs +8 -0
  220. package/lib/init-templates/app/fsharp/src/%name.PascalCased%/Program.template.fs +11 -0
  221. package/lib/init-templates/app/fsharp/src/%name.PascalCased%.template.sln +18 -0
  222. package/lib/init-templates/app/go/%name%.template.go +70 -0
  223. package/lib/init-templates/app/go/%name%_test.template.go +26 -0
  224. package/lib/init-templates/app/go/.template.gitignore +19 -0
  225. package/lib/init-templates/app/go/README.md +12 -0
  226. package/lib/init-templates/app/go/cdk.template.json +13 -0
  227. package/lib/init-templates/app/go/go.template.mod +9 -0
  228. package/lib/init-templates/app/info.json +4 -0
  229. package/lib/init-templates/app/java/.template.gitignore +13 -0
  230. package/lib/init-templates/app/java/README.md +18 -0
  231. package/lib/init-templates/app/java/cdk.json +13 -0
  232. package/lib/init-templates/app/java/pom.xml +60 -0
  233. package/lib/init-templates/app/java/src/main/java/com/myorg/%name.PascalCased%App.template.java +42 -0
  234. package/lib/init-templates/app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +24 -0
  235. package/lib/init-templates/app/java/src/test/java/com/myorg/%name.PascalCased%Test.template.java +26 -0
  236. package/lib/init-templates/app/javascript/.template.gitignore +5 -0
  237. package/lib/init-templates/app/javascript/.template.npmignore +3 -0
  238. package/lib/init-templates/app/javascript/README.md +12 -0
  239. package/lib/init-templates/app/javascript/bin/%name%.template.js +21 -0
  240. package/lib/init-templates/app/javascript/cdk.template.json +15 -0
  241. package/lib/init-templates/app/javascript/jest.config.js +3 -0
  242. package/lib/init-templates/app/javascript/lib/%name%-stack.template.js +23 -0
  243. package/lib/init-templates/app/javascript/package.json +20 -0
  244. package/lib/init-templates/app/javascript/test/%name%.test.template.js +17 -0
  245. package/lib/init-templates/app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +19 -0
  246. package/lib/init-templates/app/python/%name.PythonModule%/__init__.py +0 -0
  247. package/lib/init-templates/app/python/.template.gitignore +10 -0
  248. package/lib/init-templates/app/python/README.template.md +58 -0
  249. package/lib/init-templates/app/python/app.template.py +28 -0
  250. package/lib/init-templates/app/python/cdk.template.json +15 -0
  251. package/lib/init-templates/app/python/requirements-dev.txt +1 -0
  252. package/lib/init-templates/app/python/requirements.txt +2 -0
  253. package/lib/init-templates/app/python/source.bat +13 -0
  254. package/lib/init-templates/app/python/tests/__init__.py +0 -0
  255. package/lib/init-templates/app/python/tests/unit/__init__.py +0 -0
  256. package/lib/init-templates/app/python/tests/unit/test_%name.PythonModule%_stack.template.py +15 -0
  257. package/lib/init-templates/app/typescript/.template.gitignore +8 -0
  258. package/lib/init-templates/app/typescript/.template.npmignore +6 -0
  259. package/lib/init-templates/app/typescript/README.md +14 -0
  260. package/lib/init-templates/app/typescript/bin/%name%.template.ts +20 -0
  261. package/lib/init-templates/app/typescript/cdk.template.json +17 -0
  262. package/lib/init-templates/app/typescript/jest.config.js +8 -0
  263. package/lib/init-templates/app/typescript/lib/%name%-stack.template.ts +16 -0
  264. package/lib/init-templates/app/typescript/package.json +26 -0
  265. package/lib/init-templates/app/typescript/test/%name%.test.template.ts +17 -0
  266. package/lib/init-templates/app/typescript/tsconfig.json +31 -0
  267. package/lib/init-templates/lib/info.json +4 -0
  268. package/lib/init-templates/lib/typescript/.template.gitignore +8 -0
  269. package/lib/init-templates/lib/typescript/.template.npmignore +6 -0
  270. package/lib/init-templates/lib/typescript/README.template.md +12 -0
  271. package/lib/init-templates/lib/typescript/jest.config.js +8 -0
  272. package/lib/init-templates/lib/typescript/lib/index.template.ts +21 -0
  273. package/lib/init-templates/lib/typescript/package.json +24 -0
  274. package/lib/init-templates/lib/typescript/test/%name%.test.template.ts +18 -0
  275. package/lib/init-templates/lib/typescript/tsconfig.json +31 -0
  276. package/lib/init-templates/sample-app/csharp/.template.gitignore +342 -0
  277. package/lib/init-templates/sample-app/csharp/README.template.md +19 -0
  278. package/lib/init-templates/sample-app/csharp/cdk.template.json +15 -0
  279. package/lib/init-templates/sample-app/csharp/src/%name.PascalCased%/%name.PascalCased%.template.csproj +20 -0
  280. package/lib/init-templates/sample-app/csharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.cs +24 -0
  281. package/lib/init-templates/sample-app/csharp/src/%name.PascalCased%/GlobalSuppressions.cs +1 -0
  282. package/lib/init-templates/sample-app/csharp/src/%name.PascalCased%/Program.template.cs +15 -0
  283. package/lib/init-templates/sample-app/csharp/src/%name.PascalCased%.template.sln +18 -0
  284. package/lib/init-templates/sample-app/fsharp/.template.gitignore +342 -0
  285. package/lib/init-templates/sample-app/fsharp/README.template.md +20 -0
  286. package/lib/init-templates/sample-app/fsharp/cdk.template.json +14 -0
  287. package/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%.template.fsproj +25 -0
  288. package/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs +14 -0
  289. package/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/Program.template.fs +11 -0
  290. package/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%.template.sln +18 -0
  291. package/lib/init-templates/sample-app/go/%name%.template.go +73 -0
  292. package/lib/init-templates/sample-app/go/%name%_test.template.go +25 -0
  293. package/lib/init-templates/sample-app/go/.template.gitignore +19 -0
  294. package/lib/init-templates/sample-app/go/README.md +12 -0
  295. package/lib/init-templates/sample-app/go/cdk.template.json +13 -0
  296. package/lib/init-templates/sample-app/go/go.template.mod +9 -0
  297. package/lib/init-templates/sample-app/info.json +4 -0
  298. package/lib/init-templates/sample-app/java/.template.gitignore +13 -0
  299. package/lib/init-templates/sample-app/java/README.template.md +19 -0
  300. package/lib/init-templates/sample-app/java/cdk.json +13 -0
  301. package/lib/init-templates/sample-app/java/pom.xml +55 -0
  302. package/lib/init-templates/sample-app/java/src/main/java/com/myorg/%name.PascalCased%App.template.java +13 -0
  303. package/lib/init-templates/sample-app/java/src/main/java/com/myorg/%name.PascalCased%Stack.template.java +29 -0
  304. package/lib/init-templates/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +27 -0
  305. package/lib/init-templates/sample-app/javascript/.template.gitignore +5 -0
  306. package/lib/init-templates/sample-app/javascript/.template.npmignore +3 -0
  307. package/lib/init-templates/sample-app/javascript/README.template.md +13 -0
  308. package/lib/init-templates/sample-app/javascript/bin/%name%.template.js +6 -0
  309. package/lib/init-templates/sample-app/javascript/cdk.template.json +15 -0
  310. package/lib/init-templates/sample-app/javascript/jest.config.js +3 -0
  311. package/lib/init-templates/sample-app/javascript/lib/%name%-stack.template.js +25 -0
  312. package/lib/init-templates/sample-app/javascript/package.json +20 -0
  313. package/lib/init-templates/sample-app/javascript/test/%name%.test.template.js +16 -0
  314. package/lib/init-templates/sample-app/javascript/tsconfig.json +34 -0
  315. package/lib/init-templates/sample-app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py +26 -0
  316. package/lib/init-templates/sample-app/python/%name.PythonModule%/__init__.py +0 -0
  317. package/lib/init-templates/sample-app/python/.template.gitignore +22 -0
  318. package/lib/init-templates/sample-app/python/README.template.md +65 -0
  319. package/lib/init-templates/sample-app/python/app.template.py +11 -0
  320. package/lib/init-templates/sample-app/python/cdk.template.json +15 -0
  321. package/lib/init-templates/sample-app/python/requirements-dev.txt +1 -0
  322. package/lib/init-templates/sample-app/python/requirements.txt +2 -0
  323. package/lib/init-templates/sample-app/python/source.bat +13 -0
  324. package/lib/init-templates/sample-app/python/tests/__init__.py +0 -0
  325. package/lib/init-templates/sample-app/python/tests/unit/__init__.py +0 -0
  326. package/lib/init-templates/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py +21 -0
  327. package/lib/init-templates/sample-app/typescript/.template.gitignore +8 -0
  328. package/lib/init-templates/sample-app/typescript/.template.npmignore +6 -0
  329. package/lib/init-templates/sample-app/typescript/README.template.md +15 -0
  330. package/lib/init-templates/sample-app/typescript/bin/%name%.template.ts +6 -0
  331. package/lib/init-templates/sample-app/typescript/cdk.template.json +17 -0
  332. package/lib/init-templates/sample-app/typescript/jest.config.js +8 -0
  333. package/lib/init-templates/sample-app/typescript/lib/%name%-stack.template.ts +19 -0
  334. package/lib/init-templates/sample-app/typescript/package.json +26 -0
  335. package/lib/init-templates/sample-app/typescript/test/%name%.test.template.ts +17 -0
  336. package/lib/init-templates/sample-app/typescript/tsconfig.json +31 -0
  337. package/lib/init.d.ts +52 -0
  338. package/lib/init.js +430 -0
  339. package/lib/legacy-exports-source.d.ts +27 -0
  340. package/lib/legacy-exports-source.js +88 -0
  341. package/lib/legacy-exports.d.ts +10 -0
  342. package/lib/legacy-exports.js +28 -0
  343. package/lib/legacy-logging-source.d.ts +32 -0
  344. package/lib/legacy-logging-source.js +107 -0
  345. package/lib/list-stacks.d.ts +22 -0
  346. package/lib/list-stacks.js +23 -0
  347. package/lib/logging.d.ts +109 -0
  348. package/lib/logging.js +159 -0
  349. package/lib/migrator.d.ts +25 -0
  350. package/lib/migrator.js +67 -0
  351. package/lib/notices.d.ts +156 -0
  352. package/lib/notices.js +373 -0
  353. package/lib/os.d.ts +7 -0
  354. package/lib/os.js +92 -0
  355. package/lib/serialize.d.ts +27 -0
  356. package/lib/serialize.js +86 -0
  357. package/lib/toolkit/cli-io-host.d.ts +208 -0
  358. package/lib/toolkit/cli-io-host.js +282 -0
  359. package/lib/toolkit/error.d.ts +44 -0
  360. package/lib/toolkit/error.js +78 -0
  361. package/lib/tree.d.ts +31 -0
  362. package/lib/tree.js +40 -0
  363. package/lib/util/archive.d.ts +1 -0
  364. package/lib/util/archive.js +86 -0
  365. package/lib/util/arrays.d.ts +14 -0
  366. package/lib/util/arrays.js +36 -0
  367. package/lib/util/bool.d.ts +7 -0
  368. package/lib/util/bool.js +13 -0
  369. package/lib/util/bytes.d.ts +8 -0
  370. package/lib/util/bytes.js +21 -0
  371. package/lib/util/content-hash.d.ts +5 -0
  372. package/lib/util/content-hash.js +43 -0
  373. package/lib/util/directories.d.ts +23 -0
  374. package/lib/util/directories.js +57 -0
  375. package/lib/util/error.d.ts +9 -0
  376. package/lib/util/error.js +22 -0
  377. package/lib/util/index.d.ts +5 -0
  378. package/lib/util/index.js +22 -0
  379. package/lib/util/objects.d.ts +52 -0
  380. package/lib/util/objects.js +183 -0
  381. package/lib/util/parallel.d.ts +6 -0
  382. package/lib/util/parallel.js +44 -0
  383. package/lib/util/tables.d.ts +1 -0
  384. package/lib/util/tables.js +10 -0
  385. package/lib/util/type-brands.d.ts +39 -0
  386. package/lib/util/type-brands.js +38 -0
  387. package/lib/util/types.d.ts +27 -0
  388. package/lib/util/types.js +25 -0
  389. package/lib/util/validate-notification-arn.d.ts +4 -0
  390. package/lib/util/validate-notification-arn.js +10 -0
  391. package/lib/util/version-range.d.ts +2 -0
  392. package/lib/util/version-range.js +36 -0
  393. package/lib/util/work-graph-builder.d.ts +32 -0
  394. package/lib/util/work-graph-builder.js +167 -0
  395. package/lib/util/work-graph-types.d.ts +50 -0
  396. package/lib/util/work-graph-types.js +14 -0
  397. package/lib/util/work-graph.d.ts +70 -0
  398. package/lib/util/work-graph.js +344 -0
  399. package/lib/util/yaml-cfn.d.ts +15 -0
  400. package/lib/util/yaml-cfn.js +56 -0
  401. package/package.json +197 -0
  402. package/scripts/user-input-gen +2 -0
package/README.md ADDED
@@ -0,0 +1,1274 @@
1
+ # AWS CDK Toolkit
2
+ <!--BEGIN STABILITY BANNER-->
3
+
4
+ ---
5
+
6
+ ![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)
7
+
8
+ ---
9
+
10
+ <!--END STABILITY BANNER-->
11
+
12
+ The AWS CDK Toolkit provides the `cdk` command-line interface that can be used to work with AWS CDK applications.
13
+
14
+ | Command | Description |
15
+ | ------------------------------------- | ---------------------------------------------------------------------------------- |
16
+ | [`cdk docs`](#cdk-docs) | Access the online documentation |
17
+ | [`cdk init`](#cdk-init) | Start a new CDK project (app or library) |
18
+ | [`cdk list`](#cdk-list) | List stacks and their dependencies in an application |
19
+ | [`cdk synth`](#cdk-synthesize) | Synthesize a CDK app to CloudFormation template(s) |
20
+ | [`cdk diff`](#cdk-diff) | Diff stacks against current state |
21
+ | [`cdk deploy`](#cdk-deploy) | Deploy a stack into an AWS account |
22
+ | [`cdk rollback`](#cdk-rollback) | Roll back a failed deployment |
23
+ | [`cdk import`](#cdk-import) | Import existing AWS resources into a CDK stack |
24
+ | [`cdk migrate`](#cdk-migrate) | Migrate AWS resources, CloudFormation stacks, and CloudFormation templates to CDK |
25
+ | [`cdk watch`](#cdk-watch) | Watches a CDK app for deployable and hotswappable changes |
26
+ | [`cdk destroy`](#cdk-destroy) | Deletes a stack from an AWS account |
27
+ | [`cdk bootstrap`](#cdk-bootstrap) | Deploy a toolkit stack to support deploying large stacks & artifacts |
28
+ | [`cdk gc`](#cdk-gc) | Garbage collect assets associated with the bootstrapped stack |
29
+ | [`cdk doctor`](#cdk-doctor) | Inspect the environment and produce information useful for troubleshooting |
30
+ | [`cdk acknowledge`](#cdk-acknowledge) | Acknowledge (and hide) a notice by issue number |
31
+ | [`cdk notices`](#cdk-notices) | List all relevant notices for the application |
32
+
33
+ - [Bundling](#bundling)
34
+ - [MFA Support](#mfa-support)
35
+ - [SSO Support](#sso-support)
36
+ - [Configuration](#configuration)
37
+ - [Running in CI](#running-in-ci)
38
+
39
+
40
+ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
41
+
42
+ ## Commands
43
+
44
+ ### `cdk docs`
45
+
46
+ Outputs the URL to the documentation for the current toolkit version, and attempts to open a browser to that URL.
47
+
48
+ ```console
49
+ $ # Open the documentation in the default browser (using 'open')
50
+ $ cdk docs
51
+ https://docs.aws.amazon.com/cdk/api/latest/
52
+
53
+ $ # Open the documentation in Chrome.
54
+ $ cdk docs --browser='chrome %u'
55
+ https://docs.aws.amazon.com/cdk/api/latest/
56
+ ```
57
+
58
+ ### `cdk init`
59
+
60
+ Creates a new CDK project.
61
+
62
+ ```console
63
+ $ # List the available template types & languages
64
+ $ cdk init --list
65
+ Available templates:
66
+ * app: Template for a CDK Application
67
+ └─ cdk init app --language=[csharp|fsharp|java|javascript|python|typescript]
68
+ * lib: Template for a CDK Construct Library
69
+ └─ cdk init lib --language=typescript
70
+ * sample-app: Example CDK Application with some constructs
71
+ └─ cdk init sample-app --language=[csharp|fsharp|java|javascript|python|typescript]
72
+
73
+ $ # Create a new library application in typescript
74
+ $ cdk init lib --language=typescript
75
+ ```
76
+
77
+ ### `cdk list`
78
+
79
+ Lists the stacks and their dependencies modeled in the CDK app.
80
+
81
+ ```console
82
+ $ # List all stacks in the CDK app 'node bin/main.js'
83
+ $ cdk list --app='node bin/main.js'
84
+ Foo
85
+ Bar
86
+ Baz
87
+
88
+ $ # List all stack including all details (add --json to output JSON instead of YAML)
89
+ $ cdk list --app='node bin/main.js' --long
90
+ -
91
+ name: Foo
92
+ environment:
93
+ name: 000000000000/bermuda-triangle-1
94
+ account: '000000000000'
95
+ region: bermuda-triangle-1
96
+ -
97
+ name: Bar
98
+ environment:
99
+ name: 111111111111/bermuda-triangle-2
100
+ account: '111111111111'
101
+ region: bermuda-triangle-2
102
+ -
103
+ name: Baz
104
+ environment:
105
+ name: 333333333333/bermuda-triangle-3
106
+ account: '333333333333'
107
+ region: bermuda-triangle-3
108
+ ```
109
+
110
+ ### `cdk synthesize`
111
+
112
+ Synthesizes the CDK app and produces a cloud assembly to a designated output (defaults to `cdk.out`)
113
+
114
+ Typically you don't interact directly with cloud assemblies. They are files that include everything
115
+ needed to deploy your app to a cloud environment. For example, it includes an AWS CloudFormation
116
+ template for each stack in your app, and a copy of any file assets or Docker images that you reference
117
+ in your app.
118
+
119
+ If your app contains a single stack or a stack is supplied as an argument to `cdk synth`, the CloudFormation template will also be displayed in the standard output (STDOUT) as `YAML`.
120
+
121
+ If there are multiple stacks in your application, `cdk synth` will synthesize the cloud assembly to `cdk.out`.
122
+
123
+ ```console
124
+ $ # Synthesize cloud assembly for StackName and output the CloudFormation template to STDOUT
125
+ $ cdk synth MyStackName
126
+
127
+ $ # Synthesize cloud assembly for all the stacks and save them into cdk.out/
128
+ $ cdk synth
129
+
130
+ $ # Synthesize cloud assembly for StackName, but don't include dependencies
131
+ $ cdk synth MyStackName --exclusively
132
+
133
+ $ # Synthesize cloud assembly for StackName, but don't write CloudFormation template output to STDOUT
134
+ $ cdk synth MyStackName --quiet
135
+ ```
136
+
137
+ The `quiet` option can be set in the `cdk.json` file.
138
+
139
+ ```json
140
+ {
141
+ "quiet": true
142
+ }
143
+ ```
144
+
145
+ See the [AWS Documentation](https://docs.aws.amazon.com/cdk/latest/guide/apps.html#apps_cloud_assembly) to learn more about cloud assemblies.
146
+ See the [CDK reference documentation](https://docs.aws.amazon.com/cdk/api/latest/docs/cloud-assembly-schema-readme.html) for details on the cloud assembly specification
147
+
148
+
149
+ ### `cdk diff`
150
+
151
+ Computes differences between the infrastructure specified in the current state of the CDK app and the currently
152
+ deployed application (or a user-specified CloudFormation template). If you need the command to return a non-zero if any differences are
153
+ found you need to use the `--fail` command line option.
154
+
155
+ ```console
156
+ $ # Diff against the currently deployed stack
157
+ $ cdk diff --app='node bin/main.js' MyStackName
158
+
159
+ $ # Diff against a specific template document
160
+ $ cdk diff --app='node bin/main.js' MyStackName --template=path/to/template.yml
161
+ ```
162
+
163
+ The `quiet` flag can also be passed to the `cdk diff` command. Assuming there are no differences detected the output to the console will **not** contain strings such as the *Stack* `MyStackName` and `There were no differences`.
164
+
165
+ ```console
166
+ $ # Diff against the currently deployed stack with quiet parameter enabled
167
+ $ cdk diff --quiet --app='node bin/main.js' MyStackName
168
+ ```
169
+
170
+ Note that the CDK::Metadata resource and the `CheckBootstrapVersion` Rule are excluded from `cdk diff` by default. You can force `cdk diff` to display them by passing the `--strict` flag.
171
+
172
+ The `change-set` flag will make `diff` create a change set and extract resource replacement data from it. This is a bit slower, but will provide no false positives for resource replacement.
173
+ The `--no-change-set` mode will consider any change to a property that requires replacement to be a resource replacement,
174
+ even if the change is purely cosmetic (like replacing a resource reference with a hardcoded arn).
175
+
176
+ ### `cdk deploy`
177
+
178
+ Deploys a stack of your CDK app to its environment. During the deployment, the toolkit will output progress
179
+ indications, similar to what can be observed in the AWS CloudFormation Console. If the environment was never
180
+ bootstrapped (using `cdk bootstrap`), only stacks that are not using assets and synthesize to a template that is under
181
+ 51,200 bytes will successfully deploy.
182
+
183
+ ```console
184
+ $ cdk deploy --app='node bin/main.js' MyStackName
185
+ ```
186
+
187
+ Before creating a change set, `cdk deploy` will compare the template and tags of the
188
+ currently deployed stack to the template and tags that are about to be deployed and
189
+ will skip deployment if they are identical. Use `--force` to override this behavior
190
+ and always deploy the stack.
191
+
192
+ #### Disabling Rollback
193
+
194
+ If a resource fails to be created or updated, the deployment will *roll back* before the CLI returns. All changes made
195
+ up to that point will be undone (resources that were created will be deleted, updates that were made will be changed
196
+ back) in order to leave the stack in a consistent state at the end of the operation. If you are using the CDK CLI
197
+ to iterate on a development stack in your personal account, you might not require CloudFormation to leave your
198
+ stack in a consistent state, but instead would prefer to update your CDK application and try again.
199
+
200
+ To disable the rollback feature, specify `--no-rollback` (`-R` for short):
201
+
202
+ ```console
203
+ $ cdk deploy --no-rollback
204
+ $ cdk deploy -R
205
+ ```
206
+
207
+ If a deployment fails you can update your code and immediately retry the
208
+ deployment from the point of failure. If you would like to explicitly roll back
209
+ a failed, paused deployment, use `cdk rollback`.
210
+
211
+ `--no-rollback` deployments cannot contain resource replacements. If the CLI
212
+ detects that a resource is being replaced, it will prompt you to perform
213
+ a regular replacement instead. If the stack rollback is currently paused
214
+ and you are trying to perform an deployment that contains a replacement, you
215
+ will be prompted to roll back first.
216
+
217
+ #### Deploying multiple stacks
218
+
219
+ You can have multiple stacks in a cdk app. An example can be found in [how to create multiple stacks](https://docs.aws.amazon.com/cdk/latest/guide/stack_how_to_create_multiple_stacks.html).
220
+
221
+ In order to deploy them, you can list the stacks you want to deploy. If your application contains pipeline stacks, the `cdk list` command will show stack names as paths, showing where they are in the pipeline hierarchy (e.g., `PipelineStack`, `PipelineStack/Prod`, `PipelineStack/Prod/MyService` etc).
222
+
223
+ If you want to deploy all of them, you can use the flag `--all` or the wildcard `*` to deploy all stacks in an app. Please note that, if you have a hierarchy of stacks as described above, `--all` and `*` will only match the stacks on the top level. If you want to match all the stacks in the hierarchy, use `**`. You can also combine these patterns. For example, if you want to deploy all stacks in the `Prod` stage, you can use `cdk deploy PipelineStack/Prod/**`.
224
+
225
+ `--concurrency N` allows deploying multiple stacks in parallel while respecting inter-stack dependencies to speed up deployments. It does not protect against CloudFormation and other AWS account rate limiting.
226
+
227
+ #### Parameters
228
+
229
+ Pass parameters to your template during deployment by using `--parameters
230
+ (STACK:KEY=VALUE)`. This will apply the value `VALUE` to the key `KEY` for stack `STACK`.
231
+
232
+ Example of providing an attribute value for an SNS Topic through a parameter in TypeScript:
233
+
234
+ Usage of parameter in CDK Stack:
235
+
236
+ ```ts
237
+ new sns.Topic(this, 'TopicParameter', {
238
+ topicName: new cdk.CfnParameter(this, 'TopicNameParam').value.toString()
239
+ });
240
+ ```
241
+
242
+ Parameter values as a part of `cdk deploy`
243
+
244
+ ```console
245
+ $ cdk deploy --parameters "MyStackName:TopicNameParam=parameterized"
246
+ ```
247
+
248
+ Parameter values can be overwritten by supplying the `--force` flag.
249
+ Example of overwriting the topic name from a previous deployment.
250
+
251
+ ```console
252
+ $ cdk deploy --parameters "ParametersStack:TopicNameParam=blahagain" --force
253
+ ```
254
+
255
+ ⚠️ Parameters will be applied to all stacks if a stack name is not specified or `*` is provided.
256
+ Parameters provided to Stacks that do not make use of the parameter will not successfully deploy.
257
+
258
+ ⚠️ Parameters do not propagate to NestedStacks. These must be sent with the constructor.
259
+ See Nested Stack [documentation](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudformation.NestedStack.html)
260
+
261
+ #### Outputs
262
+
263
+ Write stack outputs from deployments into a file. When your stack finishes deploying, all stack outputs
264
+ will be written to the output file as JSON.
265
+
266
+ Usage of output in a CDK stack
267
+
268
+ ```ts
269
+ const fn = new lambda.Function(this, "fn", {
270
+ handler: "index.handler",
271
+ code: lambda.Code.fromInline(`exports.handler = \${handler.toString()}`),
272
+ runtime: lambda.Runtime.NODEJS_LATEST
273
+ });
274
+
275
+ new cdk.CfnOutput(this, 'FunctionArn', {
276
+ value: fn.functionArn,
277
+ });
278
+ ```
279
+
280
+ Specify an outputs file to write to by supplying the `--outputs-file` parameter
281
+
282
+ ```console
283
+ $ cdk deploy --outputs-file outputs.json
284
+ ```
285
+
286
+ Alternatively, the `outputsFile` key can be specified in the project config (`cdk.json`).
287
+
288
+ The following shows a sample `cdk.json` where the `outputsFile` key is set to *outputs.json*.
289
+
290
+ ```json
291
+ {
292
+ "app": "npx ts-node bin/myproject.ts",
293
+ "context": {
294
+ "@aws-cdk/core:enableStackNameDuplicates": "true",
295
+ "aws-cdk:enableDiffNoFail": "true",
296
+ "@aws-cdk/core:stackRelativeExports": "true"
297
+ },
298
+ "outputsFile": "outputs.json"
299
+ }
300
+ ```
301
+
302
+ The `outputsFile` key can also be specified as a user setting (`~/.cdk.json`)
303
+
304
+ When the stack finishes deployment, `outputs.json` would look like this:
305
+
306
+ ```json
307
+ {
308
+ "MyStack": {
309
+ "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:MyStack-fn5FF616E3-G632ITHSP5HK"
310
+ }
311
+ }
312
+ ```
313
+
314
+ ⚠️ The `key` of the outputs corresponds to the logical ID of the `CfnOutput`.
315
+ Read more about identifiers in the CDK [here](https://docs.aws.amazon.com/cdk/latest/guide/identifiers.html)
316
+
317
+ If multiple stacks are being deployed or the wild card `*` is used to deploy all stacks, all outputs
318
+ are written to the same output file where each stack artifact ID is a key in the JSON file
319
+
320
+
321
+ ```console
322
+ $ cdk deploy '**' --outputs-file "/Users/code/myproject/outputs.json"
323
+ ```
324
+
325
+ Example `outputs.json` after deployment of multiple stacks
326
+
327
+ ```json
328
+ {
329
+ "MyStack": {
330
+ "FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:MyStack-fn5FF616E3-G632ITHSP5HK"
331
+ },
332
+ "AnotherStack": {
333
+ "VPCId": "vpc-z0mg270fee16693f"
334
+ }
335
+ }
336
+ ```
337
+
338
+ #### Deployment Progress
339
+
340
+ By default, stack deployment events are displayed as a progress bar with the events for the resource
341
+ currently being deployed.
342
+
343
+ Set the `--progress` flag to request the complete history which includes all CloudFormation events
344
+
345
+ ```console
346
+ $ cdk deploy --progress events
347
+ ```
348
+
349
+ Alternatively, the `progress` key can be specified in the project config (`cdk.json`).
350
+
351
+ The following shows a sample `cdk.json` where the `progress` key is set to *events*.
352
+ When `cdk deploy` is executed, deployment events will include the complete history.
353
+
354
+ ```json
355
+ {
356
+ "app": "npx ts-node bin/myproject.ts",
357
+ "context": {
358
+ "@aws-cdk/core:enableStackNameDuplicates": "true",
359
+ "aws-cdk:enableDiffNoFail": "true",
360
+ "@aws-cdk/core:stackRelativeExports": "true"
361
+ },
362
+ "progress": "events"
363
+ }
364
+ ```
365
+
366
+ The `progress` key can also be specified as a user setting (`~/.cdk.json`)
367
+
368
+ #### CloudFormation Change Sets vs direct stack updates
369
+
370
+ By default, CDK creates a CloudFormation change set with the changes that will
371
+ be deployed and then executes it. This behavior can be controlled with the
372
+ `--method` parameter:
373
+
374
+ - `--method=change-set` (default): create and execute the change set.
375
+ - `--method=prepare-change-set`: create the change set but don't execute it.
376
+ This is useful if you have external tools that will inspect the change set or
377
+ you have an approval process for change sets.
378
+ - `--method=direct`: do not create a change set but apply the change immediately.
379
+ This is typically a bit faster than creating a change set, but it loses
380
+ the progress information.
381
+
382
+ To deploy faster without using change sets:
383
+
384
+ ```console
385
+ $ cdk deploy --method=direct
386
+ ```
387
+
388
+ If a change set is created, it will be called *cdk-deploy-change-set*, and a
389
+ previous change set with that name will be overwritten. The change set will
390
+ always be created, even if it is empty. A name can also be given to the change
391
+ set to make it easier to later execute:
392
+
393
+ ```console
394
+ $ cdk deploy --method=prepare-change-set --change-set-name MyChangeSetName
395
+ ```
396
+
397
+ For more control over when stack changes are deployed, the CDK can generate a
398
+ CloudFormation change set but not execute it.
399
+
400
+ #### Import existing resources
401
+
402
+ You can utilize the AWS CloudFormation
403
+ [feature](https://aws.amazon.com/about-aws/whats-new/2023/11/aws-cloudformation-import-parameter-changesets/)
404
+ that automatically imports resources in your template that already exist in your account.
405
+ To do so, pass the `--import-existing-resources` flag to the `deploy` command:
406
+
407
+ ```console
408
+ $ cdk deploy --import-existing-resources
409
+ ```
410
+
411
+ This automatically imports resources in your CDK application that represent
412
+ unmanaged resources in your account. It reduces the manual effort of import operations and
413
+ avoids deployment failures due to naming conflicts with unmanaged resources in your account.
414
+
415
+ Use the `--method=prepare-change-set` flag to review which resources are imported or not before deploying a changeset.
416
+ You can inspect the change set created by CDK from the management console or other external tools.
417
+
418
+ ```console
419
+ $ cdk deploy --import-existing-resources --method=prepare-change-set
420
+ ```
421
+
422
+ Use the `--exclusively` flag to enable this feature for a specific stack.
423
+
424
+ ```console
425
+ $ cdk deploy --import-existing-resources --exclusively StackName
426
+ ```
427
+
428
+ Only resources that have custom names can be imported using `--import-existing-resources`.
429
+ For more information, see [name type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html).
430
+ To import resources that do not accept custom names, such as EC2 instances,
431
+ use the `cdk import` instead.
432
+ Visit [Bringing existing resources into CloudFormation management](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html)
433
+ for more details.
434
+
435
+ #### Ignore No Stacks
436
+
437
+ You may have an app with multiple environments, e.g., dev and prod. When starting
438
+ development, your prod app may not have any resources or the resources are commented
439
+ out. In this scenario, you will receive an error message stating that the app has no
440
+ stacks.
441
+
442
+ To bypass this error messages, you can pass the `--ignore-no-stacks` flag to the
443
+ `deploy` command:
444
+
445
+ ```console
446
+ $ cdk deploy --ignore-no-stacks
447
+ ```
448
+
449
+ #### Hotswap deployments for faster development
450
+
451
+ You can pass the `--hotswap` flag to the `deploy` command:
452
+
453
+ ```console
454
+ $ cdk deploy --hotswap [StackNames]
455
+ ```
456
+
457
+ This will attempt to perform a faster, short-circuit deployment if possible
458
+ (for example, if you changed the code of a Lambda function in your CDK app),
459
+ skipping CloudFormation, and updating the affected resources directly;
460
+ this includes changes to resources in nested stacks.
461
+ If the tool detects that the change does not support hotswapping,
462
+ it will ignore it and display that ignored change.
463
+ To have hotswap fall back and perform a full CloudFormation deployment,
464
+ exactly like `cdk deploy` does without the `--hotswap` flag,
465
+ specify `--hotswap-fallback`, like so:
466
+
467
+ ```console
468
+ $ cdk deploy --hotswap-fallback [StackNames]
469
+ ```
470
+
471
+ Passing either option to `cdk deploy` will make it use your current AWS credentials to perform the API calls -
472
+ it will not assume the Roles from your bootstrap stack,
473
+ even if the `@aws-cdk/core:newStyleStackSynthesis` feature flag is set to `true`
474
+ (as those Roles do not have the necessary permissions to update AWS resources directly, without using CloudFormation).
475
+ For that reason, make sure that your credentials are for the same AWS account that the Stack(s)
476
+ you are performing the hotswap deployment for belong to,
477
+ and that you have the necessary IAM permissions to update the resources that are being deployed.
478
+
479
+ Hotswapping is currently supported for the following changes
480
+ (additional changes will be supported in the future):
481
+
482
+ - Code asset (including Docker image and inline code), tag changes, and configuration changes (only
483
+ description and environment variables are supported) of AWS Lambda functions.
484
+ - AWS Lambda Versions and Aliases changes.
485
+ - Definition changes of AWS Step Functions State Machines.
486
+ - Container asset changes of AWS ECS Services.
487
+ - Website asset changes of AWS S3 Bucket Deployments.
488
+ - Source and Environment changes of AWS CodeBuild Projects.
489
+ - VTL mapping template changes for AppSync Resolvers and Functions.
490
+ - Schema changes for AppSync GraphQL Apis.
491
+
492
+ You can optionally configure the behavior of your hotswap deployments in `cdk.json`. Currently you can only configure ECS hotswap behavior:
493
+
494
+ ```json
495
+ {
496
+ "hotswap": {
497
+ "ecs": {
498
+ "minimumHealthyPercent": 100,
499
+ "maximumHealthyPercent": 250
500
+ }
501
+ }
502
+ }
503
+ ```
504
+
505
+ **⚠ Note #1**: This command deliberately introduces drift in CloudFormation stacks in order to speed up deployments.
506
+ For this reason, only use it for development purposes.
507
+ **Never use this flag for your production deployments**!
508
+
509
+ **⚠ Note #2**: This command is considered experimental,
510
+ and might have breaking changes in the future.
511
+
512
+ **⚠ Note #3**: Expected defaults for certain parameters may be different with the hotswap parameter. For example, an ECS service's minimum healthy percentage will currently be set to 0. Please review the source accordingly if this occurs.
513
+
514
+ **⚠ Note #4**: Only usage of certain [CloudFormation intrinsic functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) are supported as part of a hotswapped deployment. At time of writing, these are:
515
+
516
+ - `Ref`
517
+ - `Fn::GetAtt` *
518
+ - `Fn::ImportValue`
519
+ - `Fn::Join`
520
+ - `Fn::Select`
521
+ - `Fn::Split`
522
+ - `Fn::Sub`
523
+
524
+ > *: `Fn::GetAtt` is only partially supported. Refer to [this implementation](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts#L477-L492) for supported resources and attributes.
525
+
526
+ ### `cdk rollback`
527
+
528
+ If a deployment performed using `cdk deploy --no-rollback` fails, your
529
+ deployment will be left in a failed, paused state. From this state you can
530
+ update your code and try the deployment again, or roll the deployment back to
531
+ the last stable state.
532
+
533
+ To roll the deployment back, use `cdk rollback`. This will initiate a rollback
534
+ to the last stable state of your stack.
535
+
536
+ Some resources may fail to roll back. If they do, you can try again by calling
537
+ `cdk rollback --orphan <LogicalId>` (can be specified multiple times). Or, run
538
+ `cdk rollback --force` to have the CDK CLI automatically orphan all failing
539
+ resources.
540
+
541
+ (`cdk rollback` requires version 23 of the bootstrap stack, since it depends on
542
+ new permissions necessary to call the appropriate CloudFormation APIs)
543
+
544
+ ### `cdk watch`
545
+
546
+ The `watch` command is similar to `deploy`,
547
+ but instead of being a one-shot operation,
548
+ the command continuously monitors the files of the project,
549
+ and triggers a deployment whenever it detects any changes:
550
+
551
+ ```console
552
+ $ cdk watch DevelopmentStack
553
+ Detected change to 'lambda-code/index.js' (type: change). Triggering 'cdk deploy'
554
+ DevelopmentStack: deploying...
555
+
556
+ ✅ DevelopmentStack
557
+
558
+ ^C
559
+ ```
560
+
561
+ To end a `cdk watch` session, interrupt the process by pressing Ctrl+C.
562
+
563
+ What files are observed is determined by the `"watch"` setting in your `cdk.json` file.
564
+ It has two sub-keys, `"include"` and `"exclude"`, each of which can be either a single string, or an array of strings.
565
+ Each entry is interpreted as a path relative to the location of the `cdk.json` file.
566
+ Globs, both `*` and `**`, are allowed to be used.
567
+ Example:
568
+
569
+ ```json
570
+ {
571
+ "app": "mvn -e -q compile exec:java",
572
+ "watch": {
573
+ "include": "src/main/**",
574
+ "exclude": "target/*"
575
+ }
576
+ }
577
+ ```
578
+
579
+ The default for `"include"` is `"**/*"`
580
+ (which means all files and directories in the root of the project),
581
+ and `"exclude"` is optional
582
+ (note that we always ignore files and directories starting with `.`,
583
+ the CDK output directory, and the `node_modules` directory),
584
+ so the minimal settings to enable `watch` are `"watch": {}`.
585
+
586
+ If either your CDK code, or application code, needs a build step before being deployed,
587
+ `watch` works with the `"build"` key in the `cdk.json` file,
588
+ for example:
589
+
590
+ ```json
591
+ {
592
+ "app": "mvn -e -q exec:java",
593
+ "build": "mvn package",
594
+ "watch": {
595
+ "include": "src/main/**",
596
+ "exclude": "target/*"
597
+ }
598
+ }
599
+ ```
600
+
601
+ Note that `watch` by default uses hotswap deployments (see above for details) --
602
+ to turn them off, pass the `--no-hotswap` option when invoking it.
603
+
604
+ By default `watch` will also monitor all CloudWatch Log Groups in your application and stream the log events
605
+ locally to your terminal. To disable this feature you can pass the `--no-logs` option when invoking it:
606
+
607
+ ```console
608
+ $ cdk watch --no-logs
609
+ ```
610
+
611
+ You can increase the concurrency by which `watch` will deploy and hotswap
612
+ your stacks by specifying `--concurrency N`. `--concurrency` for `watch`
613
+ acts the same as `--concurrency` for `deploy`, in that it will deploy or
614
+ hotswap your stacks while respecting inter-stack dependencies.
615
+
616
+ ```console
617
+ $ cdk watch --concurrency 5
618
+ ```
619
+
620
+ **Note**: This command is considered experimental, and might have breaking changes in the future.
621
+ The same limitations apply to to `watch` deployments as do to `--hotswap` deployments. See the
622
+ *Hotswap deployments for faster development* section for more information.
623
+
624
+ ### `cdk import`
625
+
626
+ Sometimes you want to import AWS resources that were created using other means
627
+ into a CDK stack. For some resources (like Roles, Lambda Functions, Event Rules,
628
+ ...), it's feasible to create new versions in CDK and then delete the old
629
+ versions. For other resources, this is not possible: stateful resources like S3
630
+ Buckets, DynamoDB tables, etc., cannot be easily deleted without impact on the
631
+ service.
632
+
633
+ `cdk import`, which uses [CloudFormation resource
634
+ imports](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html),
635
+ makes it possible to bring an existing resource under CDK/CloudFormation's
636
+ management. See the [list of resources that can be imported here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html).
637
+
638
+ To import an existing resource to a CDK stack, follow the following steps:
639
+
640
+ 1. Run a `cdk diff` to make sure there are no pending changes to the CDK stack you want to
641
+ import resources into. The only changes allowed in an "import" operation are
642
+ the addition of new resources which you want to import.
643
+ 2. Add constructs for the resources you want to import to your Stack (for example,
644
+ for an S3 bucket, add something like `new s3.Bucket(this, 'ImportedS3Bucket', {});`).
645
+ **Do not add any other changes!** You must also make sure to exactly model the state
646
+ that the resource currently has. For the example of the Bucket, be sure to
647
+ include KMS keys, life cycle policies, and anything else that's relevant
648
+ about the bucket. If you do not, subsequent update operations may not do what
649
+ you expect.
650
+ 3. Run the `cdk import` - if there are multiple stacks in the CDK app, pass a specific
651
+ stack name as an argument.
652
+ 4. The CLI will prompt you to pass in the actual names of the resources you are
653
+ importing. After you supply it, the import starts.
654
+ 5. When `cdk import` reports success, the resource is managed by CDK. Any subsequent
655
+ changes in the construct configuration will be reflected on the resource.
656
+
657
+ NOTE: You can also import existing resources by passing `--import-existing-resources` to `cdk deploy`.
658
+ This parameter only works for resources that support custom physical names,
659
+ such as S3 Buckets, DynamoDB Tables, etc...
660
+ For more information, see [Request Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateChangeSet.html#API_CreateChangeSet_RequestParameters).
661
+
662
+ #### Limitations
663
+
664
+ This feature currently has the following limitations:
665
+
666
+ - Importing resources into nested stacks is not possible.
667
+ - There is no check on whether the properties you specify are correct and complete
668
+ for the imported resource. Try starting a drift detection operation after importing.
669
+ - Resources that depend on other resources must all be imported together, or one-by-one
670
+ in the right order. If you do not, the CloudFormation deployment will fail
671
+ with unresolved references.
672
+ - Uses the deploy role credentials (necessary to read the encrypted staging
673
+ bucket). Requires version 12 of the bootstrap stack, for the added
674
+ IAM permissions to the `deploy-role`.
675
+
676
+
677
+ ### `cdk migrate`
678
+
679
+ ⚠️**CAUTION**⚠️: CDK Migrate is currently experimental and may have breaking changes in the future.
680
+
681
+ CDK Migrate generates a CDK app from deployed AWS resources using `--from-scan`, deployed AWS CloudFormation stacks using `--from-stack`, and local AWS CloudFormation templates using `--from-path`.
682
+
683
+ To learn more about the CDK Migrate feature, see [Migrate to AWS CDK](https://docs.aws.amazon.com/cdk/v2/guide/migrate.html). For more information on `cdk migrate` command options, see [cdk migrate command reference](https://docs.aws.amazon.com/cdk/v2/guide/ref-cli-cdk-migrate.html).
684
+
685
+ The new CDK app will be initialized in the current working directory and will include a single stack that is named with the value you provide using `--stack-name`. The new stack, app, and directory will all use this name. To specify a different output directory, use `--output-path`. You can create the new CDK app in any CDK supported programming language using `--language`.
686
+
687
+ #### Migrate from an AWS CloudFormation stack
688
+
689
+ Migrate from a deployed AWS CloudFormation stack in a specific AWS account and AWS Region using `--from-stack`. Provide `--stack-name` to identify the name of your stack. Account and Region information are retrieved from default CDK CLI sources. Use `--account` and `--region` options to provide other values. The following is an example that migrates **myCloudFormationStack** to a new CDK app using TypeScript:
690
+
691
+ ```console
692
+ $ cdk migrate --language typescript --from-stack --stack-name 'myCloudFormationStack'
693
+ ```
694
+
695
+ #### Migrate from a local AWS CloudFormation template
696
+
697
+ Migrate from a local `YAML` or `JSON` AWS CloudFormation template using `--from-path`. Provide a name for the stack that will be created in your new CDK app using `--stack-name`. Account and Region information are retrieved from default CDK CLI sources. Use `--account` and `--region` options to provide other values. The following is an example that creates a new CDK app using TypeScript that includes a **myCloudFormationStack** stack from a local `template.json` file:
698
+
699
+ ```console
700
+ $ cdk migrate --language typescript --from-path "./template.json" --stack-name "myCloudFormationStack"
701
+ ```
702
+
703
+ #### Migrate from deployed AWS resources
704
+
705
+ Migrate from deployed AWS resources in a specific AWS account and Region that are not associated with an AWS CloudFormation stack using `--from-scan`. These would be resources that were provisioned outside of an IaC tool. CDK Migrate utilizes the IaC generator service to scan for resources and generate a template. Then, the CDK CLI references the template to create a new CDK app. To learn more about IaC generator, see [Generating templates for existing resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html).
706
+
707
+ Account and Region information are retrieved from default CDK CLI sources. Use `--account` and `--region` options to provide other values. The following is an example that creates a new CDK app using TypeScript that includes a new **myCloudFormationStack** stack from deployed resources:
708
+
709
+ ```console
710
+ $ cdk migrate --language typescript --from-scan --stack-name "myCloudFormationStack"
711
+ ```
712
+
713
+ Since CDK Migrate relies on the IaC generator service, any limitations of IaC generator will apply to CDK Migrate. For general limitations, see [Considerations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html#generate-template-considerations).
714
+
715
+ IaC generator limitations with discovering resource and property values will also apply here. As a result, CDK Migrate will only migrate resources supported by IaC generator. Some of your resources may not be supported and some property values may not be accessible. For more information, see [Iac generator and write-only properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC-write-only-properties.html) and [Supported resource types](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC-supported-resources.html).
716
+
717
+ You can specify filters using `--filter` to specify which resources to migrate. This is a good option to use if you are over the IaC generator total resource limit.
718
+
719
+ After migration, you must resolve any write-only properties that were detected by IaC generator from your deployed resources. To learn more, see [Resolve write-only properties](https://docs.aws.amazon.com/cdk/v2/guide/migrate.html#migrate-resources-writeonly).
720
+
721
+ #### Examples
722
+
723
+ ##### Generate a TypeScript CDK app from a local AWS CloudFormation template.json file
724
+
725
+ ```console
726
+ $ # template.json is a valid cloudformation template in the local directory
727
+ $ cdk migrate --stack-name MyAwesomeApplication --language typescript --from-path MyTemplate.json
728
+ ```
729
+
730
+ This command generates a new directory named `MyAwesomeApplication` within your current working directory, and
731
+ then initializes a new CDK application within that directory. The CDK app contains a `MyAwesomeApplication` stack with resources configured to match those in your local CloudFormation template.
732
+
733
+ This results in a CDK application with the following structure, where the lib directory contains a stack definition
734
+ with the same resource configuration as the provided template.json.
735
+
736
+ ```console
737
+ ├── README.md
738
+ ├── bin
739
+ │ └── my_awesome_application.ts
740
+ ├── cdk.json
741
+ ├── jest.config.js
742
+ ├── lib
743
+ │ └── my_awesome_application-stack.ts
744
+ ├── package.json
745
+ ├── tsconfig.json
746
+ ```
747
+
748
+ ##### Generate a Python CDK app from a deployed stack
749
+
750
+ If you already have a CloudFormation stack deployed in your account and would like to manage it with CDK, you can migrate the deployed stack to a new CDK app. The value provided with `--stack-name` must match the name of the deployed stack.
751
+
752
+ ```console
753
+ $ # generate a Python application from MyDeployedStack in your account
754
+ $ cdk migrate --stack-name MyDeployedStack --language python --from-stack
755
+ ```
756
+
757
+ This will generate a Python CDK app which will synthesize the same configuration of resources as the deployed stack.
758
+
759
+ ##### Generate a TypeScript CDK app from deployed AWS resources that are not associated with a stack
760
+
761
+ If you have resources in your account that were provisioned outside AWS IaC tools and would like to manage them with the CDK, you can use the `--from-scan` option to generate the application.
762
+
763
+ In this example, we use the `--filter` option to specify which resources to migrate. You can filter resources to limit the number of resources migrated to only those specified by the `--filter` option, including any resources they depend on, or resources that depend on them (for example A filter which specifies a single Lambda Function, will find that specific table and any alarms that may monitor it). The `--filter` argument offers both AND as well as OR filtering.
764
+
765
+ OR filtering can be specified by passing multiple `--filter` options, and AND filtering can be specified by passing a single `--filter` option with multiple comma separated key/value pairs as seen below (see below for examples). It is recommended to use the `--filter` option to limit the number of resources returned as some resource types provide sample resources by default in all accounts which can add to the resource limits.
766
+
767
+ `--from-scan` takes 3 potential arguments: `--new`, `most-recent`, and undefined. If `--new` is passed, CDK Migrate will initiate a new scan of the account and use that new scan to discover resources. If `--most-recent` is passed, CDK Migrate will use the most recent scan of the account to discover resources. If neither `--new` nor `--most-recent` are passed, CDK Migrate will take the most recent scan of the account to discover resources, unless there is no recent scan, in which case it will initiate a new scan.
768
+
769
+ ```console
770
+ # Filtering options
771
+ identifier|id|resource-identifier=<resource-specific-resource-identifier-value>
772
+ type|resource-type-prefix=<resource-type-prefix>
773
+ tag-key=<tag-key>
774
+ tag-value=<tag-value>
775
+ ```
776
+
777
+ ##### Additional examples of migrating from deployed resources
778
+
779
+ ```console
780
+ $ # Generate a typescript application from all un-managed resources in your account
781
+ $ cdk migrate --stack-name MyAwesomeApplication --language typescript --from-scan
782
+
783
+ $ # Generate a typescript application from all un-managed resources in your account with the tag key "Environment" AND the tag value "Production"
784
+ $ cdk migrate --stack-name MyAwesomeApplication --language typescript --from-scan --filter tag-key=Environment,tag-value=Production
785
+
786
+ $ # Generate a python application from any dynamoDB resources with the tag-key "dev" AND the tag-value "true" OR any SQS::Queue
787
+ $ cdk migrate --stack-name MyAwesomeApplication --language python --from-scan --filter type=AWS::DynamoDb::,tag-key=dev,tag-value=true --filter type=SQS::Queue
788
+
789
+ $ # Generate a typescript application from a specific lambda function by providing it's specific resource identifier
790
+ $ cdk migrate --stack-name MyAwesomeApplication --language typescript --from-scan --filter identifier=myAwesomeLambdaFunction
791
+ ```
792
+
793
+ #### **CDK Migrate Limitations**
794
+
795
+ - CDK Migrate does not currently support nested stacks, custom resources, or the `Fn::ForEach` intrinsic function.
796
+
797
+ - CDK Migrate will only generate L1 constructs and does not currently support any higher level abstractions.
798
+
799
+ - CDK Migrate successfully generating an application does *not* guarantee the application is immediately deployable.
800
+ It simply generates a CDK application which will synthesize a template that has identical resource configurations
801
+ to the provided template.
802
+
803
+ - CDK Migrate does not interact with the CloudFormation service to verify the template
804
+ provided can deploy on its own. Although by default any CDK app generated using the `--from-scan` option exclude
805
+ CloudFormation managed resources, CDK Migrate will not verify prior to deployment that any resources scanned, or in the provided
806
+ template are already managed in other CloudFormation templates, nor will it verify that the resources in the provided
807
+ template are available in the desired regions, which may impact ADC or Opt-In regions.
808
+
809
+ - If the provided template has parameters without default values, those will need to be provided
810
+ before deploying the generated application.
811
+
812
+ In practice this is how CDK Migrate generated applications will operate in the following scenarios:
813
+
814
+ | Situation | Result |
815
+ | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
816
+ | Provided template + stack-name is from a deployed stack in the account/region | The CDK application will deploy as a changeset to the existing stack |
817
+ | Provided template has no overlap with resources already in the account/region | The CDK application will deploy a new stack successfully |
818
+ | Provided template has overlap with Cloudformation managed resources already in the account/region | The CDK application will not be deployable unless those resources are removed |
819
+ | Provided template has overlap with un-managed resources already in the account/region | The CDK application will not be deployable until those resources are adopted with [`cdk import`](#cdk-import) |
820
+ | No template has been provided and resources exist in the region the scan is done | The CDK application will be immediatly deployable and will import those resources into a new cloudformation stack upon deploy |
821
+
822
+ ##### **The provided template is already deployed to CloudFormation in the account/region**
823
+
824
+ If the provided template came directly from a deployed CloudFormation stack, and that stack has not experienced any drift,
825
+ then the generated application will be immediately deployable, and will not cause any changes to the deployed resources.
826
+ Drift might occur if a resource in your template was modified outside of CloudFormation, namely via the AWS Console or AWS CLI.
827
+
828
+ ##### **The provided template is not deployed to CloudFormation in the account/region, and there *is not* overlap with existing resources in the account/region**
829
+
830
+ If the provided template represents a set of resources that have no overlap with resources already deployed in the account/region,
831
+ then the generated application will be immediately deployable. This could be because the stack has never been deployed, or
832
+ the application was generated from a stack deployed in another account/region.
833
+
834
+ In practice this means for any resource in the provided template, for example,
835
+
836
+ ```Json
837
+ "S3Bucket": {
838
+ "Type": "AWS::S3::Bucket",
839
+ "Properties": {
840
+ "BucketName": "amzn-s3-demo-bucket",
841
+ "AccessControl": "PublicRead",
842
+ },
843
+ "DeletionPolicy": "Retain"
844
+ }
845
+ ```
846
+
847
+ There must not exist a resource of that type with the same identifier in the desired region. In this example that identfier
848
+ would be "amzn-s3-demo-bucket"
849
+
850
+ ##### **The provided template is not deployed to CloudFormation in the account/region, and there *is* overlap with existing resources in the account/region**
851
+
852
+ If the provided template represents a set of resources that overlap with resources already deployed in the account/region,
853
+ then the generated application will not be immediately deployable. If those overlapped resources are already managed by
854
+ another CloudFormation stack in that account/region, then those resources will need to be manually removed from the provided
855
+ template. Otherwise, if the overlapped resources are not managed by another CloudFormation stack, then first remove those
856
+ resources from your CDK Application Stack, deploy the cdk application successfully, then re-add them and run `cdk import`
857
+ to import them into your deployed stack.
858
+
859
+ ### `cdk destroy`
860
+
861
+ Deletes a stack from it's environment. This will cause the resources in the stack to be destroyed (unless they were
862
+ configured with a `DeletionPolicy` of `Retain`). During the stack destruction, the command will output progress
863
+ information similar to what `cdk deploy` provides.
864
+
865
+ ```console
866
+ $ cdk destroy --app='node bin/main.js' MyStackName
867
+ ```
868
+
869
+ ### `cdk bootstrap`
870
+
871
+ Deploys a `CDKToolkit` CloudFormation stack into the specified environment(s), that provides an S3 bucket
872
+ and ECR repository that `cdk deploy` will use to store synthesized templates and the related assets, before
873
+ triggering a CloudFormation stack update. The name of the deployed stack can be configured using the
874
+ `--toolkit-stack-name` argument. The S3 Bucket Public Access Block Configuration can be configured using
875
+ the `--public-access-block-configuration` argument. ECR uses immutable tags for images.
876
+
877
+ ```console
878
+ $ # Deploys to all environments
879
+ $ cdk bootstrap --app='node bin/main.js'
880
+
881
+ $ # Deploys only to environments foo and bar
882
+ $ cdk bootstrap --app='node bin/main.js' foo bar
883
+ ```
884
+
885
+ By default, bootstrap stack will be protected from stack termination. This can be disabled using
886
+ `--termination-protection` argument.
887
+
888
+ If you have specific prerequisites not met by the example template, you can
889
+ [customize it](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html#bootstrapping-customizing)
890
+ to fit your requirements, by exporting the provided one to a file and either deploying it yourself
891
+ using CloudFormation directly, or by telling the CLI to use a custom template. That looks as follows:
892
+
893
+ ```console
894
+ # Dump the built-in template to a file
895
+ $ cdk bootstrap --show-template > bootstrap-template.yaml
896
+
897
+ # Edit 'bootstrap-template.yaml' to your liking
898
+
899
+ # Tell CDK to use the customized template
900
+ $ cdk bootstrap --template bootstrap-template.yaml
901
+ ```
902
+
903
+ Out of the box customization options are also available as arguments. To use a permissions boundary:
904
+
905
+ - `--example-permissions-boundary` indicates the example permissions boundary, supplied by CDK
906
+ - `--custom-permissions-boundary` specifies, by name a predefined, customer maintained, boundary
907
+
908
+ A few notes to add at this point. The CDK supplied permissions boundary policy should be regarded as
909
+ an example. Edit the content and reference the example policy if you're testing out the feature, turn
910
+ it into a new policy for actual deployments (if one does not already exist). The concern here is drift
911
+ as, most likely, a permissions boundary is maintained and has dedicated conventions, naming included.
912
+
913
+ For more information on configuring permissions, including using permissions
914
+ boundaries see the [Security And Safety Dev Guide](https://github.com/aws/aws-cdk/wiki/Security-And-Safety-Dev-Guide)
915
+
916
+ Once a bootstrap template has been deployed with a set of parameters, you must
917
+ use the `--no-previous-parameters` CLI flag to change any of these parameters on
918
+ future deployments.
919
+
920
+ > **Note** Please note that when you use this flag, you must resupply
921
+ >*all* previously supplied parameters.
922
+
923
+ For example if you bootstrap with a custom permissions boundary
924
+
925
+ ```console
926
+ cdk bootstrap --custom-permissions-boundary my-permissions-boundary
927
+ ```
928
+
929
+ In order to remove that permissions boundary you have to specify the
930
+ `--no-previous-parameters` option.
931
+
932
+ ```console
933
+ cdk bootstrap --no-previous-parameters
934
+ ```
935
+
936
+ ### `cdk gc`
937
+
938
+ CDK Garbage Collection.
939
+
940
+ > [!CAUTION]
941
+ > CDK Garbage Collection is under development and therefore must be opted in via the
942
+ >`--unstable` flag: `cdk gc --unstable=gc`. `--unstable` indicates that the scope and
943
+ > API of feature might still change. Otherwise the feature is generally production
944
+ > ready and fully supported.
945
+
946
+ `cdk gc` garbage collects unused assets from your bootstrap bucket via the following mechanism:
947
+
948
+ - for each object in the bootstrap S3 Bucket, check to see if it is referenced in any existing CloudFormation templates
949
+ - if not, it is treated as unused and gc will either tag it or delete it, depending on your configuration.
950
+
951
+ The high-level mechanism works identically for unused assets in bootstrapped ECR Repositories.
952
+
953
+ The most basic usage looks like this:
954
+
955
+ ```console
956
+ cdk gc --unstable=gc
957
+ ```
958
+
959
+ This will garbage collect all unused assets in all environments of the existing CDK App.
960
+
961
+ To specify one type of asset, use the `type` option (options are `all`, `s3`, `ecr`):
962
+
963
+ ```console
964
+ cdk gc --unstable=gc --type=s3
965
+ ```
966
+
967
+ Otherwise `cdk gc` defaults to collecting assets in both the bootstrapped S3 Bucket and ECR Repository.
968
+
969
+ `cdk gc` will garbage collect S3 and ECR assets from the current bootstrapped environment(s) and immediately delete them. Note that, since the default bootstrap S3 Bucket is versioned, object deletion will be handled by the lifecycle
970
+ policy on the bucket.
971
+
972
+ Before we begin to delete your assets, you will be prompted:
973
+
974
+ ```console
975
+ cdk gc --unstable=gc
976
+
977
+ Found X objects to delete based off of the following criteria:
978
+ - objects have been isolated for > 0 days
979
+ - objects were created > 1 days ago
980
+
981
+ Delete this batch (yes/no/delete-all)?
982
+ ```
983
+
984
+ Since it's quite possible that the bootstrap bucket has many objects, we work in batches of 1000 objects or 100 images.
985
+ To skip the prompt either reply with `delete-all`, or use the `--confirm=false` option.
986
+
987
+ ```console
988
+ cdk gc --unstable=gc --confirm=false
989
+ ```
990
+
991
+ If you are concerned about deleting assets too aggressively, there are multiple levers you can configure:
992
+
993
+ - rollback-buffer-days: this is the amount of days an asset has to be marked as isolated before it is elligible for deletion.
994
+ - created-buffer-days: this is the amount of days an asset must live before it is elligible for deletion.
995
+
996
+ When using `rollback-buffer-days`, instead of deleting unused objects, `cdk gc` will tag them with
997
+ today's date instead. It will also check if any objects have been tagged by previous runs of `cdk gc`
998
+ and delete them if they have been tagged for longer than the buffer days.
999
+
1000
+ When using `created-buffer-days`, we simply filter out any assets that have not persisted that number
1001
+ of days.
1002
+
1003
+ ```console
1004
+ cdk gc --unstable=gc --rollback-buffer-days=30 --created-buffer-days=1
1005
+ ```
1006
+
1007
+ You can also configure the scope that `cdk gc` performs via the `--action` option. By default, all actions
1008
+ are performed, but you can specify `print`, `tag`, or `delete-tagged`.
1009
+
1010
+ - `print` performs no changes to your AWS account, but finds and prints the number of unused assets.
1011
+ - `tag` tags any newly unused assets, but does not delete any unused assets.
1012
+ - `delete-tagged` deletes assets that have been tagged for longer than the buffer days, but does not tag newly unused assets.
1013
+
1014
+ ```console
1015
+ cdk gc --unstable=gc --action=delete-tagged --rollback-buffer-days=30
1016
+ ```
1017
+
1018
+ This will delete assets that have been unused for >30 days, but will not tag additional assets.
1019
+
1020
+ Here is a diagram that shows the algorithm of garbage collection:
1021
+
1022
+ ![Diagram of Garbage Collection algorithm](images/garbage-collection.png)
1023
+
1024
+ #### Theoretical Race Condition with `REVIEW_IN_PROGRESS` stacks
1025
+
1026
+ When gathering stack templates, we are currently ignoring `REVIEW_IN_PROGRESS` stacks as no template
1027
+ is available during the time the stack is in that state. However, stacks in `REVIEW_IN_PROGRESS` have already
1028
+ passed through the asset uploading step, where it either uploads new assets or ensures that the asset exists.
1029
+ Therefore it is possible the assets it references are marked as isolated and garbage collected before the stack
1030
+ template is available.
1031
+
1032
+ Our recommendation is to not deploy stacks and run garbage collection at the same time. If that is unavoidable,
1033
+ setting `--created-buffer-days` will help as garbage collection will avoid deleting assets that are recently
1034
+ created. Finally, if you do result in a failed deployment, the mitigation is to redeploy, as the asset upload step
1035
+ will be able to reupload the missing asset.
1036
+
1037
+ In practice, this race condition is only for a specific edge case and unlikely to happen but please open an
1038
+ issue if you think that this has happened to your stack.
1039
+
1040
+ ### `cdk doctor`
1041
+
1042
+ Inspect the current command-line environment and configurations, and collect information that can be useful for
1043
+ troubleshooting problems. It is usually a good idea to include the information provided by this command when submitting
1044
+ a bug report.
1045
+
1046
+ ```console
1047
+ $ cdk doctor
1048
+ ℹ️ CDK Version: 1.0.0 (build e64993a)
1049
+ ℹ️ AWS environment variables:
1050
+ - AWS_EC2_METADATA_DISABLED = 1
1051
+ - AWS_SDK_LOAD_CONFIG = 1
1052
+ ```
1053
+
1054
+ ## Notices
1055
+
1056
+ CDK Notices are important messages regarding security vulnerabilities, regressions, and usage of unsupported
1057
+ versions. Relevant notices appear on every command by default. For example,
1058
+
1059
+ ```console
1060
+ $ cdk deploy
1061
+
1062
+ ... # Normal output of the command
1063
+
1064
+ NOTICES
1065
+
1066
+ 22090 cli: cdk init produces EACCES: permission denied and does not fill the directory
1067
+
1068
+ Overview: The CLI is unable to initialize new apps if CDK is
1069
+ installed globally in a directory owned by root
1070
+
1071
+ Affected versions: cli: 2.42.0.
1072
+
1073
+ More information at: https://github.com/aws/aws-cdk/issues/22090
1074
+
1075
+
1076
+ 27547 Incorrect action in policy of Bucket `grantRead` method
1077
+
1078
+ Overview: Using the `grantRead` method on `aws-cdk-lib/aws-s3.Bucket`
1079
+ results in an invalid action attached to the resource policy
1080
+ which can cause unexpected failures when interacting
1081
+ with the bucket.
1082
+
1083
+ Affected versions: aws-cdk-lib.aws_s3.Bucket: 2.101.0.
1084
+
1085
+ More information at: https://github.com/aws/aws-cdk/issues/27547
1086
+
1087
+
1088
+ If you don’t want to see a notice anymore, use "cdk acknowledge ID". For example, "cdk acknowledge 16603".
1089
+ ```
1090
+
1091
+ There are several types of notices you may encounter, differentiated by the affected component:
1092
+
1093
+ - **cli**: notifies you about issues related to your CLI version.
1094
+ - **framework**: notifies you about issues related to your version of core constructs (e.g `Stack`).
1095
+ - **aws-cdk-lib.{module}.{construct}**: notifies you about issue related to your version of a specific construct (e.g `aws-cdk-lib.aws_s3.Bucket`)
1096
+ - **bootstrap**: notifies you about issues related to your version of the bootstrap stack. Note that these types of notices are only shown during the `cdk deploy` command.
1097
+
1098
+ You can suppress notices in a variety of ways:
1099
+
1100
+ - per individual execution:
1101
+
1102
+ `cdk deploy --no-notices`
1103
+
1104
+ - disable all notices indefinitely through context in `cdk.json`:
1105
+
1106
+ ```json
1107
+ {
1108
+ "notices": false,
1109
+ "context": {
1110
+ ...
1111
+ }
1112
+ }
1113
+ ```
1114
+
1115
+ - acknowledging individual notices via `cdk acknowledge` (see below).
1116
+
1117
+ ### `cdk acknowledge`
1118
+
1119
+ To hide a particular notice that has been addressed or does not apply, call `cdk acknowledge` with the ID of
1120
+ the notice:
1121
+
1122
+ ```console
1123
+ $cdk acknowledge 16603
1124
+ ```
1125
+
1126
+ > Please note that the acknowledgements are made project by project. If you acknowledge an notice in one CDK
1127
+ > project, it will still appear on other projects when you run any CDK commands, unless you have suppressed
1128
+ > or disabled notices.
1129
+
1130
+
1131
+ ### `cdk notices`
1132
+
1133
+ List the notices that are relevant to the current CDK repository, regardless of context flags or notices that
1134
+ have been acknowledged:
1135
+
1136
+ ```console
1137
+ $ cdk notices
1138
+
1139
+ NOTICES
1140
+
1141
+ 16603 Toggling off auto_delete_objects for Bucket empties the bucket
1142
+
1143
+ Overview: if a stack is deployed with an S3 bucket with
1144
+ auto_delete_objects=True, and then re-deployed with
1145
+ auto_delete_objects=False, all the objects in the bucket
1146
+ will be deleted.
1147
+
1148
+ Affected versions: framework: <=2.15.0 >=2.10.0
1149
+
1150
+ More information at: https://github.com/aws/aws-cdk/issues/16603
1151
+
1152
+
1153
+ If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 16603".
1154
+ ```
1155
+
1156
+ List the unacknowledged notices:
1157
+
1158
+ ```console
1159
+ $ cdk notices --unacknowledged
1160
+
1161
+ NOTICES (What's this? https://github.com/aws/aws-cdk/wiki/CLI-Notices)
1162
+
1163
+ 29483 (cli): Upgrading to v2.132.0 or v2.132.1 breaks cdk diff functionality
1164
+
1165
+ Overview: cdk diff functionality used to rely on assuming lookup-role.
1166
+ With a recent change present in v2.132.0 and v2.132.1, it is
1167
+ now trying to assume deploy-role with the lookup-role. This
1168
+ leads to an authorization error if permissions were not
1169
+ defined to assume deploy-role.
1170
+
1171
+ Affected versions: cli: >=2.132.0 <=2.132.1
1172
+
1173
+ More information at: https://github.com/aws/aws-cdk/issues/29483
1174
+
1175
+
1176
+ If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 29483".
1177
+
1178
+ There are 1 unacknowledged notice(s).
1179
+ ```
1180
+
1181
+ ### Bundling
1182
+
1183
+ By default asset bundling is skipped for `cdk list` and `cdk destroy`. For `cdk deploy`, `cdk diff`
1184
+ and `cdk synthesize` the default is to bundle assets for all stacks unless `exclusively` is specified.
1185
+ In this case, only the listed stacks will have their assets bundled.
1186
+
1187
+ ## MFA support
1188
+
1189
+ If `mfa_serial` is found in the active profile of the shared ini file AWS CDK
1190
+ will ask for token defined in the `mfa_serial`. This token will be provided to STS assume role call.
1191
+
1192
+ Example profile in `~/.aws/config` where `mfa_serial` is used to assume role:
1193
+
1194
+ ```ini
1195
+ [profile my_assume_role_profile]
1196
+ source_profile=my_source_role
1197
+ role_arn=arn:aws:iam::123456789123:role/role_to_be_assumed
1198
+ mfa_serial=arn:aws:iam::123456789123:mfa/my_user
1199
+ ```
1200
+
1201
+ ## SSO support
1202
+
1203
+ If you create an SSO profile with `aws configure sso` and run `aws sso login`, the CDK can use those credentials
1204
+ if you set the profile name as the value of `AWS_PROFILE` or pass it to `--profile`.
1205
+
1206
+ ## Configuration
1207
+
1208
+ On top of passing configuration through command-line arguments, it is possible to use JSON configuration files. The
1209
+ configuration's order of precedence is:
1210
+
1211
+ 1. Command-line arguments
1212
+ 2. Project configuration (`./cdk.json`)
1213
+ 3. User configuration (`~/.cdk.json`)
1214
+
1215
+ ### JSON Configuration files
1216
+
1217
+ Some of the interesting keys that can be used in the JSON configuration files:
1218
+
1219
+ ```json5
1220
+ {
1221
+ "app": "node bin/main.js", // Command to start the CDK app (--app='node bin/main.js')
1222
+ "build": "mvn package", // Specify pre-synth build (--build='mvn package')
1223
+ "context": { // Context entries (--context=key=value)
1224
+ "key": "value"
1225
+ },
1226
+ "toolkitStackName": "foo", // Customize 'bootstrap' stack name (--toolkit-stack-name=foo)
1227
+ "toolkitBucket": {
1228
+ "bucketName": "amzn-s3-demo-bucket", // Customize 'bootstrap' bucket name (--toolkit-bucket-name=amzn-s3-demo-bucket)
1229
+ "kmsKeyId": "fooKMSKey" // Customize 'bootstrap' KMS key id (--bootstrap-kms-key-id=fooKMSKey)
1230
+ },
1231
+ "versionReporting": false, // Opt-out of version reporting (--no-version-reporting)
1232
+ }
1233
+ ```
1234
+
1235
+ If specified, the command in the `build` key will be executed immediately before synthesis.
1236
+ This can be used to build Lambda Functions, CDK Application code, or other assets.
1237
+ `build` cannot be specified on the command line or in the User configuration,
1238
+ and must be specified in the Project configuration. The command specified
1239
+ in `build` will be executed by the "watch" process before deployment.
1240
+
1241
+ ### Environment
1242
+
1243
+ The following environment variables affect aws-cdk:
1244
+
1245
+ - `CDK_DISABLE_VERSION_CHECK`: If set, disable automatic check for newer versions.
1246
+ - `CDK_NEW_BOOTSTRAP`: use the modern bootstrapping stack.
1247
+
1248
+ ### Running in CI
1249
+
1250
+ The CLI will attempt to detect whether it is being run in CI by looking for the presence of an
1251
+ environment variable `CI=true`. This can be forced by passing the `--ci` flag. By default the CLI
1252
+ sends most of its logs to `stderr`, but when `ci=true` it will send the logs to `stdout` instead.
1253
+
1254
+ ### Changing the default TypeScript transpiler
1255
+
1256
+ The ts-node package used to synthesize and deploy CDK apps supports an alternate transpiler that might improve transpile times. The SWC transpiler is written in Rust and has no type checking. The SWC transpiler should be enabled by experienced TypeScript developers.
1257
+
1258
+ To enable the SWC transpiler, install the package in the CDK app.
1259
+
1260
+ ```sh
1261
+ npm i -D @swc/core @swc/helpers regenerator-runtime
1262
+ ```
1263
+
1264
+ And, update the `tsconfig.json` file to add the `ts-node` property.
1265
+
1266
+ ```json
1267
+ {
1268
+ "ts-node": {
1269
+ "swc": true
1270
+ }
1271
+ }
1272
+ ```
1273
+
1274
+ The documentation may be found at <https://typestrong.org/ts-node/docs/swc/>