@aws-cdk-testing/cli-integ 3.2.4 → 3.3.1

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 (454) hide show
  1. package/lib/cli/run-suite.js +6 -1
  2. package/lib/cli/run-suite.ts +6 -0
  3. package/lib/integ-test.js +3 -13
  4. package/lib/integ-test.ts +2 -13
  5. package/lib/process.d.ts +45 -0
  6. package/lib/process.js +97 -0
  7. package/lib/process.ts +154 -0
  8. package/lib/shell.d.ts +51 -0
  9. package/lib/shell.js +81 -20
  10. package/lib/shell.ts +144 -17
  11. package/lib/with-cdk-app.d.ts +4 -1
  12. package/lib/with-cdk-app.js +6 -4
  13. package/lib/with-cdk-app.ts +9 -2
  14. package/lib/with-cli-lib.js +2 -1
  15. package/lib/with-cli-lib.ts +1 -0
  16. package/package.json +5 -4
  17. package/resources/cdk-apps/app/app.js +36 -25
  18. package/resources/integ.jest.config.js +2 -3
  19. package/tests/cli-integ-tests/cdk---exclusively-selects-only-selected-stack.integtest.js +24 -0
  20. package/tests/cli-integ-tests/cdk---exclusively-selects-only-selected-stack.integtest.ts +29 -0
  21. package/tests/cli-integ-tests/cdk-assets/cdk-assets-uses-profile.integtest.js +80 -0
  22. package/tests/cli-integ-tests/cdk-assets/cdk-assets-uses-profile.integtest.ts +92 -0
  23. package/tests/cli-integ-tests/cdk-automatic-ordering-with-concurrency.integtest.js +11 -0
  24. package/tests/cli-integ-tests/cdk-automatic-ordering-with-concurrency.integtest.ts +15 -0
  25. package/tests/cli-integ-tests/cdk-automatic-ordering.integtest.js +11 -0
  26. package/tests/cli-integ-tests/cdk-automatic-ordering.integtest.ts +15 -0
  27. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and---no-rollback-is-removed-from-flags.integtest.d.ts +1 -0
  28. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and---no-rollback-is-removed-from-flags.integtest.js +35 -0
  29. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and---no-rollback-is-removed-from-flags.integtest.ts +40 -0
  30. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and-change-contains-a-replacement.integtest.d.ts +1 -0
  31. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and-change-contains-a-replacement.integtest.js +35 -0
  32. package/tests/cli-integ-tests/cdk-automatic-rollback-if-paused-and-change-contains-a-replacement.integtest.ts +40 -0
  33. package/tests/cli-integ-tests/cdk-automatic-rollback-if-replacement-and---no-rollback-is-removed-from-flags.integtest.d.ts +1 -0
  34. package/tests/cli-integ-tests/cdk-automatic-rollback-if-replacement-and---no-rollback-is-removed-from-flags.integtest.js +26 -0
  35. package/tests/cli-integ-tests/cdk-automatic-rollback-if-replacement-and---no-rollback-is-removed-from-flags.integtest.ts +29 -0
  36. package/tests/cli-integ-tests/cdk-bootstrap-a-customized-template-vendor-will-not-overwrite-the-default-template.integtest.d.ts +1 -0
  37. package/tests/cli-integ-tests/cdk-bootstrap-a-customized-template-vendor-will-not-overwrite-the-default-template.integtest.js +39 -0
  38. package/tests/cli-integ-tests/cdk-bootstrap-a-customized-template-vendor-will-not-overwrite-the-default-template.integtest.ts +42 -0
  39. package/tests/cli-integ-tests/cdk-bootstrap-add-tags.integtest.d.ts +1 -0
  40. package/tests/cli-integ-tests/cdk-bootstrap-add-tags.integtest.js +25 -0
  41. package/tests/cli-integ-tests/cdk-bootstrap-add-tags.integtest.ts +26 -0
  42. package/tests/cli-integ-tests/cdk-bootstrap-can-add-tags-then-update-tags-during-re-bootstrap.integtest.d.ts +1 -0
  43. package/tests/cli-integ-tests/cdk-bootstrap-can-add-tags-then-update-tags-during-re-bootstrap.integtest.js +27 -0
  44. package/tests/cli-integ-tests/cdk-bootstrap-can-add-tags-then-update-tags-during-re-bootstrap.integtest.ts +28 -0
  45. package/tests/cli-integ-tests/cdk-bootstrap-can-and-deploy-if-omitting-execution-policies.integtest.d.ts +1 -0
  46. package/tests/cli-integ-tests/cdk-bootstrap-can-and-deploy-if-omitting-execution-policies.integtest.js +19 -0
  47. package/tests/cli-integ-tests/cdk-bootstrap-can-and-deploy-if-omitting-execution-policies.integtest.ts +21 -0
  48. package/tests/cli-integ-tests/cdk-bootstrap-can-bootstrap-without-execution.integtest.d.ts +1 -0
  49. package/tests/cli-integ-tests/cdk-bootstrap-can-bootstrap-without-execution.integtest.js +18 -0
  50. package/tests/cli-integ-tests/cdk-bootstrap-can-bootstrap-without-execution.integtest.ts +22 -0
  51. package/tests/cli-integ-tests/cdk-bootstrap-can-create-a-legacy-bootstrap-stack-with---public-access-block-configuration-false.integtest.d.ts +1 -0
  52. package/tests/cli-integ-tests/cdk-bootstrap-can-create-a-legacy-bootstrap-stack-with---public-access-block-configuration-false.integtest.js +20 -0
  53. package/tests/cli-integ-tests/cdk-bootstrap-can-create-a-legacy-bootstrap-stack-with---public-access-block-configuration-false.integtest.ts +21 -0
  54. package/tests/cli-integ-tests/cdk-bootstrap-can-create-multiple-legacy-bootstrap-stacks.integtest.d.ts +1 -0
  55. package/tests/cli-integ-tests/cdk-bootstrap-can-create-multiple-legacy-bootstrap-stacks.integtest.js +26 -0
  56. package/tests/cli-integ-tests/cdk-bootstrap-can-create-multiple-legacy-bootstrap-stacks.integtest.ts +27 -0
  57. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-modern-synthesized-stack-even-if-bootstrap-stack-name-is-unknown.integtest.d.ts +1 -0
  58. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-modern-synthesized-stack-even-if-bootstrap-stack-name-is-unknown.integtest.js +22 -0
  59. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-modern-synthesized-stack-even-if-bootstrap-stack-name-is-unknown.integtest.ts +24 -0
  60. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-with-session-tags-on-the-deploy.integtest.d.ts +1 -0
  61. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-with-session-tags-on-the-deploy.integtest.js +23 -0
  62. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-with-session-tags-on-the-deploy.integtest.ts +25 -0
  63. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-without-execution-role-and-with-session-tags-on-deploy-role.integtest.d.ts +1 -0
  64. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-without-execution-role-and-with-session-tags-on-deploy-role.integtest.js +20 -0
  65. package/tests/cli-integ-tests/cdk-bootstrap-can-deploy-without-execution-role-and-with-session-tags-on-deploy-role.integtest.ts +22 -0
  66. package/tests/cli-integ-tests/cdk-bootstrap-can-dump-the-template.integtest.d.ts +1 -0
  67. package/tests/cli-integ-tests/cdk-bootstrap-can-dump-the-template.integtest.js +29 -0
  68. package/tests/cli-integ-tests/cdk-bootstrap-can-dump-the-template.integtest.ts +32 -0
  69. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-custompermissionsboundary.integtest.d.ts +1 -0
  70. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-custompermissionsboundary.integtest.js +61 -0
  71. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-custompermissionsboundary.integtest.ts +77 -0
  72. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-trusted-account.integtest.d.ts +1 -0
  73. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-trusted-account.integtest.js +25 -0
  74. package/tests/cli-integ-tests/cdk-bootstrap-can-remove-trusted-account.integtest.ts +30 -0
  75. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-(with-slashes)-to-bootstrap.integtest.d.ts +1 -0
  76. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-(with-slashes)-to-bootstrap.integtest.js +14 -0
  77. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-(with-slashes)-to-bootstrap.integtest.ts +15 -0
  78. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-to-bootstrap.integtest.d.ts +1 -0
  79. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-to-bootstrap.integtest.js +14 -0
  80. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-custom-permissions-boundary-to-bootstrap.integtest.ts +15 -0
  81. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-default-permissions-boundary-to-bootstrap.integtest.d.ts +1 -0
  82. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-default-permissions-boundary-to-bootstrap.integtest.js +14 -0
  83. package/tests/cli-integ-tests/cdk-bootstrap-can-use-the-default-permissions-boundary-to-bootstrap.integtest.ts +15 -0
  84. package/tests/cli-integ-tests/cdk-bootstrap-create-ecr-with-tag-immutability-to-set-on.integtest.d.ts +1 -0
  85. package/tests/cli-integ-tests/cdk-bootstrap-create-ecr-with-tag-immutability-to-set-on.integtest.js +27 -0
  86. package/tests/cli-integ-tests/cdk-bootstrap-create-ecr-with-tag-immutability-to-set-on.integtest.ts +34 -0
  87. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap-(with-docker-image).integtest.d.ts +1 -0
  88. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap-(with-docker-image).integtest.js +20 -0
  89. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap-(with-docker-image).integtest.ts +22 -0
  90. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap.integtest.d.ts +1 -0
  91. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap.integtest.js +20 -0
  92. package/tests/cli-integ-tests/cdk-bootstrap-deploy-new-style-synthesis-to-new-style-bootstrap.integtest.ts +22 -0
  93. package/tests/cli-integ-tests/cdk-bootstrap-deploy-old-style-synthesis-to-new-style-bootstrap.integtest.d.ts +1 -0
  94. package/tests/cli-integ-tests/cdk-bootstrap-deploy-old-style-synthesis-to-new-style-bootstrap.integtest.js +19 -0
  95. package/tests/cli-integ-tests/cdk-bootstrap-deploy-old-style-synthesis-to-new-style-bootstrap.integtest.ts +21 -0
  96. package/tests/cli-integ-tests/cdk-bootstrap-switch-on-termination-protection.integtest.d.ts +1 -0
  97. package/tests/cli-integ-tests/cdk-bootstrap-switch-on-termination-protection.integtest.js +23 -0
  98. package/tests/cli-integ-tests/cdk-bootstrap-switch-on-termination-protection.integtest.ts +24 -0
  99. package/tests/cli-integ-tests/cdk-bootstrap-upgrade-legacy-bootstrap-stack-to-new-bootstrap-stack-while-in-use.integtest.d.ts +1 -0
  100. package/tests/cli-integ-tests/cdk-bootstrap-upgrade-legacy-bootstrap-stack-to-new-bootstrap-stack-while-in-use.integtest.js +42 -0
  101. package/tests/cli-integ-tests/cdk-bootstrap-upgrade-legacy-bootstrap-stack-to-new-bootstrap-stack-while-in-use.integtest.ts +47 -0
  102. package/tests/cli-integ-tests/cdk-can-still-load-old-assemblies.integtest.d.ts +1 -0
  103. package/tests/cli-integ-tests/cdk-can-still-load-old-assemblies.integtest.js +49 -0
  104. package/tests/cli-integ-tests/cdk-can-still-load-old-assemblies.integtest.ts +57 -0
  105. package/tests/cli-integ-tests/cdk-cdk-diff---fail-on-multiple-stacks-exits-with-error-if-any-of-the-stacks-contains-a-diff.integtest.d.ts +1 -0
  106. package/tests/cli-integ-tests/cdk-cdk-diff---fail-on-multiple-stacks-exits-with-error-if-any-of-the-stacks-contains-a-diff.integtest.js +15 -0
  107. package/tests/cli-integ-tests/cdk-cdk-diff---fail-on-multiple-stacks-exits-with-error-if-any-of-the-stacks-contains-a-diff.integtest.ts +22 -0
  108. package/tests/cli-integ-tests/cdk-cdk-diff---fail-with-multiple-stack-exits-with-if-any-of-the-stacks-contains-a-diff.integtest.d.ts +1 -0
  109. package/tests/cli-integ-tests/cdk-cdk-diff---fail-with-multiple-stack-exits-with-if-any-of-the-stacks-contains-a-diff.integtest.js +15 -0
  110. package/tests/cli-integ-tests/cdk-cdk-diff---fail-with-multiple-stack-exits-with-if-any-of-the-stacks-contains-a-diff.integtest.ts +22 -0
  111. package/tests/cli-integ-tests/cdk-cdk-diff---quiet-does-not-print-there-were-no-differences-message-for-stacks-which-have-no-differences.integtest.d.ts +1 -0
  112. package/tests/cli-integ-tests/cdk-cdk-diff---quiet-does-not-print-there-were-no-differences-message-for-stacks-which-have-no-differences.integtest.js +14 -0
  113. package/tests/cli-integ-tests/cdk-cdk-diff---quiet-does-not-print-there-were-no-differences-message-for-stacks-which-have-no-differences.integtest.ts +19 -0
  114. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-changes-are-present.integtest.d.ts +1 -0
  115. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-changes-are-present.integtest.js +9 -0
  116. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-changes-are-present.integtest.ts +14 -0
  117. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-access-control-config.integtest.d.ts +1 -0
  118. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-access-control-config.integtest.js +8 -0
  119. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-access-control-config.integtest.ts +13 -0
  120. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-assignment.integtest.d.ts +1 -0
  121. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-assignment.integtest.js +8 -0
  122. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-assignment.integtest.ts +13 -0
  123. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-with-managed-policy.integtest.d.ts +1 -0
  124. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-with-managed-policy.integtest.js +8 -0
  125. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-with-managed-policy.integtest.ts +13 -0
  126. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-without-managed-policy.integtest.d.ts +1 -0
  127. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-without-managed-policy.integtest.js +8 -0
  128. package/tests/cli-integ-tests/cdk-cdk-diff---security-only---fail-exits-when-security-diff-for-sso-perm-set-without-managed-policy.integtest.ts +13 -0
  129. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-access-control-information.integtest.d.ts +1 -0
  130. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-access-control-information.integtest.js +30 -0
  131. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-access-control-information.integtest.ts +35 -0
  132. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-assignment-information.integtest.d.ts +1 -0
  133. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-assignment-information.integtest.js +28 -0
  134. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-assignment-information.integtest.ts +37 -0
  135. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-with-managed-policy-information.integtest.d.ts +1 -0
  136. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-with-managed-policy-information.integtest.js +27 -0
  137. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-with-managed-policy-information.integtest.ts +35 -0
  138. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-without-managed-policy-information.integtest.d.ts +1 -0
  139. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-without-managed-policy-information.integtest.js +30 -0
  140. package/tests/cli-integ-tests/cdk-cdk-diff---security-only-successfully-outputs-sso-permission-set-without-managed-policy-information.integtest.ts +37 -0
  141. package/tests/cli-integ-tests/cdk-cdk-diff-doesnt-show-resource-metadata-changes.integtest.d.ts +1 -0
  142. package/tests/cli-integ-tests/cdk-cdk-diff-doesnt-show-resource-metadata-changes.integtest.js +18 -0
  143. package/tests/cli-integ-tests/cdk-cdk-diff-doesnt-show-resource-metadata-changes.integtest.ts +23 -0
  144. package/tests/cli-integ-tests/cdk-cdk-diff-shows-resource-metadata-changes-with---no-change-set.integtest.d.ts +1 -0
  145. package/tests/cli-integ-tests/cdk-cdk-diff-shows-resource-metadata-changes-with---no-change-set.integtest.js +18 -0
  146. package/tests/cli-integ-tests/cdk-cdk-diff-shows-resource-metadata-changes-with---no-change-set.integtest.ts +23 -0
  147. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-and-custom-toolkit-stack-name-and-qualifier-does-not-fail.integtest.d.ts +1 -0
  148. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-and-custom-toolkit-stack-name-and-qualifier-does-not-fail.integtest.js +35 -0
  149. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-and-custom-toolkit-stack-name-and-qualifier-does-not-fail.integtest.ts +38 -0
  150. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-does-not-fail.integtest.d.ts +1 -0
  151. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-does-not-fail.integtest.js +23 -0
  152. package/tests/cli-integ-tests/cdk-cdk-diff-with-large-changeset-does-not-fail.integtest.ts +28 -0
  153. package/tests/cli-integ-tests/cdk-cdk-diff.integtest.d.ts +1 -0
  154. package/tests/cli-integ-tests/cdk-cdk-diff.integtest.js +13 -0
  155. package/tests/cli-integ-tests/cdk-cdk-diff.integtest.ts +18 -0
  156. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json---long.integtest.d.ts +1 -0
  157. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json---long.integtest.js +45 -0
  158. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json---long.integtest.ts +50 -0
  159. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json.integtest.d.ts +1 -0
  160. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json.integtest.js +75 -0
  161. package/tests/cli-integ-tests/cdk-cdk-ls---show-dependencies---json.integtest.ts +95 -0
  162. package/tests/cli-integ-tests/cdk-cdk-ls.integtest.d.ts +1 -0
  163. package/tests/cli-integ-tests/cdk-cdk-ls.integtest.js +32 -0
  164. package/tests/cli-integ-tests/cdk-cdk-ls.integtest.ts +36 -0
  165. package/tests/cli-integ-tests/cdk-cdk-notices-are-displayed-correctly.integtest.d.ts +1 -0
  166. package/tests/cli-integ-tests/cdk-cdk-notices-are-displayed-correctly.integtest.js +38 -0
  167. package/tests/cli-integ-tests/cdk-cdk-notices-are-displayed-correctly.integtest.ts +42 -0
  168. package/tests/cli-integ-tests/cdk-cdk-notices-with---unacknowledged.integtest.d.ts +1 -0
  169. package/tests/cli-integ-tests/cdk-cdk-notices-with---unacknowledged.integtest.js +11 -0
  170. package/tests/cli-integ-tests/cdk-cdk-notices-with---unacknowledged.integtest.ts +14 -0
  171. package/tests/cli-integ-tests/cdk-cdk-synth-add-the-metadata-properties-expected-by-sam.integtest.d.ts +1 -0
  172. package/tests/cli-integ-tests/cdk-cdk-synth-add-the-metadata-properties-expected-by-sam.integtest.js +111 -0
  173. package/tests/cli-integ-tests/cdk-cdk-synth-add-the-metadata-properties-expected-by-sam.integtest.ts +126 -0
  174. package/tests/cli-integ-tests/cdk-cdk-synth-bundled-functions-as-expected.integtest.d.ts +1 -0
  175. package/tests/cli-integ-tests/cdk-cdk-synth-bundled-functions-as-expected.integtest.js +74 -0
  176. package/tests/cli-integ-tests/cdk-cdk-synth-bundled-functions-as-expected.integtest.ts +80 -0
  177. package/tests/cli-integ-tests/cdk-cdk-synth.integtest.d.ts +1 -0
  178. package/tests/cli-integ-tests/cdk-cdk-synth.integtest.js +40 -0
  179. package/tests/cli-integ-tests/cdk-cdk-synth.integtest.ts +53 -0
  180. package/tests/cli-integ-tests/cdk-ci-output-to-stderr.integtest.d.ts +1 -0
  181. package/tests/cli-integ-tests/cdk-ci-output-to-stderr.integtest.js +16 -0
  182. package/tests/cli-integ-tests/cdk-ci-output-to-stderr.integtest.ts +19 -0
  183. package/tests/cli-integ-tests/cdk-ci-true-output-to-stdout.integtest.d.ts +1 -0
  184. package/tests/cli-integ-tests/cdk-ci-true-output-to-stdout.integtest.js +24 -0
  185. package/tests/cli-integ-tests/cdk-ci-true-output-to-stdout.integtest.ts +28 -0
  186. package/tests/cli-integ-tests/cdk-construct-with-builtin-lambda-function.integtest.d.ts +1 -0
  187. package/tests/cli-integ-tests/cdk-construct-with-builtin-lambda-function.integtest.js +11 -0
  188. package/tests/cli-integ-tests/cdk-construct-with-builtin-lambda-function.integtest.ts +14 -0
  189. package/tests/cli-integ-tests/cdk-context-in-stage-propagates-to-top.integtest.d.ts +1 -0
  190. package/tests/cli-integ-tests/cdk-context-in-stage-propagates-to-top.integtest.js +15 -0
  191. package/tests/cli-integ-tests/cdk-context-in-stage-propagates-to-top.integtest.ts +20 -0
  192. package/tests/cli-integ-tests/cdk-context-setting.integtest.d.ts +1 -0
  193. package/tests/cli-integ-tests/cdk-context-setting.integtest.js +26 -0
  194. package/tests/cli-integ-tests/cdk-context-setting.integtest.ts +33 -0
  195. package/tests/cli-integ-tests/cdk-deploy---method-direct.integtest.d.ts +1 -0
  196. package/tests/cli-integ-tests/cdk-deploy---method-direct.integtest.js +18 -0
  197. package/tests/cli-integ-tests/cdk-deploy---method-direct.integtest.ts +23 -0
  198. package/tests/cli-integ-tests/cdk-deploy-all-concurrently.integtest.d.ts +1 -0
  199. package/tests/cli-integ-tests/cdk-deploy-all-concurrently.integtest.js +13 -0
  200. package/tests/cli-integ-tests/cdk-deploy-all-concurrently.integtest.ts +17 -0
  201. package/tests/cli-integ-tests/cdk-deploy-all.integtest.d.ts +1 -0
  202. package/tests/cli-integ-tests/cdk-deploy-all.integtest.js +10 -0
  203. package/tests/cli-integ-tests/cdk-deploy-all.integtest.ts +14 -0
  204. package/tests/cli-integ-tests/cdk-deploy-and-test-stack-with-lambda-asset.integtest.d.ts +1 -0
  205. package/tests/cli-integ-tests/cdk-deploy-and-test-stack-with-lambda-asset.integtest.js +22 -0
  206. package/tests/cli-integ-tests/cdk-deploy-and-test-stack-with-lambda-asset.integtest.ts +31 -0
  207. package/tests/cli-integ-tests/cdk-deploy-deletes-all-notification-arns-when-empty-array-is-passed.integtest.d.ts +1 -0
  208. package/tests/cli-integ-tests/cdk-deploy-deletes-all-notification-arns-when-empty-array-is-passed.integtest.js +41 -0
  209. package/tests/cli-integ-tests/cdk-deploy-deletes-all-notification-arns-when-empty-array-is-passed.integtest.ts +50 -0
  210. package/tests/cli-integ-tests/cdk-deploy-no-stacks-error.integtest.d.ts +1 -0
  211. package/tests/cli-integ-tests/cdk-deploy-no-stacks-error.integtest.js +13 -0
  212. package/tests/cli-integ-tests/cdk-deploy-no-stacks-error.integtest.ts +18 -0
  213. package/tests/cli-integ-tests/cdk-deploy-no-stacks-with---ignore-no-stacks.integtest.d.ts +1 -0
  214. package/tests/cli-integ-tests/cdk-deploy-no-stacks-with---ignore-no-stacks.integtest.js +14 -0
  215. package/tests/cli-integ-tests/cdk-deploy-no-stacks-with---ignore-no-stacks.integtest.ts +17 -0
  216. package/tests/cli-integ-tests/cdk-deploy-preserves-existing-notification-arns-when-not-specified.integtest.d.ts +1 -0
  217. package/tests/cli-integ-tests/cdk-deploy-preserves-existing-notification-arns-when-not-specified.integtest.js +38 -0
  218. package/tests/cli-integ-tests/cdk-deploy-preserves-existing-notification-arns-when-not-specified.integtest.ts +51 -0
  219. package/tests/cli-integ-tests/cdk-deploy-stack-with-docker-asset.integtest.d.ts +1 -0
  220. package/tests/cli-integ-tests/cdk-deploy-stack-with-docker-asset.integtest.js +8 -0
  221. package/tests/cli-integ-tests/cdk-deploy-stack-with-docker-asset.integtest.ts +11 -0
  222. package/tests/cli-integ-tests/cdk-deploy-stack-with-lambda-asset-to-object-lock-enabled-asset-bucket.integtest.d.ts +1 -0
  223. package/tests/cli-integ-tests/cdk-deploy-stack-with-lambda-asset-to-object-lock-enabled-asset-bucket.integtest.js +39 -0
  224. package/tests/cli-integ-tests/cdk-deploy-stack-with-lambda-asset-to-object-lock-enabled-asset-bucket.integtest.ts +42 -0
  225. package/tests/cli-integ-tests/cdk-deploy-stack-without-resource.integtest.d.ts +1 -0
  226. package/tests/cli-integ-tests/cdk-deploy-stack-without-resource.integtest.js +17 -0
  227. package/tests/cli-integ-tests/cdk-deploy-stack-without-resource.integtest.ts +32 -0
  228. package/tests/cli-integ-tests/cdk-deploy-wildcard-with-outputs.integtest.d.ts +1 -0
  229. package/tests/cli-integ-tests/cdk-deploy-wildcard-with-outputs.integtest.js +23 -0
  230. package/tests/cli-integ-tests/cdk-deploy-wildcard-with-outputs.integtest.ts +28 -0
  231. package/tests/cli-integ-tests/cdk-deploy-with-import-existing-resources-true.integtest.d.ts +1 -0
  232. package/tests/cli-integ-tests/cdk-deploy-with-import-existing-resources-true.integtest.js +28 -0
  233. package/tests/cli-integ-tests/cdk-deploy-with-import-existing-resources-true.integtest.ts +29 -0
  234. package/tests/cli-integ-tests/cdk-deploy-with-method-direct-and-import-existing-resources-fails.integtest.d.ts +1 -0
  235. package/tests/cli-integ-tests/cdk-deploy-with-method-direct-and-import-existing-resources-fails.integtest.js +16 -0
  236. package/tests/cli-integ-tests/cdk-deploy-with-method-direct-and-import-existing-resources-fails.integtest.ts +17 -0
  237. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-flag.integtest.d.ts +1 -0
  238. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-flag.integtest.js +28 -0
  239. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-flag.integtest.ts +36 -0
  240. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop-and-flag.integtest.d.ts +1 -0
  241. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop-and-flag.integtest.js +37 -0
  242. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop-and-flag.integtest.ts +45 -0
  243. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop.integtest.d.ts +1 -0
  244. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop.integtest.js +31 -0
  245. package/tests/cli-integ-tests/cdk-deploy-with-notification-arn-as-prop.integtest.ts +37 -0
  246. package/tests/cli-integ-tests/cdk-deploy-with-parameters-multi.integtest.d.ts +1 -0
  247. package/tests/cli-integ-tests/cdk-deploy-with-parameters-multi.integtest.js +26 -0
  248. package/tests/cli-integ-tests/cdk-deploy-with-parameters-multi.integtest.ts +33 -0
  249. package/tests/cli-integ-tests/cdk-deploy-with-parameters.integtest.d.ts +1 -0
  250. package/tests/cli-integ-tests/cdk-deploy-with-parameters.integtest.js +20 -0
  251. package/tests/cli-integ-tests/cdk-deploy-with-parameters.integtest.ts +26 -0
  252. package/tests/cli-integ-tests/cdk-deploy-with-role.integtest.d.ts +1 -0
  253. package/tests/cli-integ-tests/cdk-deploy-with-role.integtest.js +97 -0
  254. package/tests/cli-integ-tests/cdk-deploy-with-role.integtest.ts +119 -0
  255. package/tests/cli-integ-tests/cdk-deploy-with-wildcard-and-parameters.integtest.d.ts +1 -0
  256. package/tests/cli-integ-tests/cdk-deploy-with-wildcard-and-parameters.integtest.js +19 -0
  257. package/tests/cli-integ-tests/cdk-deploy-with-wildcard-and-parameters.integtest.ts +22 -0
  258. package/tests/cli-integ-tests/cdk-deploy-without-execute-a-named-change-set.integtest.d.ts +1 -0
  259. package/tests/cli-integ-tests/cdk-deploy-without-execute-a-named-change-set.integtest.js +28 -0
  260. package/tests/cli-integ-tests/cdk-deploy-without-execute-a-named-change-set.integtest.ts +36 -0
  261. package/tests/cli-integ-tests/cdk-deploy-without-import-existing-resources.integtest.d.ts +1 -0
  262. package/tests/cli-integ-tests/cdk-deploy-without-import-existing-resources.integtest.js +27 -0
  263. package/tests/cli-integ-tests/cdk-deploy-without-import-existing-resources.integtest.ts +28 -0
  264. package/tests/cli-integ-tests/cdk-deploy.integtest.d.ts +1 -0
  265. package/tests/cli-integ-tests/cdk-deploy.integtest.js +15 -0
  266. package/tests/cli-integ-tests/cdk-deploy.integtest.ts +20 -0
  267. package/tests/cli-integ-tests/cdk-destroy-interactive.integtest.d.ts +1 -0
  268. package/tests/cli-integ-tests/cdk-destroy-interactive.integtest.js +32 -0
  269. package/tests/cli-integ-tests/cdk-destroy-interactive.integtest.ts +36 -0
  270. package/tests/cli-integ-tests/cdk-doubly-nested-stack.integtest.d.ts +1 -0
  271. package/tests/cli-integ-tests/cdk-doubly-nested-stack.integtest.js +10 -0
  272. package/tests/cli-integ-tests/cdk-doubly-nested-stack.integtest.ts +12 -0
  273. package/tests/cli-integ-tests/cdk-enablediffnofail.integtest.d.ts +1 -0
  274. package/tests/cli-integ-tests/cdk-enablediffnofail.integtest.js +34 -0
  275. package/tests/cli-integ-tests/cdk-enablediffnofail.integtest.ts +44 -0
  276. package/tests/cli-integ-tests/cdk-failed-deploy-does-not-hang.integtest.d.ts +1 -0
  277. package/tests/cli-integ-tests/cdk-failed-deploy-does-not-hang.integtest.js +9 -0
  278. package/tests/cli-integ-tests/cdk-failed-deploy-does-not-hang.integtest.ts +12 -0
  279. package/tests/cli-integ-tests/cdk-fast-deploy.integtest.d.ts +1 -0
  280. package/tests/cli-integ-tests/cdk-fast-deploy.integtest.js +35 -0
  281. package/tests/cli-integ-tests/cdk-fast-deploy.integtest.ts +41 -0
  282. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-ecr-images.integtest.d.ts +1 -0
  283. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-ecr-images.integtest.js +39 -0
  284. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-ecr-images.integtest.ts +48 -0
  285. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-s3-objects.integtest.d.ts +1 -0
  286. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-s3-objects.integtest.js +43 -0
  287. package/tests/cli-integ-tests/cdk-gc-garbage-collection-deletes-unused-s3-objects.integtest.ts +51 -0
  288. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-ecr-images.integtest.d.ts +1 -0
  289. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-ecr-images.integtest.js +39 -0
  290. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-ecr-images.integtest.ts +48 -0
  291. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-s3-objects.integtest.d.ts +1 -0
  292. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-s3-objects.integtest.js +44 -0
  293. package/tests/cli-integ-tests/cdk-gc-garbage-collection-keeps-in-use-s3-objects.integtest.ts +52 -0
  294. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-ecr-images.integtest.d.ts +1 -0
  295. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-ecr-images.integtest.js +38 -0
  296. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-ecr-images.integtest.ts +47 -0
  297. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-s3-objects.integtest.d.ts +1 -0
  298. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-s3-objects.integtest.js +54 -0
  299. package/tests/cli-integ-tests/cdk-gc-garbage-collection-tags-unused-s3-objects.integtest.ts +63 -0
  300. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-ecr-images.integtest.d.ts +1 -0
  301. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-ecr-images.integtest.js +45 -0
  302. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-ecr-images.integtest.ts +55 -0
  303. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-s3-objects.integtest.d.ts +1 -0
  304. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-s3-objects.integtest.js +53 -0
  305. package/tests/cli-integ-tests/cdk-gc-garbage-collection-untags-in-use-s3-objects.integtest.ts +63 -0
  306. package/tests/cli-integ-tests/cdk-generating-and-loading-assembly.integtest.d.ts +1 -0
  307. package/tests/cli-integ-tests/cdk-generating-and-loading-assembly.integtest.js +44 -0
  308. package/tests/cli-integ-tests/cdk-generating-and-loading-assembly.integtest.ts +52 -0
  309. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-detects-failed-deployment-and-errors.integtest.d.ts +1 -0
  310. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-detects-failed-deployment-and-errors.integtest.js +24 -0
  311. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-detects-failed-deployment-and-errors.integtest.ts +29 -0
  312. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-waits-for-deployment-to-complete.integtest.d.ts +1 -0
  313. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-waits-for-deployment-to-complete.integtest.js +33 -0
  314. package/tests/cli-integ-tests/cdk-hotswap-deployment-for-ecs-service-waits-for-deployment-to-complete.integtest.ts +45 -0
  315. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-appsync-apis-with-many-functions.integtest.d.ts +1 -0
  316. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-appsync-apis-with-many-functions.integtest.js +30 -0
  317. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-appsync-apis-with-many-functions.integtest.ts +36 -0
  318. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-ecs-service.integtest.d.ts +1 -0
  319. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-ecs-service.integtest.js +33 -0
  320. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-ecs-service.integtest.ts +41 -0
  321. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-fn::importvalue-intrinsic.integtest.d.ts +1 -0
  322. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-fn::importvalue-intrinsic.integtest.js +46 -0
  323. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-fn::importvalue-intrinsic.integtest.ts +53 -0
  324. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-lambda-functions-description-and-environment-variables.integtest.d.ts +1 -0
  325. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-lambda-functions-description-and-environment-variables.integtest.js +36 -0
  326. package/tests/cli-integ-tests/cdk-hotswap-deployment-supports-lambda-functions-description-and-environment-variables.integtest.ts +43 -0
  327. package/tests/cli-integ-tests/cdk-hotswap-ecs-deployment-respects-properties-override.integtest.d.ts +1 -0
  328. package/tests/cli-integ-tests/cdk-hotswap-ecs-deployment-respects-properties-override.integtest.js +51 -0
  329. package/tests/cli-integ-tests/cdk-hotswap-ecs-deployment-respects-properties-override.integtest.ts +59 -0
  330. package/tests/cli-integ-tests/cdk-iam-diff.integtest.d.ts +1 -0
  331. package/tests/cli-integ-tests/cdk-iam-diff.integtest.js +18 -0
  332. package/tests/cli-integ-tests/cdk-iam-diff.integtest.ts +23 -0
  333. package/tests/cli-integ-tests/cdk-import-interactive.integtest.d.ts +1 -0
  334. package/tests/cli-integ-tests/cdk-import-interactive.integtest.js +46 -0
  335. package/tests/cli-integ-tests/cdk-import-interactive.integtest.ts +53 -0
  336. package/tests/cli-integ-tests/cdk-lib-cli-lib-deploy.integtest.d.ts +1 -0
  337. package/tests/cli-integ-tests/cdk-lib-cli-lib-deploy.integtest.js +27 -0
  338. package/tests/cli-integ-tests/cdk-lib-cli-lib-deploy.integtest.ts +32 -0
  339. package/tests/cli-integ-tests/cdk-lib-cli-lib-list.integtest.d.ts +1 -0
  340. package/tests/cli-integ-tests/cdk-lib-cli-lib-list.integtest.js +9 -0
  341. package/tests/cli-integ-tests/cdk-lib-cli-lib-list.integtest.ts +12 -0
  342. package/tests/cli-integ-tests/cdk-lib-cli-lib-synth.integtest.d.ts +1 -0
  343. package/tests/cli-integ-tests/cdk-lib-cli-lib-synth.integtest.js +22 -0
  344. package/tests/cli-integ-tests/cdk-lib-cli-lib-synth.integtest.ts +27 -0
  345. package/tests/cli-integ-tests/cdk-lib-security-related-changes-without-a-cli-are-expected-to-fail-when-approval-is-required.integtest.d.ts +1 -0
  346. package/tests/cli-integ-tests/cdk-lib-security-related-changes-without-a-cli-are-expected-to-fail-when-approval-is-required.integtest.js +20 -0
  347. package/tests/cli-integ-tests/cdk-lib-security-related-changes-without-a-cli-are-expected-to-fail-when-approval-is-required.integtest.ts +32 -0
  348. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-csharp.integtest.d.ts +1 -0
  349. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-csharp.integtest.js +9 -0
  350. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-csharp.integtest.ts +11 -0
  351. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-java.integtest.d.ts +1 -0
  352. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-java.integtest.js +9 -0
  353. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-java.integtest.ts +11 -0
  354. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-python.integtest.d.ts +1 -0
  355. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-python.integtest.js +9 -0
  356. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-python.integtest.ts +11 -0
  357. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-typescript.integtest.d.ts +1 -0
  358. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-typescript.integtest.js +9 -0
  359. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate--from-stack-creates-deployable-app-typescript.integtest.ts +11 -0
  360. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-csharp.integtest.d.ts +1 -0
  361. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-csharp.integtest.js +9 -0
  362. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-csharp.integtest.ts +13 -0
  363. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-java.integtest.d.ts +1 -0
  364. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-java.integtest.js +9 -0
  365. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-java.integtest.ts +13 -0
  366. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-python.integtest.d.ts +1 -0
  367. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-python.integtest.js +9 -0
  368. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-python.integtest.ts +13 -0
  369. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-typescript.integtest.d.ts +1 -0
  370. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-typescript.integtest.js +9 -0
  371. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-deploys-successfully-typescript.integtest.ts +13 -0
  372. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-generates-migrate.json.integtest.d.ts +1 -0
  373. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-generates-migrate.json.integtest.js +16 -0
  374. package/tests/cli-integ-tests/cdk-migrate/cdk-migrate-generates-migrate.json.integtest.ts +20 -0
  375. package/tests/cli-integ-tests/cdk-migrate/testcase.d.ts +3 -0
  376. package/tests/cli-integ-tests/cdk-migrate/testcase.js +55 -0
  377. package/tests/cli-integ-tests/cdk-migrate/testcase.ts +69 -0
  378. package/tests/cli-integ-tests/cdk-nested-stack-with-parameters.integtest.d.ts +1 -0
  379. package/tests/cli-integ-tests/cdk-nested-stack-with-parameters.integtest.js +22 -0
  380. package/tests/cli-integ-tests/cdk-nested-stack-with-parameters.integtest.ts +28 -0
  381. package/tests/cli-integ-tests/cdk-requests-go-through-a-proxy-when-configured.integtest.d.ts +1 -0
  382. package/tests/cli-integ-tests/cdk-requests-go-through-a-proxy-when-configured.integtest.js +36 -0
  383. package/tests/cli-integ-tests/cdk-requests-go-through-a-proxy-when-configured.integtest.ts +39 -0
  384. package/tests/cli-integ-tests/cdk-sam-can-locally-test-the-synthesized-cdk-application.integtest.d.ts +1 -0
  385. package/tests/cli-integ-tests/cdk-sam-can-locally-test-the-synthesized-cdk-application.integtest.js +14 -0
  386. package/tests/cli-integ-tests/cdk-sam-can-locally-test-the-synthesized-cdk-application.integtest.ts +25 -0
  387. package/tests/cli-integ-tests/cdk-security-related-changes-without-a-cli-are-expected-to-fail.integtest.d.ts +1 -0
  388. package/tests/cli-integ-tests/cdk-security-related-changes-without-a-cli-are-expected-to-fail.integtest.js +20 -0
  389. package/tests/cli-integ-tests/cdk-security-related-changes-without-a-cli-are-expected-to-fail.integtest.ts +30 -0
  390. package/tests/cli-integ-tests/cdk-skips-notice-refresh.integtest.d.ts +6 -0
  391. package/tests/cli-integ-tests/cdk-skips-notice-refresh.integtest.js +22 -0
  392. package/tests/cli-integ-tests/cdk-skips-notice-refresh.integtest.ts +26 -0
  393. package/tests/cli-integ-tests/cdk-ssm-parameter-provider-error.integtest.d.ts +1 -0
  394. package/tests/cli-integ-tests/cdk-ssm-parameter-provider-error.integtest.js +10 -0
  395. package/tests/cli-integ-tests/cdk-ssm-parameter-provider-error.integtest.ts +18 -0
  396. package/tests/cli-integ-tests/cdk-stack-in-update_rollback_complete-state-can-be-updated.integtest.d.ts +1 -0
  397. package/tests/cli-integ-tests/cdk-stack-in-update_rollback_complete-state-can-be-updated.integtest.js +41 -0
  398. package/tests/cli-integ-tests/cdk-stack-in-update_rollback_complete-state-can-be-updated.integtest.ts +59 -0
  399. package/tests/cli-integ-tests/cdk-stage-with-bundled-lambda-function.integtest.d.ts +1 -0
  400. package/tests/cli-integ-tests/cdk-stage-with-bundled-lambda-function.integtest.js +10 -0
  401. package/tests/cli-integ-tests/cdk-stage-with-bundled-lambda-function.integtest.ts +13 -0
  402. package/tests/cli-integ-tests/cdk-synth---quiet-can-be-specified-in-cdk.json.integtest.d.ts +1 -0
  403. package/tests/cli-integ-tests/cdk-synth---quiet-can-be-specified-in-cdk.json.integtest.js +17 -0
  404. package/tests/cli-integ-tests/cdk-synth---quiet-can-be-specified-in-cdk.json.integtest.ts +20 -0
  405. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-can-be-suppressed.integtest.d.ts +1 -0
  406. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-can-be-suppressed.integtest.js +12 -0
  407. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-can-be-suppressed.integtest.ts +15 -0
  408. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-leads-to-failure.integtest.d.ts +1 -0
  409. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-leads-to-failure.integtest.js +14 -0
  410. package/tests/cli-integ-tests/cdk-synthing-a-stage-with-errors-leads-to-failure.integtest.ts +18 -0
  411. package/tests/cli-integ-tests/cdk-templates-on-disk-contain-metadata-resource.integtest.d.ts +1 -0
  412. package/tests/cli-integ-tests/cdk-templates-on-disk-contain-metadata-resource.integtest.js +18 -0
  413. package/tests/cli-integ-tests/cdk-templates-on-disk-contain-metadata-resource.integtest.ts +25 -0
  414. package/tests/cli-integ-tests/cdk-termination-protection.integtest.d.ts +1 -0
  415. package/tests/cli-integ-tests/cdk-termination-protection.integtest.js +14 -0
  416. package/tests/cli-integ-tests/cdk-termination-protection.integtest.ts +19 -0
  417. package/tests/cli-integ-tests/cdk-test-cdk-rollback---force.integtest.d.ts +1 -0
  418. package/tests/cli-integ-tests/cdk-test-cdk-rollback---force.integtest.js +40 -0
  419. package/tests/cli-integ-tests/cdk-test-cdk-rollback---force.integtest.ts +48 -0
  420. package/tests/cli-integ-tests/cdk-test-cdk-rollback.integtest.d.ts +1 -0
  421. package/tests/cli-integ-tests/cdk-test-cdk-rollback.integtest.js +33 -0
  422. package/tests/cli-integ-tests/cdk-test-cdk-rollback.integtest.ts +38 -0
  423. package/tests/cli-integ-tests/cdk-test-migrate-deployment-for-app-with-localfile-source-in-migrate.json.integtest.d.ts +1 -0
  424. package/tests/cli-integ-tests/cdk-test-migrate-deployment-for-app-with-localfile-source-in-migrate.json.integtest.js +45 -0
  425. package/tests/cli-integ-tests/cdk-test-migrate-deployment-for-app-with-localfile-source-in-migrate.json.integtest.ts +56 -0
  426. package/tests/cli-integ-tests/cdk-test-resource-import-with-construct-that-requires-bundling.integtest.d.ts +6 -0
  427. package/tests/cli-integ-tests/cdk-test-resource-import-with-construct-that-requires-bundling.integtest.js +59 -0
  428. package/tests/cli-integ-tests/cdk-test-resource-import-with-construct-that-requires-bundling.integtest.ts +74 -0
  429. package/tests/cli-integ-tests/cdk-test-resource-import.integtest.d.ts +1 -0
  430. package/tests/cli-integ-tests/cdk-test-resource-import.integtest.js +51 -0
  431. package/tests/cli-integ-tests/cdk-test-resource-import.integtest.ts +64 -0
  432. package/tests/cli-integ-tests/cdk-two-ways-of-showing-the-version.integtest.d.ts +1 -0
  433. package/tests/cli-integ-tests/cdk-two-ways-of-showing-the-version.integtest.js +10 -0
  434. package/tests/cli-integ-tests/cdk-two-ways-of-showing-the-version.integtest.ts +14 -0
  435. package/tests/cli-integ-tests/cdk-update-to-stack-in-rollback_complete-state-will-delete-stack-and-create-a-new-one.integtest.d.ts +1 -0
  436. package/tests/cli-integ-tests/cdk-update-to-stack-in-rollback_complete-state-will-delete-stack-and-create-a-new-one.integtest.js +34 -0
  437. package/tests/cli-integ-tests/cdk-update-to-stack-in-rollback_complete-state-will-delete-stack-and-create-a-new-one.integtest.ts +47 -0
  438. package/tests/cli-integ-tests/cdk-vpc-lookup.integtest.d.ts +1 -0
  439. package/tests/cli-integ-tests/cdk-vpc-lookup.integtest.js +21 -0
  440. package/tests/cli-integ-tests/cdk-vpc-lookup.integtest.ts +26 -0
  441. package/tests/cli-integ-tests/proxy.integtest.js +1 -2
  442. package/tests/cli-integ-tests/proxy.integtest.ts +0 -1
  443. package/tests/cli-integ-tests/bootstrapping.integtest.js +0 -431
  444. package/tests/cli-integ-tests/bootstrapping.integtest.ts +0 -517
  445. package/tests/cli-integ-tests/cli-lib.integtest.js +0 -62
  446. package/tests/cli-integ-tests/cli-lib.integtest.ts +0 -90
  447. package/tests/cli-integ-tests/cli.integtest.js +0 -2187
  448. package/tests/cli-integ-tests/cli.integtest.ts +0 -2969
  449. package/tests/cli-integ-tests/garbage-collection.integtest.js +0 -314
  450. package/tests/cli-integ-tests/garbage-collection.integtest.ts +0 -392
  451. /package/tests/cli-integ-tests/{bootstrapping.integtest.d.ts → cdk---exclusively-selects-only-selected-stack.integtest.d.ts} +0 -0
  452. /package/tests/cli-integ-tests/{cli-lib.integtest.d.ts → cdk-assets/cdk-assets-uses-profile.integtest.d.ts} +0 -0
  453. /package/tests/cli-integ-tests/{cli.integtest.d.ts → cdk-automatic-ordering-with-concurrency.integtest.d.ts} +0 -0
  454. /package/tests/cli-integ-tests/{garbage-collection.integtest.d.ts → cdk-automatic-ordering.integtest.d.ts} +0 -0
@@ -1,2969 +0,0 @@
1
- import { existsSync, promises as fs } from 'fs';
2
- import * as os from 'os';
3
- import * as path from 'path';
4
- import {
5
- CreateStackCommand,
6
- DescribeStackResourcesCommand,
7
- DescribeStacksCommand,
8
- GetTemplateCommand,
9
- ListChangeSetsCommand,
10
- UpdateStackCommand,
11
- waitUntilStackUpdateComplete,
12
- } from '@aws-sdk/client-cloudformation';
13
- import { DescribeServicesCommand } from '@aws-sdk/client-ecs';
14
- import {
15
- CreateRoleCommand,
16
- DeleteRoleCommand,
17
- DeleteRolePolicyCommand,
18
- ListRolePoliciesCommand,
19
- PutRolePolicyCommand,
20
- } from '@aws-sdk/client-iam';
21
- import { InvokeCommand } from '@aws-sdk/client-lambda';
22
- import { PutObjectLockConfigurationCommand } from '@aws-sdk/client-s3';
23
- import { CreateTopicCommand, DeleteTopicCommand } from '@aws-sdk/client-sns';
24
- import { AssumeRoleCommand, GetCallerIdentityCommand } from '@aws-sdk/client-sts';
25
- import {
26
- cloneDirectory,
27
- integTest,
28
- randomInteger,
29
- randomString,
30
- RESOURCES_DIR,
31
- retry,
32
- shell,
33
- sleep,
34
- withCDKMigrateFixture,
35
- withDefaultFixture,
36
- withExtendedTimeoutFixture,
37
- withoutBootstrap,
38
- withSamIntegrationFixture,
39
- withSpecificFixture,
40
- } from '../../lib';
41
- import { awsActionsFromRequests, startProxyServer } from '../../lib/proxy';
42
-
43
- jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
44
-
45
- describe('ci', () => {
46
- integTest(
47
- 'output to stderr',
48
- withDefaultFixture(async (fixture) => {
49
- const deployOutput = await fixture.cdkDeploy('test-2', { captureStderr: true, onlyStderr: true });
50
- const diffOutput = await fixture.cdk(['diff', fixture.fullStackName('test-2')], {
51
- captureStderr: true,
52
- onlyStderr: true,
53
- });
54
- const destroyOutput = await fixture.cdkDestroy('test-2', { captureStderr: true, onlyStderr: true });
55
- expect(deployOutput).not.toEqual('');
56
- expect(destroyOutput).not.toEqual('');
57
- expect(diffOutput).not.toEqual('');
58
- }),
59
- );
60
- describe('ci=true', () => {
61
- integTest(
62
- 'output to stdout',
63
- withDefaultFixture(async (fixture) => {
64
- const execOptions = {
65
- captureStderr: true,
66
- onlyStderr: true,
67
- modEnv: {
68
- CI: 'true',
69
- JSII_SILENCE_WARNING_KNOWN_BROKEN_NODE_VERSION: 'true',
70
- JSII_SILENCE_WARNING_UNTESTED_NODE_VERSION: 'true',
71
- JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: 'true',
72
- },
73
- };
74
-
75
- const deployOutput = await fixture.cdkDeploy('test-2', execOptions);
76
- const diffOutput = await fixture.cdk(['diff', fixture.fullStackName('test-2')], execOptions);
77
- const destroyOutput = await fixture.cdkDestroy('test-2', execOptions);
78
- expect(deployOutput).toEqual('');
79
- expect(destroyOutput).toEqual('');
80
- expect(diffOutput).toEqual('');
81
- }),
82
- );
83
- });
84
- });
85
-
86
- integTest(
87
- 'VPC Lookup',
88
- withDefaultFixture(async (fixture) => {
89
- fixture.log('Making sure we are clean before starting.');
90
- await fixture.cdkDestroy('define-vpc', { modEnv: { ENABLE_VPC_TESTING: 'DEFINE' } });
91
-
92
- fixture.log('Setting up: creating a VPC with known tags');
93
- await fixture.cdkDeploy('define-vpc', { modEnv: { ENABLE_VPC_TESTING: 'DEFINE' } });
94
- fixture.log('Setup complete!');
95
-
96
- fixture.log('Verifying we can now import that VPC');
97
- await fixture.cdkDeploy('import-vpc', { modEnv: { ENABLE_VPC_TESTING: 'IMPORT' } });
98
- }),
99
- );
100
-
101
- // testing a construct with a builtin Nodejs Lambda Function.
102
- // In this case we are testing the s3.Bucket construct with the
103
- // autoDeleteObjects prop set to true, which creates a Lambda backed
104
- // CustomResource. Since the compiled Lambda code (e.g. __entrypoint__.js)
105
- // is bundled as part of the CDK package, we want to make sure we don't
106
- // introduce changes to the compiled code that could prevent the Lambda from
107
- // executing. If we do, this test will timeout and fail.
108
- integTest(
109
- 'Construct with builtin Lambda function',
110
- withDefaultFixture(async (fixture) => {
111
- await fixture.cdkDeploy('builtin-lambda-function');
112
- fixture.log('Setup complete!');
113
- await fixture.cdkDestroy('builtin-lambda-function');
114
- }),
115
- );
116
-
117
- // this is to ensure that asset bundling for apps under a stage does not break
118
- integTest(
119
- 'Stage with bundled Lambda function',
120
- withDefaultFixture(async (fixture) => {
121
- await fixture.cdkDeploy('bundling-stage/BundlingStack');
122
- fixture.log('Setup complete!');
123
- await fixture.cdkDestroy('bundling-stage/BundlingStack');
124
- }),
125
- );
126
-
127
- integTest(
128
- 'Two ways of showing the version',
129
- withDefaultFixture(async (fixture) => {
130
- const version1 = await fixture.cdk(['version'], { verbose: false });
131
- const version2 = await fixture.cdk(['--version'], { verbose: false });
132
-
133
- expect(version1).toEqual(version2);
134
- }),
135
- );
136
-
137
- integTest(
138
- 'Termination protection',
139
- withDefaultFixture(async (fixture) => {
140
- const stackName = 'termination-protection';
141
- await fixture.cdkDeploy(stackName);
142
-
143
- // Try a destroy that should fail
144
- await expect(fixture.cdkDestroy(stackName)).rejects.toThrow('exited with error');
145
-
146
- // Can update termination protection even though the change set doesn't contain changes
147
- await fixture.cdkDeploy(stackName, { modEnv: { TERMINATION_PROTECTION: 'FALSE' } });
148
- await fixture.cdkDestroy(stackName);
149
- }),
150
- );
151
-
152
- integTest(
153
- 'cdk synth',
154
- withDefaultFixture(async (fixture) => {
155
- await fixture.cdk(['synth', fixture.fullStackName('test-1')]);
156
- expect(fixture.template('test-1')).toEqual(
157
- expect.objectContaining({
158
- Resources: {
159
- topic69831491: {
160
- Type: 'AWS::SNS::Topic',
161
- Metadata: {
162
- 'aws:cdk:path': `${fixture.stackNamePrefix}-test-1/topic/Resource`,
163
- },
164
- },
165
- },
166
- }),
167
- );
168
-
169
- expect(
170
- await fixture.cdkSynth({
171
- options: [fixture.fullStackName('test-1')],
172
- }),
173
- ).not.toEqual(
174
- expect.stringContaining(`
175
- Rules:
176
- CheckBootstrapVersion:`),
177
- );
178
-
179
- await fixture.cdk(['synth', fixture.fullStackName('test-2')], { verbose: false });
180
- expect(fixture.template('test-2')).toEqual(
181
- expect.objectContaining({
182
- Resources: {
183
- topic152D84A37: {
184
- Type: 'AWS::SNS::Topic',
185
- Metadata: {
186
- 'aws:cdk:path': `${fixture.stackNamePrefix}-test-2/topic1/Resource`,
187
- },
188
- },
189
- topic2A4FB547F: {
190
- Type: 'AWS::SNS::Topic',
191
- Metadata: {
192
- 'aws:cdk:path': `${fixture.stackNamePrefix}-test-2/topic2/Resource`,
193
- },
194
- },
195
- },
196
- }),
197
- );
198
- }),
199
- );
200
-
201
- integTest(
202
- 'ssm parameter provider error',
203
- withDefaultFixture(async (fixture) => {
204
- await expect(
205
- fixture.cdk(
206
- ['synth', fixture.fullStackName('missing-ssm-parameter'), '-c', 'test:ssm-parameter-name=/does/not/exist'],
207
- {
208
- allowErrExit: true,
209
- },
210
- ),
211
- ).resolves.toContain('SSM parameter not available in account');
212
- }),
213
- );
214
-
215
- integTest(
216
- 'automatic ordering',
217
- withDefaultFixture(async (fixture) => {
218
- // Deploy the consuming stack which will include the producing stack
219
- await fixture.cdkDeploy('order-consuming');
220
-
221
- // Destroy the providing stack which will include the consuming stack
222
- await fixture.cdkDestroy('order-providing');
223
- }),
224
- );
225
-
226
- integTest(
227
- 'automatic ordering with concurrency',
228
- withDefaultFixture(async (fixture) => {
229
- // Deploy the consuming stack which will include the producing stack
230
- await fixture.cdkDeploy('order-consuming', { options: ['--concurrency', '2'] });
231
-
232
- // Destroy the providing stack which will include the consuming stack
233
- await fixture.cdkDestroy('order-providing');
234
- }),
235
- );
236
-
237
- integTest(
238
- '--exclusively selects only selected stack',
239
- withDefaultFixture(async (fixture) => {
240
- // Deploy the "depends-on-failed" stack, with --exclusively. It will NOT fail (because
241
- // of --exclusively) and it WILL create an output we can check for to confirm that it did
242
- // get deployed.
243
- const outputsFile = path.join(fixture.integTestDir, 'outputs', 'outputs.json');
244
- await fs.mkdir(path.dirname(outputsFile), { recursive: true });
245
-
246
- await fixture.cdkDeploy('depends-on-failed', {
247
- options: ['--exclusively', '--outputs-file', outputsFile],
248
- });
249
-
250
- // Verify the output to see that the stack deployed
251
- const outputs = JSON.parse((await fs.readFile(outputsFile, { encoding: 'utf-8' })).toString());
252
- expect(outputs).toEqual({
253
- [`${fixture.stackNamePrefix}-depends-on-failed`]: {
254
- TopicName: `${fixture.stackNamePrefix}-depends-on-failedMyTopic`,
255
- },
256
- });
257
- }),
258
- );
259
-
260
- integTest(
261
- 'context setting',
262
- withDefaultFixture(async (fixture) => {
263
- await fs.writeFile(
264
- path.join(fixture.integTestDir, 'cdk.context.json'),
265
- JSON.stringify({
266
- contextkey: 'this is the context value',
267
- }),
268
- );
269
- try {
270
- await expect(fixture.cdk(['context'])).resolves.toContain('this is the context value');
271
-
272
- // Test that deleting the contextkey works
273
- await fixture.cdk(['context', '--reset', 'contextkey']);
274
- await expect(fixture.cdk(['context'])).resolves.not.toContain('this is the context value');
275
-
276
- // Test that forced delete of the context key does not throw
277
- await fixture.cdk(['context', '-f', '--reset', 'contextkey']);
278
- } finally {
279
- await fs.unlink(path.join(fixture.integTestDir, 'cdk.context.json'));
280
- }
281
- }),
282
- );
283
-
284
- // bootstrapping also performs synthesis. As it turns out, bootstrap-stage synthesis still causes the lookups to be cached, meaning that the lookup never
285
- // happens when we actually call `cdk synth --no-lookups`. This results in the error never being thrown, because it never tries to lookup anything.
286
- // Fix this by not trying to bootstrap; there's no need to bootstrap anyway, since the test never tries to deploy anything.
287
- integTest(
288
- 'context in stage propagates to top',
289
- withoutBootstrap(async (fixture) => {
290
- await expect(
291
- fixture.cdkSynth({
292
- // This will make it error to prove that the context bubbles up, and also that we can fail on command
293
- options: ['--no-lookups'],
294
- modEnv: {
295
- INTEG_STACK_SET: 'stage-using-context',
296
- },
297
- allowErrExit: true,
298
- }),
299
- ).resolves.toContain('Context lookups have been disabled');
300
- }),
301
- );
302
-
303
- integTest(
304
- 'deploy',
305
- withDefaultFixture(async (fixture) => {
306
- const stackArn = await fixture.cdkDeploy('test-2', { captureStderr: false });
307
-
308
- // verify the number of resources in the stack
309
- const response = await fixture.aws.cloudFormation.send(
310
- new DescribeStackResourcesCommand({
311
- StackName: stackArn,
312
- }),
313
- );
314
- expect(response.StackResources?.length).toEqual(2);
315
- }),
316
- );
317
-
318
- integTest(
319
- 'deploy --method=direct',
320
- withDefaultFixture(async (fixture) => {
321
- const stackArn = await fixture.cdkDeploy('test-2', {
322
- options: ['--method=direct'],
323
- captureStderr: false,
324
- });
325
-
326
- // verify the number of resources in the stack
327
- const response = await fixture.aws.cloudFormation.send(
328
- new DescribeStackResourcesCommand({
329
- StackName: stackArn,
330
- }),
331
- );
332
- expect(response.StackResources?.length).toBeGreaterThan(0);
333
- }),
334
- );
335
-
336
- integTest(
337
- 'deploy all',
338
- withDefaultFixture(async (fixture) => {
339
- const arns = await fixture.cdkDeploy('test-*', { captureStderr: false });
340
-
341
- // verify that we only deployed both stacks (there are 2 ARNs in the output)
342
- expect(arns.split('\n').length).toEqual(2);
343
- }),
344
- );
345
-
346
- integTest(
347
- 'deploy all concurrently',
348
- withDefaultFixture(async (fixture) => {
349
- const arns = await fixture.cdkDeploy('test-*', {
350
- captureStderr: false,
351
- options: ['--concurrency', '2'],
352
- });
353
-
354
- // verify that we only deployed both stacks (there are 2 ARNs in the output)
355
- expect(arns.split('\n').length).toEqual(2);
356
- }),
357
- );
358
-
359
- integTest('doubly nested stack',
360
- withDefaultFixture(async (fixture) => {
361
- await fixture.cdkDeploy('with-doubly-nested-stack', {
362
- captureStderr: false,
363
- });
364
- }),
365
- );
366
-
367
- integTest(
368
- 'nested stack with parameters',
369
- withDefaultFixture(async (fixture) => {
370
- // STACK_NAME_PREFIX is used in MyTopicParam to allow multiple instances
371
- // of this test to run in parallel, othewise they will attempt to create the same SNS topic.
372
- const stackArn = await fixture.cdkDeploy('with-nested-stack-using-parameters', {
373
- options: ['--parameters', `MyTopicParam=${fixture.stackNamePrefix}ThereIsNoSpoon`],
374
- captureStderr: false,
375
- });
376
-
377
- // verify that we only deployed a single stack (there's a single ARN in the output)
378
- expect(stackArn.split('\n').length).toEqual(1);
379
-
380
- // verify the number of resources in the stack
381
- const response = await fixture.aws.cloudFormation.send(
382
- new DescribeStackResourcesCommand({
383
- StackName: stackArn,
384
- }),
385
- );
386
- expect(response.StackResources?.length).toEqual(1);
387
- }),
388
- );
389
-
390
- integTest(
391
- 'deploy without execute a named change set',
392
- withDefaultFixture(async (fixture) => {
393
- const changeSetName = 'custom-change-set-name';
394
- const stackArn = await fixture.cdkDeploy('test-2', {
395
- options: ['--no-execute', '--change-set-name', changeSetName],
396
- captureStderr: false,
397
- });
398
- // verify that we only deployed a single stack (there's a single ARN in the output)
399
- expect(stackArn.split('\n').length).toEqual(1);
400
-
401
- const response = await fixture.aws.cloudFormation.send(
402
- new DescribeStacksCommand({
403
- StackName: stackArn,
404
- }),
405
- );
406
- expect(response.Stacks?.[0].StackStatus).toEqual('REVIEW_IN_PROGRESS');
407
-
408
- // verify a change set was created with the provided name
409
- const changeSetResponse = await fixture.aws.cloudFormation.send(
410
- new ListChangeSetsCommand({
411
- StackName: stackArn,
412
- }),
413
- );
414
- const changeSets = changeSetResponse.Summaries || [];
415
- expect(changeSets.length).toEqual(1);
416
- expect(changeSets[0].ChangeSetName).toEqual(changeSetName);
417
- expect(changeSets[0].Status).toEqual('CREATE_COMPLETE');
418
- }),
419
- );
420
-
421
- integTest(
422
- 'security related changes without a CLI are expected to fail',
423
- withDefaultFixture(async (fixture) => {
424
- // redirect /dev/null to stdin, which means there will not be tty attached
425
- // since this stack includes security-related changes, the deployment should
426
- // immediately fail because we can't confirm the changes
427
- const stackName = 'iam-test';
428
- await expect(
429
- fixture.cdkDeploy(stackName, {
430
- options: ['<', '/dev/null'], // H4x, this only works because I happen to know we pass shell: true.
431
- neverRequireApproval: false,
432
- }),
433
- ).rejects.toThrow('exited with error');
434
-
435
- // Ensure stack was not deployed
436
- await expect(
437
- fixture.aws.cloudFormation.send(
438
- new DescribeStacksCommand({
439
- StackName: fixture.fullStackName(stackName),
440
- }),
441
- ),
442
- ).rejects.toThrow('does not exist');
443
- }),
444
- );
445
-
446
- integTest(
447
- 'deploy wildcard with outputs',
448
- withDefaultFixture(async (fixture) => {
449
- const outputsFile = path.join(fixture.integTestDir, 'outputs', 'outputs.json');
450
- await fs.mkdir(path.dirname(outputsFile), { recursive: true });
451
-
452
- await fixture.cdkDeploy(['outputs-test-*'], {
453
- options: ['--outputs-file', outputsFile],
454
- });
455
-
456
- const outputs = JSON.parse((await fs.readFile(outputsFile, { encoding: 'utf-8' })).toString());
457
- expect(outputs).toEqual({
458
- [`${fixture.stackNamePrefix}-outputs-test-1`]: {
459
- TopicName: `${fixture.stackNamePrefix}-outputs-test-1MyTopic`,
460
- },
461
- [`${fixture.stackNamePrefix}-outputs-test-2`]: {
462
- TopicName: `${fixture.stackNamePrefix}-outputs-test-2MyOtherTopic`,
463
- },
464
- });
465
- }),
466
- );
467
-
468
- integTest(
469
- 'deploy with parameters',
470
- withDefaultFixture(async (fixture) => {
471
- const stackArn = await fixture.cdkDeploy('param-test-1', {
472
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}bazinga`],
473
- captureStderr: false,
474
- });
475
-
476
- const response = await fixture.aws.cloudFormation.send(
477
- new DescribeStacksCommand({
478
- StackName: stackArn,
479
- }),
480
- );
481
-
482
- expect(response.Stacks?.[0].Parameters).toContainEqual({
483
- ParameterKey: 'TopicNameParam',
484
- ParameterValue: `${fixture.stackNamePrefix}bazinga`,
485
- });
486
- }),
487
- );
488
-
489
- integTest('deploy with import-existing-resources true', withDefaultFixture(async (fixture) => {
490
- const stackArn = await fixture.cdkDeploy('test-2', {
491
- options: ['--no-execute', '--import-existing-resources'],
492
- captureStderr: false,
493
- });
494
- // verify that we only deployed a single stack (there's a single ARN in the output)
495
- expect(stackArn.split('\n').length).toEqual(1);
496
-
497
- const response = await fixture.aws.cloudFormation.send(new DescribeStacksCommand({
498
- StackName: stackArn,
499
- }));
500
- expect(response.Stacks?.[0].StackStatus).toEqual('REVIEW_IN_PROGRESS');
501
-
502
- // verify a change set was successfully created
503
- // Here, we do not test whether a resource is actually imported, because that is a CloudFormation feature, not a CDK feature.
504
- const changeSetResponse = await fixture.aws.cloudFormation.send(new ListChangeSetsCommand({
505
- StackName: stackArn,
506
- }));
507
- const changeSets = changeSetResponse.Summaries || [];
508
- expect(changeSets.length).toEqual(1);
509
- expect(changeSets[0].Status).toEqual('CREATE_COMPLETE');
510
- expect(changeSets[0].ImportExistingResources).toEqual(true);
511
- }));
512
-
513
- integTest('deploy without import-existing-resources', withDefaultFixture(async (fixture) => {
514
- const stackArn = await fixture.cdkDeploy('test-2', {
515
- options: ['--no-execute'],
516
- captureStderr: false,
517
- });
518
- // verify that we only deployed a single stack (there's a single ARN in the output)
519
- expect(stackArn.split('\n').length).toEqual(1);
520
-
521
- const response = await fixture.aws.cloudFormation.send(new DescribeStacksCommand({
522
- StackName: stackArn,
523
- }));
524
- expect(response.Stacks?.[0].StackStatus).toEqual('REVIEW_IN_PROGRESS');
525
-
526
- // verify a change set was successfully created and ImportExistingResources = false
527
- const changeSetResponse = await fixture.aws.cloudFormation.send(new ListChangeSetsCommand({
528
- StackName: stackArn,
529
- }));
530
- const changeSets = changeSetResponse.Summaries || [];
531
- expect(changeSets.length).toEqual(1);
532
- expect(changeSets[0].Status).toEqual('CREATE_COMPLETE');
533
- expect(changeSets[0].ImportExistingResources).toEqual(false);
534
- }));
535
-
536
- integTest('deploy with method=direct and import-existing-resources fails', withDefaultFixture(async (fixture) => {
537
- const stackName = 'iam-test';
538
- await expect(fixture.cdkDeploy(stackName, {
539
- options: ['--import-existing-resources', '--method=direct'],
540
- })).rejects.toThrow('exited with error');
541
-
542
- // Ensure stack was not deployed
543
- await expect(fixture.aws.cloudFormation.send(new DescribeStacksCommand({
544
- StackName: fixture.fullStackName(stackName),
545
- }))).rejects.toThrow('does not exist');
546
- }));
547
-
548
- integTest(
549
- 'update to stack in ROLLBACK_COMPLETE state will delete stack and create a new one',
550
- withDefaultFixture(async (fixture) => {
551
- // GIVEN
552
- await expect(
553
- fixture.cdkDeploy('param-test-1', {
554
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}@aww`],
555
- captureStderr: false,
556
- }),
557
- ).rejects.toThrow('exited with error');
558
-
559
- const response = await fixture.aws.cloudFormation.send(
560
- new DescribeStacksCommand({
561
- StackName: fixture.fullStackName('param-test-1'),
562
- }),
563
- );
564
-
565
- const stackArn = response.Stacks?.[0].StackId;
566
- expect(response.Stacks?.[0].StackStatus).toEqual('ROLLBACK_COMPLETE');
567
-
568
- // WHEN
569
- const newStackArn = await fixture.cdkDeploy('param-test-1', {
570
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}allgood`],
571
- captureStderr: false,
572
- });
573
-
574
- const newStackResponse = await fixture.aws.cloudFormation.send(
575
- new DescribeStacksCommand({
576
- StackName: newStackArn,
577
- }),
578
- );
579
-
580
- // THEN
581
- expect(stackArn).not.toEqual(newStackArn); // new stack was created
582
- expect(newStackResponse.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
583
- expect(newStackResponse.Stacks?.[0].Parameters).toContainEqual({
584
- ParameterKey: 'TopicNameParam',
585
- ParameterValue: `${fixture.stackNamePrefix}allgood`,
586
- });
587
- }),
588
- );
589
-
590
- integTest(
591
- 'stack in UPDATE_ROLLBACK_COMPLETE state can be updated',
592
- withDefaultFixture(async (fixture) => {
593
- // GIVEN
594
- const stackArn = await fixture.cdkDeploy('param-test-1', {
595
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}nice`],
596
- captureStderr: false,
597
- });
598
-
599
- let response = await fixture.aws.cloudFormation.send(
600
- new DescribeStacksCommand({
601
- StackName: stackArn,
602
- }),
603
- );
604
-
605
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
606
-
607
- // bad parameter name with @ will put stack into UPDATE_ROLLBACK_COMPLETE
608
- await expect(
609
- fixture.cdkDeploy('param-test-1', {
610
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}@aww`],
611
- captureStderr: false,
612
- }),
613
- ).rejects.toThrow('exited with error');
614
-
615
- response = await fixture.aws.cloudFormation.send(
616
- new DescribeStacksCommand({
617
- StackName: stackArn,
618
- }),
619
- );
620
-
621
- expect(response.Stacks?.[0].StackStatus).toEqual('UPDATE_ROLLBACK_COMPLETE');
622
-
623
- // WHEN
624
- await fixture.cdkDeploy('param-test-1', {
625
- options: ['--parameters', `TopicNameParam=${fixture.stackNamePrefix}allgood`],
626
- captureStderr: false,
627
- });
628
-
629
- response = await fixture.aws.cloudFormation.send(
630
- new DescribeStacksCommand({
631
- StackName: stackArn,
632
- }),
633
- );
634
-
635
- // THEN
636
- expect(response.Stacks?.[0].StackStatus).toEqual('UPDATE_COMPLETE');
637
- expect(response.Stacks?.[0].Parameters).toContainEqual({
638
- ParameterKey: 'TopicNameParam',
639
- ParameterValue: `${fixture.stackNamePrefix}allgood`,
640
- });
641
- }),
642
- );
643
-
644
- integTest(
645
- 'deploy with wildcard and parameters',
646
- withDefaultFixture(async (fixture) => {
647
- await fixture.cdkDeploy('param-test-*', {
648
- options: [
649
- '--parameters',
650
- `${fixture.stackNamePrefix}-param-test-1:TopicNameParam=${fixture.stackNamePrefix}bazinga`,
651
- '--parameters',
652
- `${fixture.stackNamePrefix}-param-test-2:OtherTopicNameParam=${fixture.stackNamePrefix}ThatsMySpot`,
653
- '--parameters',
654
- `${fixture.stackNamePrefix}-param-test-3:DisplayNameParam=${fixture.stackNamePrefix}HeyThere`,
655
- '--parameters',
656
- `${fixture.stackNamePrefix}-param-test-3:OtherDisplayNameParam=${fixture.stackNamePrefix}AnotherOne`,
657
- ],
658
- });
659
- }),
660
- );
661
-
662
- integTest(
663
- 'deploy with parameters multi',
664
- withDefaultFixture(async (fixture) => {
665
- const paramVal1 = `${fixture.stackNamePrefix}bazinga`;
666
- const paramVal2 = `${fixture.stackNamePrefix}=jagshemash`;
667
-
668
- const stackArn = await fixture.cdkDeploy('param-test-3', {
669
- options: ['--parameters', `DisplayNameParam=${paramVal1}`, '--parameters', `OtherDisplayNameParam=${paramVal2}`],
670
- captureStderr: false,
671
- });
672
-
673
- const response = await fixture.aws.cloudFormation.send(
674
- new DescribeStacksCommand({
675
- StackName: stackArn,
676
- }),
677
- );
678
-
679
- expect(response.Stacks?.[0].Parameters).toContainEqual({
680
- ParameterKey: 'DisplayNameParam',
681
- ParameterValue: paramVal1,
682
- });
683
- expect(response.Stacks?.[0].Parameters).toContainEqual({
684
- ParameterKey: 'OtherDisplayNameParam',
685
- ParameterValue: paramVal2,
686
- });
687
- }),
688
- );
689
-
690
- integTest(
691
- 'deploy with notification ARN as flag',
692
- withDefaultFixture(async (fixture) => {
693
- const topicName = `${fixture.stackNamePrefix}-test-topic-flag`;
694
-
695
- const response = await fixture.aws.sns.send(new CreateTopicCommand({ Name: topicName }));
696
- const topicArn = response.TopicArn!;
697
-
698
- try {
699
- await fixture.cdkDeploy('notification-arns', {
700
- options: ['--notification-arns', topicArn],
701
- });
702
-
703
- // verify that the stack we deployed has our notification ARN
704
- const describeResponse = await fixture.aws.cloudFormation.send(
705
- new DescribeStacksCommand({
706
- StackName: fixture.fullStackName('notification-arns'),
707
- }),
708
- );
709
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([topicArn]);
710
- } finally {
711
- await fixture.aws.sns.send(
712
- new DeleteTopicCommand({
713
- TopicArn: topicArn,
714
- }),
715
- );
716
- }
717
- }),
718
- );
719
-
720
- integTest('deploy with notification ARN as prop', withDefaultFixture(async (fixture) => {
721
- const topicName = `${fixture.stackNamePrefix}-test-topic-prop`;
722
-
723
- const response = await fixture.aws.sns.send(new CreateTopicCommand({ Name: topicName }));
724
- const topicArn = response.TopicArn!;
725
-
726
- try {
727
- await fixture.cdkDeploy('notification-arns', {
728
- modEnv: {
729
- INTEG_NOTIFICATION_ARNS: topicArn,
730
-
731
- },
732
- });
733
-
734
- // verify that the stack we deployed has our notification ARN
735
- const describeResponse = await fixture.aws.cloudFormation.send(
736
- new DescribeStacksCommand({
737
- StackName: fixture.fullStackName('notification-arns'),
738
- }),
739
- );
740
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([topicArn]);
741
- } finally {
742
- await fixture.aws.sns.send(
743
- new DeleteTopicCommand({
744
- TopicArn: topicArn,
745
- }),
746
- );
747
- }
748
- }));
749
-
750
- // https://github.com/aws/aws-cdk/issues/32153
751
- integTest('deploy preserves existing notification arns when not specified', withDefaultFixture(async (fixture) => {
752
- const topicName = `${fixture.stackNamePrefix}-topic`;
753
-
754
- const response = await fixture.aws.sns.send(new CreateTopicCommand({ Name: topicName }));
755
- const topicArn = response.TopicArn!;
756
-
757
- try {
758
- await fixture.cdkDeploy('notification-arns');
759
-
760
- // add notification arns externally to cdk
761
- await fixture.aws.cloudFormation.send(
762
- new UpdateStackCommand({
763
- StackName: fixture.fullStackName('notification-arns'),
764
- UsePreviousTemplate: true,
765
- NotificationARNs: [topicArn],
766
- }),
767
- );
768
-
769
- await waitUntilStackUpdateComplete(
770
- {
771
- client: fixture.aws.cloudFormation,
772
- maxWaitTime: 600,
773
- },
774
- { StackName: fixture.fullStackName('notification-arns') },
775
- );
776
-
777
- // deploy again
778
- await fixture.cdkDeploy('notification-arns');
779
-
780
- // make sure the notification arn is preserved
781
- const describeResponse = await fixture.aws.cloudFormation.send(
782
- new DescribeStacksCommand({
783
- StackName: fixture.fullStackName('notification-arns'),
784
- }),
785
- );
786
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([topicArn]);
787
- } finally {
788
- await fixture.aws.sns.send(
789
- new DeleteTopicCommand({
790
- TopicArn: topicArn,
791
- }),
792
- );
793
- }
794
- }));
795
-
796
- integTest('deploy deletes ALL notification arns when empty array is passed', withDefaultFixture(async (fixture) => {
797
- const topicName = `${fixture.stackNamePrefix}-topic`;
798
-
799
- const response = await fixture.aws.sns.send(new CreateTopicCommand({ Name: topicName }));
800
- const topicArn = response.TopicArn!;
801
-
802
- try {
803
- await fixture.cdkDeploy('notification-arns', {
804
- modEnv: {
805
- INTEG_NOTIFICATION_ARNS: topicArn,
806
- },
807
- });
808
-
809
- // make sure the arn was added
810
- let describeResponse = await fixture.aws.cloudFormation.send(
811
- new DescribeStacksCommand({
812
- StackName: fixture.fullStackName('notification-arns'),
813
- }),
814
- );
815
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([topicArn]);
816
-
817
- // deploy again with empty array
818
- await fixture.cdkDeploy('notification-arns', {
819
- modEnv: {
820
- INTEG_NOTIFICATION_ARNS: '',
821
- },
822
- });
823
-
824
- // make sure the arn was deleted
825
- describeResponse = await fixture.aws.cloudFormation.send(
826
- new DescribeStacksCommand({
827
- StackName: fixture.fullStackName('notification-arns'),
828
- }),
829
- );
830
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([]);
831
- } finally {
832
- await fixture.aws.sns.send(
833
- new DeleteTopicCommand({
834
- TopicArn: topicArn,
835
- }),
836
- );
837
- }
838
- }));
839
-
840
- integTest('deploy with notification ARN as prop and flag', withDefaultFixture(async (fixture) => {
841
- const topic1Name = `${fixture.stackNamePrefix}-topic1`;
842
- const topic2Name = `${fixture.stackNamePrefix}-topic1`;
843
-
844
- const topic1Arn = (await fixture.aws.sns.send(new CreateTopicCommand({ Name: topic1Name }))).TopicArn!;
845
- const topic2Arn = (await fixture.aws.sns.send(new CreateTopicCommand({ Name: topic2Name }))).TopicArn!;
846
-
847
- try {
848
- await fixture.cdkDeploy('notification-arns', {
849
- modEnv: {
850
- INTEG_NOTIFICATION_ARNS: topic1Arn,
851
-
852
- },
853
- options: ['--notification-arns', topic2Arn],
854
- });
855
-
856
- // verify that the stack we deployed has our notification ARN
857
- const describeResponse = await fixture.aws.cloudFormation.send(
858
- new DescribeStacksCommand({
859
- StackName: fixture.fullStackName('notification-arns'),
860
- }),
861
- );
862
- expect(describeResponse.Stacks?.[0].NotificationARNs).toEqual([topic1Arn, topic2Arn]);
863
- } finally {
864
- await fixture.aws.sns.send(
865
- new DeleteTopicCommand({
866
- TopicArn: topic1Arn,
867
- }),
868
- );
869
- await fixture.aws.sns.send(
870
- new DeleteTopicCommand({
871
- TopicArn: topic2Arn,
872
- }),
873
- );
874
- }
875
- }));
876
-
877
- // NOTE: this doesn't currently work with modern-style synthesis, as the bootstrap
878
- // role by default will not have permission to iam:PassRole the created role.
879
- integTest(
880
- 'deploy with role',
881
- withDefaultFixture(async (fixture) => {
882
- if (fixture.packages.majorVersion() !== '1') {
883
- return; // Nothing to do
884
- }
885
-
886
- const roleName = `${fixture.stackNamePrefix}-test-role`;
887
-
888
- await deleteRole();
889
-
890
- const createResponse = await fixture.aws.iam.send(
891
- new CreateRoleCommand({
892
- RoleName: roleName,
893
- AssumeRolePolicyDocument: JSON.stringify({
894
- Version: '2012-10-17',
895
- Statement: [
896
- {
897
- Action: 'sts:AssumeRole',
898
- Principal: { Service: 'cloudformation.amazonaws.com' },
899
- Effect: 'Allow',
900
- },
901
- {
902
- Action: 'sts:AssumeRole',
903
- Principal: { AWS: (await fixture.aws.sts.send(new GetCallerIdentityCommand({}))).Arn },
904
- Effect: 'Allow',
905
- },
906
- ],
907
- }),
908
- }),
909
- );
910
-
911
- if (!createResponse.Role) {
912
- throw new Error('Role is expected to be present!!');
913
- }
914
-
915
- if (!createResponse.Role.Arn) {
916
- throw new Error('Role arn is expected to be present!!');
917
- }
918
-
919
- const roleArn = createResponse.Role.Arn;
920
- try {
921
- await fixture.aws.iam.send(
922
- new PutRolePolicyCommand({
923
- RoleName: roleName,
924
- PolicyName: 'DefaultPolicy',
925
- PolicyDocument: JSON.stringify({
926
- Version: '2012-10-17',
927
- Statement: [
928
- {
929
- Action: '*',
930
- Resource: '*',
931
- Effect: 'Allow',
932
- },
933
- ],
934
- }),
935
- }),
936
- );
937
-
938
- await retry(fixture.output, 'Trying to assume fresh role', retry.forSeconds(300), async () => {
939
- await fixture.aws.sts.send(
940
- new AssumeRoleCommand({
941
- RoleArn: roleArn,
942
- RoleSessionName: 'testing',
943
- }),
944
- );
945
- });
946
-
947
- // In principle, the role has replicated from 'us-east-1' to wherever we're testing.
948
- // Give it a little more sleep to make sure CloudFormation is not hitting a box
949
- // that doesn't have it yet.
950
- await sleep(5000);
951
-
952
- await fixture.cdkDeploy('test-2', {
953
- options: ['--role-arn', roleArn],
954
- });
955
-
956
- // Immediately delete the stack again before we delete the role.
957
- //
958
- // Since roles are sticky, if we delete the role before the stack, subsequent DeleteStack
959
- // operations will fail when CloudFormation tries to assume the role that's already gone.
960
- await fixture.cdkDestroy('test-2');
961
- } finally {
962
- await deleteRole();
963
- }
964
-
965
- async function deleteRole() {
966
- try {
967
- const response = await fixture.aws.iam.send(new ListRolePoliciesCommand({ RoleName: roleName }));
968
-
969
- if (!response.PolicyNames) {
970
- throw new Error('Policy names cannot be undefined for deleteRole() function');
971
- }
972
-
973
- for (const policyName of response.PolicyNames) {
974
- await fixture.aws.iam.send(
975
- new DeleteRolePolicyCommand({
976
- RoleName: roleName,
977
- PolicyName: policyName,
978
- }),
979
- );
980
- }
981
- await fixture.aws.iam.send(new DeleteRoleCommand({ RoleName: roleName }));
982
- } catch (e: any) {
983
- if (e.message.indexOf('cannot be found') > -1) {
984
- return;
985
- }
986
- throw e;
987
- }
988
- }
989
- }),
990
- );
991
-
992
- // TODO add more testing that ensures the symmetry of the generated constructs to the resources.
993
- ['typescript', 'python', 'csharp', 'java'].forEach((language) => {
994
- integTest(
995
- `cdk migrate ${language} deploys successfully`,
996
- withCDKMigrateFixture(language, async (fixture) => {
997
- if (language === 'python') {
998
- await fixture.shell(['pip', 'install', '-r', 'requirements.txt']);
999
- }
1000
-
1001
- const stackArn = await fixture.cdkDeploy(
1002
- fixture.stackNamePrefix,
1003
- { neverRequireApproval: true, verbose: true, captureStderr: false },
1004
- true,
1005
- );
1006
- const response = await fixture.aws.cloudFormation.send(
1007
- new DescribeStacksCommand({
1008
- StackName: stackArn,
1009
- }),
1010
- );
1011
-
1012
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
1013
- await fixture.cdkDestroy(fixture.stackNamePrefix);
1014
- }),
1015
- );
1016
- });
1017
-
1018
- integTest(
1019
- 'cdk migrate generates migrate.json',
1020
- withCDKMigrateFixture('typescript', async (fixture) => {
1021
- const migrateFile = await fs.readFile(path.join(fixture.integTestDir, 'migrate.json'), 'utf8');
1022
- const expectedFile = `{
1023
- \"//\": \"This file is generated by cdk migrate. It will be automatically deleted after the first successful deployment of this app to the environment of the original resources.\",
1024
- \"Source\": \"localfile\"
1025
- }`;
1026
- expect(JSON.parse(migrateFile)).toEqual(JSON.parse(expectedFile));
1027
- await fixture.cdkDestroy(fixture.stackNamePrefix);
1028
- }),
1029
- );
1030
-
1031
- // integTest('cdk migrate --from-scan with AND/OR filters correctly filters resources', withExtendedTimeoutFixture(async (fixture) => {
1032
- // const stackName = `cdk-migrate-integ-${fixture.randomString}`;
1033
-
1034
- // await fixture.cdkDeploy('migrate-stack', {
1035
- // modEnv: { SAMPLE_RESOURCES: '1' },
1036
- // });
1037
- // await fixture.cdk(
1038
- // ['migrate', '--stack-name', stackName, '--from-scan', 'new', '--filter', 'type=AWS::SNS::Topic,tag-key=tag1', 'type=AWS::SQS::Queue,tag-key=tag3'],
1039
- // { modEnv: { MIGRATE_INTEG_TEST: '1' }, neverRequireApproval: true, verbose: true, captureStderr: false },
1040
- // );
1041
-
1042
- // try {
1043
- // const response = await fixture.aws.cloudFormation('describeGeneratedTemplate', {
1044
- // GeneratedTemplateName: stackName,
1045
- // });
1046
- // const resourceNames = [];
1047
- // for (const resource of response.Resources || []) {
1048
- // if (resource.LogicalResourceId) {
1049
- // resourceNames.push(resource.LogicalResourceId);
1050
- // }
1051
- // }
1052
- // fixture.log(`Resources: ${resourceNames}`);
1053
- // expect(resourceNames.some(ele => ele && ele.includes('migratetopic1'))).toBeTruthy();
1054
- // expect(resourceNames.some(ele => ele && ele.includes('migratequeue1'))).toBeTruthy();
1055
- // } finally {
1056
- // await fixture.cdkDestroy('migrate-stack');
1057
- // await fixture.aws.cloudFormation('deleteGeneratedTemplate', {
1058
- // GeneratedTemplateName: stackName,
1059
- // });
1060
- // }
1061
- // }));
1062
-
1063
- // integTest('cdk migrate --from-scan for resources with Write Only Properties generates warnings', withExtendedTimeoutFixture(async (fixture) => {
1064
- // const stackName = `cdk-migrate-integ-${fixture.randomString}`;
1065
-
1066
- // await fixture.cdkDeploy('migrate-stack', {
1067
- // modEnv: {
1068
- // LAMBDA_RESOURCES: '1',
1069
- // },
1070
- // });
1071
- // await fixture.cdk(
1072
- // ['migrate', '--stack-name', stackName, '--from-scan', 'new', '--filter', 'type=AWS::Lambda::Function,tag-key=lambda-tag'],
1073
- // { modEnv: { MIGRATE_INTEG_TEST: '1' }, neverRequireApproval: true, verbose: true, captureStderr: false },
1074
- // );
1075
-
1076
- // try {
1077
-
1078
- // const response = await fixture.aws.cloudFormation('describeGeneratedTemplate', {
1079
- // GeneratedTemplateName: stackName,
1080
- // });
1081
- // const resourceNames = [];
1082
- // for (const resource of response.Resources || []) {
1083
- // if (resource.LogicalResourceId && resource.ResourceType === 'AWS::Lambda::Function') {
1084
- // resourceNames.push(resource.LogicalResourceId);
1085
- // }
1086
- // }
1087
- // fixture.log(`Resources: ${resourceNames}`);
1088
- // const readmePath = path.join(fixture.integTestDir, stackName, 'README.md');
1089
- // const readme = await fs.readFile(readmePath, 'utf8');
1090
- // expect(readme).toContain('## Warnings');
1091
- // for (const resourceName of resourceNames) {
1092
- // expect(readme).toContain(`### ${resourceName}`);
1093
- // }
1094
- // } finally {
1095
- // await fixture.cdkDestroy('migrate-stack');
1096
- // await fixture.aws.cloudFormation('deleteGeneratedTemplate', {
1097
- // GeneratedTemplateName: stackName,
1098
- // });
1099
- // }
1100
- // }));
1101
-
1102
- ['typescript', 'python', 'csharp', 'java'].forEach((language) => {
1103
- integTest(
1104
- `cdk migrate --from-stack creates deployable ${language} app`,
1105
- withExtendedTimeoutFixture(async (fixture) => {
1106
- const migrateStackName = fixture.fullStackName('migrate-stack');
1107
- await fixture.aws.cloudFormation.send(
1108
- new CreateStackCommand({
1109
- StackName: migrateStackName,
1110
- TemplateBody: await fs.readFile(
1111
- path.join(__dirname, '..', '..', 'resources', 'templates', 'sqs-template.json'),
1112
- 'utf8',
1113
- ),
1114
- }),
1115
- );
1116
- try {
1117
- let stackStatus = 'CREATE_IN_PROGRESS';
1118
- while (stackStatus === 'CREATE_IN_PROGRESS') {
1119
- stackStatus = await (
1120
- await fixture.aws.cloudFormation.send(new DescribeStacksCommand({ StackName: migrateStackName }))
1121
- ).Stacks?.[0].StackStatus!;
1122
- await sleep(1000);
1123
- }
1124
- await fixture.cdk(['migrate', '--stack-name', migrateStackName, '--from-stack'], {
1125
- modEnv: { MIGRATE_INTEG_TEST: '1' },
1126
- neverRequireApproval: true,
1127
- verbose: true,
1128
- captureStderr: false,
1129
- });
1130
- await fixture.shell(['cd', path.join(fixture.integTestDir, migrateStackName)]);
1131
- await fixture.cdk(['deploy', migrateStackName], {
1132
- neverRequireApproval: true,
1133
- verbose: true,
1134
- captureStderr: false,
1135
- });
1136
- const response = await fixture.aws.cloudFormation.send(
1137
- new DescribeStacksCommand({
1138
- StackName: migrateStackName,
1139
- }),
1140
- );
1141
-
1142
- expect(response.Stacks?.[0].StackStatus).toEqual('UPDATE_COMPLETE');
1143
- } finally {
1144
- await fixture.cdkDestroy('migrate-stack');
1145
- }
1146
- }),
1147
- );
1148
- });
1149
-
1150
- integTest(
1151
- 'cdk diff',
1152
- withDefaultFixture(async (fixture) => {
1153
- const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]);
1154
- expect(diff1).toContain('AWS::SNS::Topic');
1155
-
1156
- const diff2 = await fixture.cdk(['diff', fixture.fullStackName('test-2')]);
1157
- expect(diff2).toContain('AWS::SNS::Topic');
1158
-
1159
- // We can make it fail by passing --fail
1160
- await expect(fixture.cdk(['diff', '--fail', fixture.fullStackName('test-1')])).rejects.toThrow('exited with error');
1161
- }),
1162
- );
1163
-
1164
- integTest(
1165
- 'enableDiffNoFail',
1166
- withDefaultFixture(async (fixture) => {
1167
- await diffShouldSucceedWith({ fail: false, enableDiffNoFail: false });
1168
- await diffShouldSucceedWith({ fail: false, enableDiffNoFail: true });
1169
- await diffShouldFailWith({ fail: true, enableDiffNoFail: false });
1170
- await diffShouldFailWith({ fail: true, enableDiffNoFail: true });
1171
- await diffShouldFailWith({ fail: undefined, enableDiffNoFail: false });
1172
- await diffShouldSucceedWith({ fail: undefined, enableDiffNoFail: true });
1173
-
1174
- async function diffShouldSucceedWith(props: DiffParameters) {
1175
- await expect(diff(props)).resolves.not.toThrow();
1176
- }
1177
-
1178
- async function diffShouldFailWith(props: DiffParameters) {
1179
- await expect(diff(props)).rejects.toThrow('exited with error');
1180
- }
1181
-
1182
- async function diff(props: DiffParameters): Promise<string> {
1183
- await updateContext(props.enableDiffNoFail);
1184
- const flag = props.fail != null ? (props.fail ? '--fail' : '--no-fail') : '';
1185
-
1186
- return fixture.cdk(['diff', flag, fixture.fullStackName('test-1')]);
1187
- }
1188
-
1189
- async function updateContext(enableDiffNoFail: boolean) {
1190
- const cdkJson = JSON.parse(await fs.readFile(path.join(fixture.integTestDir, 'cdk.json'), 'utf8'));
1191
- cdkJson.context = {
1192
- ...cdkJson.context,
1193
- 'aws-cdk:enableDiffNoFail': enableDiffNoFail,
1194
- };
1195
- await fs.writeFile(path.join(fixture.integTestDir, 'cdk.json'), JSON.stringify(cdkJson));
1196
- }
1197
-
1198
- type DiffParameters = { fail?: boolean; enableDiffNoFail: boolean };
1199
- }),
1200
- );
1201
-
1202
- integTest(
1203
- 'cdk diff --fail on multiple stacks exits with error if any of the stacks contains a diff',
1204
- withDefaultFixture(async (fixture) => {
1205
- // GIVEN
1206
- const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]);
1207
- expect(diff1).toContain('AWS::SNS::Topic');
1208
-
1209
- await fixture.cdkDeploy('test-2');
1210
- const diff2 = await fixture.cdk(['diff', fixture.fullStackName('test-2')]);
1211
- expect(diff2).toContain('There were no differences');
1212
-
1213
- // WHEN / THEN
1214
- await expect(
1215
- fixture.cdk(['diff', '--fail', fixture.fullStackName('test-1'), fixture.fullStackName('test-2')]),
1216
- ).rejects.toThrow('exited with error');
1217
- }),
1218
- );
1219
-
1220
- integTest(
1221
- 'cdk diff --fail with multiple stack exits with if any of the stacks contains a diff',
1222
- withDefaultFixture(async (fixture) => {
1223
- // GIVEN
1224
- await fixture.cdkDeploy('test-1');
1225
- const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]);
1226
- expect(diff1).toContain('There were no differences');
1227
-
1228
- const diff2 = await fixture.cdk(['diff', fixture.fullStackName('test-2')]);
1229
- expect(diff2).toContain('AWS::SNS::Topic');
1230
-
1231
- // WHEN / THEN
1232
- await expect(
1233
- fixture.cdk(['diff', '--fail', fixture.fullStackName('test-1'), fixture.fullStackName('test-2')]),
1234
- ).rejects.toThrow('exited with error');
1235
- }),
1236
- );
1237
-
1238
- integTest(
1239
- 'cdk diff with large changeset does not fail',
1240
- withDefaultFixture(async (fixture) => {
1241
- // GIVEN - small initial stack with only one IAM role
1242
- await fixture.cdkDeploy('iam-roles', {
1243
- modEnv: {
1244
- NUMBER_OF_ROLES: '1',
1245
- },
1246
- });
1247
-
1248
- // WHEN - adding an additional role with a ton of metadata to create a large diff
1249
- const diff = await fixture.cdk(['diff', fixture.fullStackName('iam-roles')], {
1250
- verbose: true,
1251
- modEnv: {
1252
- NUMBER_OF_ROLES: '2',
1253
- },
1254
- });
1255
-
1256
- // Assert that the CLI assumes the file publishing role:
1257
- expect(diff).toMatch(/Assuming role .*file-publishing-role/);
1258
- expect(diff).toContain('success: Published');
1259
- }),
1260
- );
1261
-
1262
- integTest(
1263
- 'cdk diff doesnt show resource metadata changes',
1264
- withDefaultFixture(async (fixture) => {
1265
- // GIVEN - small initial stack with default resource metadata
1266
- await fixture.cdkDeploy('metadata');
1267
-
1268
- // WHEN - changing resource metadata value
1269
- const diff = await fixture.cdk(['diff', fixture.fullStackName('metadata')], {
1270
- verbose: true,
1271
- modEnv: {
1272
- INTEG_METADATA_VALUE: 'custom',
1273
- },
1274
- });
1275
-
1276
- // Assert there are no changes
1277
- expect(diff).toContain('There were no differences');
1278
- }),
1279
- );
1280
-
1281
- integTest(
1282
- 'cdk diff shows resource metadata changes with --no-change-set',
1283
- withDefaultFixture(async (fixture) => {
1284
- // GIVEN - small initial stack with default resource metadata
1285
- await fixture.cdkDeploy('metadata');
1286
-
1287
- // WHEN - changing resource metadata value
1288
- const diff = await fixture.cdk(['diff --no-change-set', fixture.fullStackName('metadata')], {
1289
- verbose: true,
1290
- modEnv: {
1291
- INTEG_METADATA_VALUE: 'custom',
1292
- },
1293
- });
1294
-
1295
- // Assert there are changes
1296
- expect(diff).not.toContain('There were no differences');
1297
- }),
1298
- );
1299
-
1300
- integTest('cdk diff with large changeset and custom toolkit stack name and qualifier does not fail', withoutBootstrap(async (fixture) => {
1301
- // Bootstrapping with custom toolkit stack name and qualifier
1302
- const qualifier = 'abc1111';
1303
- const toolkitStackName = 'custom-stack2';
1304
- await fixture.cdkBootstrapModern({
1305
- verbose: true,
1306
- toolkitStackName: toolkitStackName,
1307
- qualifier: qualifier,
1308
- });
1309
-
1310
- // Deploying small initial stack with only one IAM role
1311
- await fixture.cdkDeploy('iam-roles', {
1312
- modEnv: {
1313
- NUMBER_OF_ROLES: '1',
1314
- },
1315
- options: [
1316
- '--toolkit-stack-name', toolkitStackName,
1317
- '--context', `@aws-cdk/core:bootstrapQualifier=${qualifier}`,
1318
- ],
1319
- });
1320
-
1321
- // WHEN - adding a role with a ton of metadata to create a large diff
1322
- const diff = await fixture.cdk(['diff', '--toolkit-stack-name', toolkitStackName, '--context', `@aws-cdk/core:bootstrapQualifier=${qualifier}`, fixture.fullStackName('iam-roles')], {
1323
- verbose: true,
1324
- modEnv: {
1325
- NUMBER_OF_ROLES: '2',
1326
- },
1327
- });
1328
-
1329
- // Assert that the CLI assumes the file publishing role:
1330
- expect(diff).toMatch(/Assuming role .*file-publishing-role/);
1331
- expect(diff).toContain('success: Published');
1332
- }));
1333
-
1334
- integTest(
1335
- 'cdk diff --security-only successfully outputs sso-permission-set-without-managed-policy information',
1336
- withDefaultFixture(async (fixture) => {
1337
- const diff = await fixture.cdk([
1338
- 'diff',
1339
- '--security-only',
1340
- fixture.fullStackName('sso-perm-set-without-managed-policy'),
1341
- ]);
1342
- `┌───┬──────────────────────────────────────────┬──────────────────────────────────┬────────────────────┬───────────────────────────────────┬─────────────────────────────────┐
1343
- │ │ Resource │ InstanceArn │ PermissionSet name │ PermissionsBoundary │ CustomerManagedPolicyReferences │
1344
- ├───┼──────────────────────────────────────────┼──────────────────────────────────┼────────────────────┼───────────────────────────────────┼─────────────────────────────────┤
1345
- │ + │\${permission-set-without-managed-policy} │ arn:aws:sso:::instance/testvalue │ testName │ CustomerManagedPolicyReference: { │ │
1346
- │ │ │ │ │ Name: why, Path: /how/ │ │
1347
- │ │ │ │ │ } │ │
1348
- `;
1349
- expect(diff).toContain('Resource');
1350
- expect(diff).toContain('permission-set-without-managed-policy');
1351
-
1352
- expect(diff).toContain('InstanceArn');
1353
- expect(diff).toContain('arn:aws:sso:::instance/testvalue');
1354
-
1355
- expect(diff).toContain('PermissionSet name');
1356
- expect(diff).toContain('testName');
1357
-
1358
- expect(diff).toContain('PermissionsBoundary');
1359
- expect(diff).toContain('CustomerManagedPolicyReference: {');
1360
- expect(diff).toContain('Name: why, Path: /how/');
1361
- expect(diff).toContain('}');
1362
-
1363
- expect(diff).toContain('CustomerManagedPolicyReferences');
1364
- }),
1365
- );
1366
-
1367
- integTest(
1368
- 'cdk diff --security-only successfully outputs sso-permission-set-with-managed-policy information',
1369
- withDefaultFixture(async (fixture) => {
1370
- const diff = await fixture.cdk([
1371
- 'diff',
1372
- '--security-only',
1373
- fixture.fullStackName('sso-perm-set-with-managed-policy'),
1374
- ]);
1375
- `┌───┬──────────────────────────────────────────┬──────────────────────────────────┬────────────────────┬───────────────────────────────────────────────────────────────┬─────────────────────────────────┐
1376
- │ │ Resource │ InstanceArn │ PermissionSet name │ PermissionsBoundary │ CustomerManagedPolicyReferences │
1377
- ├───┼──────────────────────────────────────────┼──────────────────────────────────┼────────────────────┼───────────────────────────────────────────────────────────────┼─────────────────────────────────┤
1378
- │ + │\${permission-set-with-managed-policy} │ arn:aws:sso:::instance/testvalue │ niceWork │ ManagedPolicyArn: arn:aws:iam::aws:policy/AdministratorAccess │ Name: forSSO, Path: │
1379
- `;
1380
-
1381
- expect(diff).toContain('Resource');
1382
- expect(diff).toContain('permission-set-with-managed-policy');
1383
-
1384
- expect(diff).toContain('InstanceArn');
1385
- expect(diff).toContain('arn:aws:sso:::instance/testvalue');
1386
-
1387
- expect(diff).toContain('PermissionSet name');
1388
- expect(diff).toContain('niceWork');
1389
-
1390
- expect(diff).toContain('PermissionsBoundary');
1391
- expect(diff).toContain('ManagedPolicyArn: arn:aws:iam::aws:policy/AdministratorAccess');
1392
-
1393
- expect(diff).toContain('CustomerManagedPolicyReferences');
1394
- expect(diff).toContain('Name: forSSO, Path:');
1395
- }),
1396
- );
1397
-
1398
- integTest(
1399
- 'cdk diff --security-only successfully outputs sso-assignment information',
1400
- withDefaultFixture(async (fixture) => {
1401
- const diff = await fixture.cdk(['diff', '--security-only', fixture.fullStackName('sso-assignment')]);
1402
- `┌───┬───────────────┬──────────────────────────────────┬─────────────────────────┬──────────────────────────────┬───────────────┬──────────────┬─────────────┐
1403
- │ │ Resource │ InstanceArn │ PermissionSetArn │ PrincipalId │ PrincipalType │ TargetId │ TargetType │
1404
- ├───┼───────────────┼──────────────────────────────────┼─────────────────────────┼──────────────────────────────┼───────────────┼──────────────┼─────────────┤
1405
- │ + │\${assignment} │ arn:aws:sso:::instance/testvalue │ arn:aws:sso:::testvalue │ 11111111-2222-3333-4444-test │ USER │ 111111111111 │ AWS_ACCOUNT │
1406
- └───┴───────────────┴──────────────────────────────────┴─────────────────────────┴──────────────────────────────┴───────────────┴──────────────┴─────────────┘
1407
- `;
1408
- expect(diff).toContain('Resource');
1409
- expect(diff).toContain('assignment');
1410
-
1411
- expect(diff).toContain('InstanceArn');
1412
- expect(diff).toContain('arn:aws:sso:::instance/testvalue');
1413
-
1414
- expect(diff).toContain('PermissionSetArn');
1415
- expect(diff).toContain('arn:aws:sso:::testvalue');
1416
-
1417
- expect(diff).toContain('PrincipalId');
1418
- expect(diff).toContain('11111111-2222-3333-4444-test');
1419
-
1420
- expect(diff).toContain('PrincipalType');
1421
- expect(diff).toContain('USER');
1422
-
1423
- expect(diff).toContain('TargetId');
1424
- expect(diff).toContain('111111111111');
1425
-
1426
- expect(diff).toContain('TargetType');
1427
- expect(diff).toContain('AWS_ACCOUNT');
1428
- }),
1429
- );
1430
-
1431
- integTest(
1432
- 'cdk diff --security-only successfully outputs sso-access-control information',
1433
- withDefaultFixture(async (fixture) => {
1434
- const diff = await fixture.cdk(['diff', '--security-only', fixture.fullStackName('sso-access-control')]);
1435
- `┌───┬────────────────────────────────┬────────────────────────┬─────────────────────────────────┐
1436
- │ │ Resource │ InstanceArn │ AccessControlAttributes │
1437
- ├───┼────────────────────────────────┼────────────────────────┼─────────────────────────────────┤
1438
- │ + │\${instanceAccessControlConfig} │ arn:aws:test:testvalue │ Key: first, Values: [a] │
1439
- │ │ │ │ Key: second, Values: [b] │
1440
- │ │ │ │ Key: third, Values: [c] │
1441
- │ │ │ │ Key: fourth, Values: [d] │
1442
- │ │ │ │ Key: fifth, Values: [e] │
1443
- │ │ │ │ Key: sixth, Values: [f] │
1444
- └───┴────────────────────────────────┴────────────────────────┴─────────────────────────────────┘
1445
- `;
1446
- expect(diff).toContain('Resource');
1447
- expect(diff).toContain('instanceAccessControlConfig');
1448
-
1449
- expect(diff).toContain('InstanceArn');
1450
- expect(diff).toContain('arn:aws:sso:::instance/testvalue');
1451
-
1452
- expect(diff).toContain('AccessControlAttributes');
1453
- expect(diff).toContain('Key: first, Values: [a]');
1454
- expect(diff).toContain('Key: second, Values: [b]');
1455
- expect(diff).toContain('Key: third, Values: [c]');
1456
- expect(diff).toContain('Key: fourth, Values: [d]');
1457
- expect(diff).toContain('Key: fifth, Values: [e]');
1458
- expect(diff).toContain('Key: sixth, Values: [f]');
1459
- }),
1460
- );
1461
-
1462
- integTest(
1463
- 'cdk diff --security-only --fail exits when security diff for sso access control config',
1464
- withDefaultFixture(async (fixture) => {
1465
- await expect(
1466
- fixture.cdk(['diff', '--security-only', '--fail', fixture.fullStackName('sso-access-control')]),
1467
- ).rejects.toThrow('exited with error');
1468
- }),
1469
- );
1470
-
1471
- integTest(
1472
- 'cdk diff --security-only --fail exits when security diff for sso-perm-set-without-managed-policy',
1473
- withDefaultFixture(async (fixture) => {
1474
- await expect(
1475
- fixture.cdk(['diff', '--security-only', '--fail', fixture.fullStackName('sso-perm-set-without-managed-policy')]),
1476
- ).rejects.toThrow('exited with error');
1477
- }),
1478
- );
1479
-
1480
- integTest(
1481
- 'cdk diff --security-only --fail exits when security diff for sso-perm-set-with-managed-policy',
1482
- withDefaultFixture(async (fixture) => {
1483
- await expect(
1484
- fixture.cdk(['diff', '--security-only', '--fail', fixture.fullStackName('sso-perm-set-with-managed-policy')]),
1485
- ).rejects.toThrow('exited with error');
1486
- }),
1487
- );
1488
-
1489
- integTest(
1490
- 'cdk diff --security-only --fail exits when security diff for sso-assignment',
1491
- withDefaultFixture(async (fixture) => {
1492
- await expect(
1493
- fixture.cdk(['diff', '--security-only', '--fail', fixture.fullStackName('sso-assignment')]),
1494
- ).rejects.toThrow('exited with error');
1495
- }),
1496
- );
1497
-
1498
- integTest(
1499
- 'cdk diff --security-only --fail exits when security changes are present',
1500
- withDefaultFixture(async (fixture) => {
1501
- const stackName = 'iam-test';
1502
- await expect(fixture.cdk(['diff', '--security-only', '--fail', fixture.fullStackName(stackName)])).rejects.toThrow(
1503
- 'exited with error',
1504
- );
1505
- }),
1506
- );
1507
-
1508
- integTest(
1509
- "cdk diff --quiet does not print 'There were no differences' message for stacks which have no differences",
1510
- withDefaultFixture(async (fixture) => {
1511
- // GIVEN
1512
- await fixture.cdkDeploy('test-1');
1513
-
1514
- // WHEN
1515
- const diff = await fixture.cdk(['diff', '--quiet', fixture.fullStackName('test-1')]);
1516
-
1517
- // THEN
1518
- expect(diff).not.toContain('Stack test-1');
1519
- expect(diff).not.toContain('There were no differences');
1520
- }),
1521
- );
1522
-
1523
- integTest(
1524
- 'deploy stack with docker asset',
1525
- withDefaultFixture(async (fixture) => {
1526
- await fixture.cdkDeploy('docker');
1527
- }),
1528
- );
1529
-
1530
- integTest(
1531
- 'deploy and test stack with lambda asset',
1532
- withDefaultFixture(async (fixture) => {
1533
- const stackArn = await fixture.cdkDeploy('lambda', { captureStderr: false });
1534
-
1535
- const response = await fixture.aws.cloudFormation.send(
1536
- new DescribeStacksCommand({
1537
- StackName: stackArn,
1538
- }),
1539
- );
1540
- const lambdaArn = response.Stacks?.[0].Outputs?.[0].OutputValue;
1541
- if (lambdaArn === undefined) {
1542
- throw new Error('Stack did not have expected Lambda ARN output');
1543
- }
1544
-
1545
- const output = await fixture.aws.lambda.send(
1546
- new InvokeCommand({
1547
- FunctionName: lambdaArn,
1548
- }),
1549
- );
1550
-
1551
- expect(JSON.stringify(output.Payload?.transformToString())).toContain('dear asset');
1552
- }),
1553
- );
1554
-
1555
- integTest('deploy stack with Lambda Asset to Object Lock-enabled asset bucket', withoutBootstrap(async (fixture) => {
1556
- // Bootstrapping with custom toolkit stack name and qualifier
1557
- const qualifier = fixture.qualifier;
1558
- const toolkitStackName = fixture.bootstrapStackName;
1559
- await fixture.cdkBootstrapModern({
1560
- verbose: true,
1561
- toolkitStackName: toolkitStackName,
1562
- qualifier: qualifier,
1563
- });
1564
-
1565
- const bucketName = `cdk-${qualifier}-assets-${await fixture.aws.account()}-${fixture.aws.region}`;
1566
- await fixture.aws.s3.send(new PutObjectLockConfigurationCommand({
1567
- Bucket: bucketName,
1568
- ObjectLockConfiguration: {
1569
- ObjectLockEnabled: 'Enabled',
1570
- Rule: {
1571
- DefaultRetention: {
1572
- Days: 1,
1573
- Mode: 'GOVERNANCE',
1574
- },
1575
- },
1576
- },
1577
- }));
1578
-
1579
- // Deploy a stack that definitely contains a file asset
1580
- await fixture.cdkDeploy('lambda', {
1581
- options: [
1582
- '--toolkit-stack-name', toolkitStackName,
1583
- '--context', `@aws-cdk/core:bootstrapQualifier=${qualifier}`,
1584
- ],
1585
- });
1586
-
1587
- // THEN - should not fail. Now clean the bucket with governance bypass: a regular delete
1588
- // operation will fail.
1589
- await fixture.aws.emptyBucket(bucketName, { bypassGovernance: true });
1590
- }));
1591
-
1592
- integTest(
1593
- 'cdk ls',
1594
- withDefaultFixture(async (fixture) => {
1595
- const listing = await fixture.cdk(['ls'], { captureStderr: false });
1596
-
1597
- const expectedStacks = [
1598
- 'conditional-resource',
1599
- 'docker',
1600
- 'docker-with-custom-file',
1601
- 'failed',
1602
- 'iam-test',
1603
- 'lambda',
1604
- 'missing-ssm-parameter',
1605
- 'order-providing',
1606
- 'outputs-test-1',
1607
- 'outputs-test-2',
1608
- 'param-test-1',
1609
- 'param-test-2',
1610
- 'param-test-3',
1611
- 'termination-protection',
1612
- 'test-1',
1613
- 'test-2',
1614
- 'with-nested-stack',
1615
- 'with-nested-stack-using-parameters',
1616
- 'order-consuming',
1617
- ];
1618
-
1619
- for (const stack of expectedStacks) {
1620
- expect(listing).toContain(fixture.fullStackName(stack));
1621
- }
1622
- }),
1623
- );
1624
-
1625
- /**
1626
- * Type to store stack dependencies recursively
1627
- */
1628
- type DependencyDetails = {
1629
- id: string;
1630
- dependencies: DependencyDetails[];
1631
- };
1632
-
1633
- type StackDetails = {
1634
- id: string;
1635
- dependencies: DependencyDetails[];
1636
- };
1637
-
1638
- integTest(
1639
- 'cdk ls --show-dependencies --json',
1640
- withDefaultFixture(async (fixture) => {
1641
- const listing = await fixture.cdk(['ls --show-dependencies --json'], { captureStderr: false });
1642
-
1643
- const expectedStacks = [
1644
- {
1645
- id: 'test-1',
1646
- dependencies: [],
1647
- },
1648
- {
1649
- id: 'order-providing',
1650
- dependencies: [],
1651
- },
1652
- {
1653
- id: 'order-consuming',
1654
- dependencies: [
1655
- {
1656
- id: 'order-providing',
1657
- dependencies: [],
1658
- },
1659
- ],
1660
- },
1661
- {
1662
- id: 'with-nested-stack',
1663
- dependencies: [],
1664
- },
1665
- {
1666
- id: 'list-stacks',
1667
- dependencies: [
1668
- {
1669
- id: 'list-stacks/DependentStack',
1670
- dependencies: [
1671
- {
1672
- id: 'list-stacks/DependentStack/InnerDependentStack',
1673
- dependencies: [],
1674
- },
1675
- ],
1676
- },
1677
- ],
1678
- },
1679
- {
1680
- id: 'list-multiple-dependent-stacks',
1681
- dependencies: [
1682
- {
1683
- id: 'list-multiple-dependent-stacks/DependentStack1',
1684
- dependencies: [],
1685
- },
1686
- {
1687
- id: 'list-multiple-dependent-stacks/DependentStack2',
1688
- dependencies: [],
1689
- },
1690
- ],
1691
- },
1692
- ];
1693
-
1694
- function validateStackDependencies(stack: StackDetails) {
1695
- expect(listing).toContain(stack.id);
1696
-
1697
- function validateDependencies(dependencies: DependencyDetails[]) {
1698
- for (const dependency of dependencies) {
1699
- expect(listing).toContain(dependency.id);
1700
- if (dependency.dependencies.length > 0) {
1701
- validateDependencies(dependency.dependencies);
1702
- }
1703
- }
1704
- }
1705
-
1706
- if (stack.dependencies.length > 0) {
1707
- validateDependencies(stack.dependencies);
1708
- }
1709
- }
1710
-
1711
- for (const stack of expectedStacks) {
1712
- validateStackDependencies(stack);
1713
- }
1714
- }),
1715
- );
1716
-
1717
- integTest(
1718
- 'cdk ls --show-dependencies --json --long',
1719
- withDefaultFixture(async (fixture) => {
1720
- const listing = await fixture.cdk(['ls --show-dependencies --json --long'], { captureStderr: false });
1721
-
1722
- const expectedStacks = [
1723
- {
1724
- id: 'order-providing',
1725
- name: 'order-providing',
1726
- enviroment: {
1727
- account: 'unknown-account',
1728
- region: 'unknown-region',
1729
- name: 'aws://unknown-account/unknown-region',
1730
- },
1731
- dependencies: [],
1732
- },
1733
- {
1734
- id: 'order-consuming',
1735
- name: 'order-consuming',
1736
- enviroment: {
1737
- account: 'unknown-account',
1738
- region: 'unknown-region',
1739
- name: 'aws://unknown-account/unknown-region',
1740
- },
1741
- dependencies: [
1742
- {
1743
- id: 'order-providing',
1744
- dependencies: [],
1745
- },
1746
- ],
1747
- },
1748
- ];
1749
-
1750
- for (const stack of expectedStacks) {
1751
- expect(listing).toContain(fixture.fullStackName(stack.id));
1752
- expect(listing).toContain(fixture.fullStackName(stack.name));
1753
- expect(listing).toContain(stack.enviroment.account);
1754
- expect(listing).toContain(stack.enviroment.name);
1755
- expect(listing).toContain(stack.enviroment.region);
1756
- for (const dependency of stack.dependencies) {
1757
- expect(listing).toContain(fixture.fullStackName(dependency.id));
1758
- }
1759
- }
1760
- }),
1761
- );
1762
-
1763
- integTest(
1764
- 'synthing a stage with errors leads to failure',
1765
- withDefaultFixture(async (fixture) => {
1766
- const output = await fixture.cdk(['synth'], {
1767
- allowErrExit: true,
1768
- modEnv: {
1769
- INTEG_STACK_SET: 'stage-with-errors',
1770
- },
1771
- });
1772
-
1773
- expect(output).toContain('This is an error');
1774
- }),
1775
- );
1776
-
1777
- integTest(
1778
- 'synthing a stage with errors can be suppressed',
1779
- withDefaultFixture(async (fixture) => {
1780
- await fixture.cdk(['synth', '--no-validation'], {
1781
- modEnv: {
1782
- INTEG_STACK_SET: 'stage-with-errors',
1783
- },
1784
- });
1785
- }),
1786
- );
1787
-
1788
- integTest(
1789
- 'synth --quiet can be specified in cdk.json',
1790
- withDefaultFixture(async (fixture) => {
1791
- let cdkJson = JSON.parse(await fs.readFile(path.join(fixture.integTestDir, 'cdk.json'), 'utf8'));
1792
- cdkJson = {
1793
- ...cdkJson,
1794
- quiet: true,
1795
- };
1796
- await fs.writeFile(path.join(fixture.integTestDir, 'cdk.json'), JSON.stringify(cdkJson));
1797
- const synthOutput = await fixture.cdk(['synth', fixture.fullStackName('test-2')]);
1798
- expect(synthOutput).not.toContain('topic152D84A37');
1799
- }),
1800
- );
1801
-
1802
- integTest(
1803
- 'deploy stack without resource',
1804
- withDefaultFixture(async (fixture) => {
1805
- // Deploy the stack without resources
1806
- await fixture.cdkDeploy('conditional-resource', { modEnv: { NO_RESOURCE: 'TRUE' } });
1807
-
1808
- // This should have succeeded but not deployed the stack.
1809
- await expect(
1810
- fixture.aws.cloudFormation.send(
1811
- new DescribeStacksCommand({ StackName: fixture.fullStackName('conditional-resource') }),
1812
- ),
1813
- ).rejects.toThrow('conditional-resource does not exist');
1814
-
1815
- // Deploy the stack with resources
1816
- await fixture.cdkDeploy('conditional-resource');
1817
-
1818
- // Then again WITHOUT resources (this should destroy the stack)
1819
- await fixture.cdkDeploy('conditional-resource', { modEnv: { NO_RESOURCE: 'TRUE' } });
1820
-
1821
- await expect(
1822
- fixture.aws.cloudFormation.send(
1823
- new DescribeStacksCommand({ StackName: fixture.fullStackName('conditional-resource') }),
1824
- ),
1825
- ).rejects.toThrow('conditional-resource does not exist');
1826
- }),
1827
- );
1828
-
1829
- integTest(
1830
- 'deploy no stacks with --ignore-no-stacks',
1831
- withDefaultFixture(async (fixture) => {
1832
- // empty array for stack names
1833
- await fixture.cdkDeploy([], {
1834
- options: ['--ignore-no-stacks'],
1835
- modEnv: {
1836
- INTEG_STACK_SET: 'stage-with-no-stacks',
1837
- },
1838
- });
1839
- }),
1840
- );
1841
-
1842
- integTest(
1843
- 'deploy no stacks error',
1844
- withDefaultFixture(async (fixture) => {
1845
- // empty array for stack names
1846
- await expect(
1847
- fixture.cdkDeploy([], {
1848
- modEnv: {
1849
- INTEG_STACK_SET: 'stage-with-no-stacks',
1850
- },
1851
- }),
1852
- ).rejects.toThrow('exited with error');
1853
- }),
1854
- );
1855
-
1856
- integTest(
1857
- 'IAM diff',
1858
- withDefaultFixture(async (fixture) => {
1859
- const output = await fixture.cdk(['diff', fixture.fullStackName('iam-test')]);
1860
-
1861
- // Roughly check for a table like this:
1862
- //
1863
- // ┌───┬─────────────────┬────────┬────────────────┬────────────────────────────-──┬───────────┐
1864
- // │ │ Resource │ Effect │ Action │ Principal │ Condition │
1865
- // ├───┼─────────────────┼────────┼────────────────┼───────────────────────────────┼───────────┤
1866
- // │ + │ ${SomeRole.Arn} │ Allow │ sts:AssumeRole │ Service:ec2.amazonaws.com │ │
1867
- // └───┴─────────────────┴────────┴────────────────┴───────────────────────────────┴───────────┘
1868
-
1869
- expect(output).toContain('${SomeRole.Arn}');
1870
- expect(output).toContain('sts:AssumeRole');
1871
- expect(output).toContain('ec2.amazonaws.com');
1872
- }),
1873
- );
1874
-
1875
- integTest(
1876
- 'fast deploy',
1877
- withDefaultFixture(async (fixture) => {
1878
- // we are using a stack with a nested stack because CFN will always attempt to
1879
- // update a nested stack, which will allow us to verify that updates are actually
1880
- // skipped unless --force is specified.
1881
- const stackArn = await fixture.cdkDeploy('with-nested-stack', { captureStderr: false });
1882
- const changeSet1 = await getLatestChangeSet();
1883
-
1884
- // Deploy the same stack again, there should be no new change set created
1885
- await fixture.cdkDeploy('with-nested-stack');
1886
- const changeSet2 = await getLatestChangeSet();
1887
- expect(changeSet2.ChangeSetId).toEqual(changeSet1.ChangeSetId);
1888
-
1889
- // Deploy the stack again with --force, now we should create a changeset
1890
- await fixture.cdkDeploy('with-nested-stack', { options: ['--force'] });
1891
- const changeSet3 = await getLatestChangeSet();
1892
- expect(changeSet3.ChangeSetId).not.toEqual(changeSet2.ChangeSetId);
1893
-
1894
- // Deploy the stack again with tags, expected to create a new changeset
1895
- // even though the resources didn't change.
1896
- await fixture.cdkDeploy('with-nested-stack', { options: ['--tags', 'key=value'] });
1897
- const changeSet4 = await getLatestChangeSet();
1898
- expect(changeSet4.ChangeSetId).not.toEqual(changeSet3.ChangeSetId);
1899
-
1900
- async function getLatestChangeSet() {
1901
- const response = await fixture.aws.cloudFormation.send(new DescribeStacksCommand({ StackName: stackArn }));
1902
- if (!response.Stacks?.[0]) {
1903
- throw new Error('Did not get a ChangeSet at all');
1904
- }
1905
- fixture.log(`Found Change Set ${response.Stacks?.[0].ChangeSetId}`);
1906
- return response.Stacks?.[0];
1907
- }
1908
- }),
1909
- );
1910
-
1911
- integTest(
1912
- 'failed deploy does not hang',
1913
- withDefaultFixture(async (fixture) => {
1914
- // this will hang if we introduce https://github.com/aws/aws-cdk/issues/6403 again.
1915
- await expect(fixture.cdkDeploy('failed')).rejects.toThrow('exited with error');
1916
- }),
1917
- );
1918
-
1919
- integTest(
1920
- 'can still load old assemblies',
1921
- withDefaultFixture(async (fixture) => {
1922
- const cxAsmDir = path.join(os.tmpdir(), 'cdk-integ-cx');
1923
-
1924
- const testAssembliesDirectory = path.join(RESOURCES_DIR, 'cloud-assemblies');
1925
- for (const asmdir of await listChildDirs(testAssembliesDirectory)) {
1926
- fixture.log(`ASSEMBLY ${asmdir}`);
1927
- await cloneDirectory(asmdir, cxAsmDir);
1928
-
1929
- // Some files in the asm directory that have a .js extension are
1930
- // actually treated as templates. Evaluate them using NodeJS.
1931
- const templates = await listChildren(cxAsmDir, (fullPath) => Promise.resolve(fullPath.endsWith('.js')));
1932
- for (const template of templates) {
1933
- const targetName = template.replace(/.js$/, '');
1934
- await shell([process.execPath, template, '>', targetName], {
1935
- cwd: cxAsmDir,
1936
- outputs: [fixture.output],
1937
- modEnv: {
1938
- TEST_ACCOUNT: await fixture.aws.account(),
1939
- TEST_REGION: fixture.aws.region,
1940
- },
1941
- });
1942
- }
1943
-
1944
- // Use this directory as a Cloud Assembly
1945
- const output = await fixture.cdk(['--app', cxAsmDir, '-v', 'synth']);
1946
-
1947
- // Assert that there was no providerError in CDK's stderr
1948
- // Because we rely on the app/framework to actually error in case the
1949
- // provider fails, we inspect the logs here.
1950
- expect(output).not.toContain('$providerError');
1951
- }
1952
- }),
1953
- );
1954
-
1955
- integTest(
1956
- 'generating and loading assembly',
1957
- withDefaultFixture(async (fixture) => {
1958
- const asmOutputDir = `${fixture.integTestDir}-cdk-integ-asm`;
1959
- await fixture.shell(['rm', '-rf', asmOutputDir]);
1960
-
1961
- // Synthesize a Cloud Assembly tothe default directory (cdk.out) and a specific directory.
1962
- await fixture.cdk(['synth']);
1963
- await fixture.cdk(['synth', '--output', asmOutputDir]);
1964
-
1965
- // cdk.out in the current directory and the indicated --output should be the same
1966
- await fixture.shell(['diff', 'cdk.out', asmOutputDir]);
1967
-
1968
- // Check that we can 'ls' the synthesized asm.
1969
- // Change to some random directory to make sure we're not accidentally loading cdk.json
1970
- const list = await fixture.cdk(['--app', asmOutputDir, 'ls'], { cwd: os.tmpdir() });
1971
- // Same stacks we know are in the app
1972
- expect(list).toContain(`${fixture.stackNamePrefix}-lambda`);
1973
- expect(list).toContain(`${fixture.stackNamePrefix}-test-1`);
1974
- expect(list).toContain(`${fixture.stackNamePrefix}-test-2`);
1975
-
1976
- // Check that we can use '.' and just synth ,the generated asm
1977
- const stackTemplate = await fixture.cdk(['--app', '.', 'synth', fixture.fullStackName('test-2')], {
1978
- cwd: asmOutputDir,
1979
- });
1980
- expect(stackTemplate).toContain('topic152D84A37');
1981
-
1982
- // Deploy a Lambda from the copied asm
1983
- await fixture.cdkDeploy('lambda', { options: ['-a', '.'], cwd: asmOutputDir });
1984
-
1985
- // Remove (rename) the original custom docker file that was used during synth.
1986
- // this verifies that the assemly has a copy of it and that the manifest uses
1987
- // relative paths to reference to it.
1988
- const customDockerFile = path.join(fixture.integTestDir, 'docker', 'Dockerfile.Custom');
1989
- await fs.rename(customDockerFile, `${customDockerFile}~`);
1990
- try {
1991
- // deploy a docker image with custom file without synth (uses assets)
1992
- await fixture.cdkDeploy('docker-with-custom-file', { options: ['-a', '.'], cwd: asmOutputDir });
1993
- } finally {
1994
- // Rename back to restore fixture to original state
1995
- await fs.rename(`${customDockerFile}~`, customDockerFile);
1996
- }
1997
- }),
1998
- );
1999
-
2000
- integTest(
2001
- 'templates on disk contain metadata resource, also in nested assemblies',
2002
- withDefaultFixture(async (fixture) => {
2003
- // Synth first, and switch on version reporting because cdk.json is disabling it
2004
- await fixture.cdk(['synth', '--version-reporting=true']);
2005
-
2006
- // Load template from disk from root assembly
2007
- const templateContents = await fixture.shell(['cat', 'cdk.out/*-lambda.template.json']);
2008
-
2009
- expect(JSON.parse(templateContents).Resources.CDKMetadata).toBeTruthy();
2010
-
2011
- // Load template from nested assembly
2012
- const nestedTemplateContents = await fixture.shell([
2013
- 'cat',
2014
- 'cdk.out/assembly-*-stage/*StackInStage*.template.json',
2015
- ]);
2016
-
2017
- expect(JSON.parse(nestedTemplateContents).Resources.CDKMetadata).toBeTruthy();
2018
- }),
2019
- );
2020
-
2021
- integTest(
2022
- 'CDK synth add the metadata properties expected by sam',
2023
- withSamIntegrationFixture(async (fixture) => {
2024
- // Synth first
2025
- await fixture.cdkSynth();
2026
-
2027
- const template = fixture.template('TestStack');
2028
-
2029
- const expectedResources = [
2030
- {
2031
- // Python Layer Version
2032
- id: 'PythonLayerVersion39495CEF',
2033
- cdkId: 'PythonLayerVersion',
2034
- isBundled: true,
2035
- property: 'Content',
2036
- },
2037
- {
2038
- // Layer Version
2039
- id: 'LayerVersion3878DA3A',
2040
- cdkId: 'LayerVersion',
2041
- isBundled: false,
2042
- property: 'Content',
2043
- },
2044
- {
2045
- // Bundled layer version
2046
- id: 'BundledLayerVersionPythonRuntime6BADBD6E',
2047
- cdkId: 'BundledLayerVersionPythonRuntime',
2048
- isBundled: true,
2049
- property: 'Content',
2050
- },
2051
- {
2052
- // Python Function
2053
- id: 'PythonFunction0BCF77FD',
2054
- cdkId: 'PythonFunction',
2055
- isBundled: true,
2056
- property: 'Code',
2057
- },
2058
- {
2059
- // Log Retention Function
2060
- id: 'LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aFD4BFC8A',
2061
- cdkId: 'LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8a',
2062
- isBundled: false,
2063
- property: 'Code',
2064
- },
2065
- {
2066
- // Function
2067
- id: 'FunctionPythonRuntime28CBDA05',
2068
- cdkId: 'FunctionPythonRuntime',
2069
- isBundled: false,
2070
- property: 'Code',
2071
- },
2072
- {
2073
- // Bundled Function
2074
- id: 'BundledFunctionPythonRuntime4D9A0918',
2075
- cdkId: 'BundledFunctionPythonRuntime',
2076
- isBundled: true,
2077
- property: 'Code',
2078
- },
2079
- {
2080
- // NodeJs Function
2081
- id: 'NodejsFunction09C1F20F',
2082
- cdkId: 'NodejsFunction',
2083
- isBundled: true,
2084
- property: 'Code',
2085
- },
2086
- {
2087
- // Go Function
2088
- id: 'GoFunctionCA95FBAA',
2089
- cdkId: 'GoFunction',
2090
- isBundled: true,
2091
- property: 'Code',
2092
- },
2093
- {
2094
- // Docker Image Function
2095
- id: 'DockerImageFunction28B773E6',
2096
- cdkId: 'DockerImageFunction',
2097
- dockerFilePath: 'Dockerfile',
2098
- property: 'Code.ImageUri',
2099
- },
2100
- {
2101
- // Spec Rest Api
2102
- id: 'SpecRestAPI7D4B3A34',
2103
- cdkId: 'SpecRestAPI',
2104
- property: 'BodyS3Location',
2105
- },
2106
- ];
2107
-
2108
- for (const resource of expectedResources) {
2109
- fixture.output.write(`validate assets metadata for resource ${resource}`);
2110
- expect(resource.id in template.Resources).toBeTruthy();
2111
- expect(template.Resources[resource.id]).toEqual(
2112
- expect.objectContaining({
2113
- Metadata: {
2114
- 'aws:cdk:path': `${fixture.fullStackName('TestStack')}/${resource.cdkId}/Resource`,
2115
- 'aws:asset:path': expect.stringMatching(/asset\.[0-9a-zA-Z]{64}/),
2116
- 'aws:asset:is-bundled': resource.isBundled,
2117
- 'aws:asset:dockerfile-path': resource.dockerFilePath,
2118
- 'aws:asset:property': resource.property,
2119
- },
2120
- }),
2121
- );
2122
- }
2123
-
2124
- // Nested Stack
2125
- fixture.output.write('validate assets metadata for nested stack resource');
2126
- expect('NestedStackNestedStackNestedStackNestedStackResourceB70834FD' in template.Resources).toBeTruthy();
2127
- expect(template.Resources.NestedStackNestedStackNestedStackNestedStackResourceB70834FD).toEqual(
2128
- expect.objectContaining({
2129
- Metadata: {
2130
- 'aws:cdk:path': `${fixture.fullStackName(
2131
- 'TestStack',
2132
- )}/NestedStack.NestedStack/NestedStack.NestedStackResource`,
2133
- 'aws:asset:path': expect.stringMatching(
2134
- `${fixture.stackNamePrefix.replace(/-/, '')}TestStackNestedStack[0-9A-Z]{8}\.nested\.template\.json`,
2135
- ),
2136
- 'aws:asset:property': 'TemplateURL',
2137
- },
2138
- }),
2139
- );
2140
- }),
2141
- );
2142
-
2143
- integTest(
2144
- 'CDK synth bundled functions as expected',
2145
- withSamIntegrationFixture(async (fixture) => {
2146
- // Synth first
2147
- await fixture.cdkSynth();
2148
-
2149
- const template = fixture.template('TestStack');
2150
-
2151
- const expectedBundledAssets = [
2152
- {
2153
- // Python Layer Version
2154
- id: 'PythonLayerVersion39495CEF',
2155
- files: [
2156
- 'python/layer_version_dependency.py',
2157
- 'python/geonamescache/__init__.py',
2158
- 'python/geonamescache-1.3.0.dist-info',
2159
- ],
2160
- },
2161
- {
2162
- // Layer Version
2163
- id: 'LayerVersion3878DA3A',
2164
- files: ['layer_version_dependency.py', 'requirements.txt'],
2165
- },
2166
- {
2167
- // Bundled layer version
2168
- id: 'BundledLayerVersionPythonRuntime6BADBD6E',
2169
- files: [
2170
- 'python/layer_version_dependency.py',
2171
- 'python/geonamescache/__init__.py',
2172
- 'python/geonamescache-1.3.0.dist-info',
2173
- ],
2174
- },
2175
- {
2176
- // Python Function
2177
- id: 'PythonFunction0BCF77FD',
2178
- files: ['app.py', 'geonamescache/__init__.py', 'geonamescache-1.3.0.dist-info'],
2179
- },
2180
- {
2181
- // Function
2182
- id: 'FunctionPythonRuntime28CBDA05',
2183
- files: ['app.py', 'requirements.txt'],
2184
- },
2185
- {
2186
- // Bundled Function
2187
- id: 'BundledFunctionPythonRuntime4D9A0918',
2188
- files: ['app.py', 'geonamescache/__init__.py', 'geonamescache-1.3.0.dist-info'],
2189
- },
2190
- {
2191
- // NodeJs Function
2192
- id: 'NodejsFunction09C1F20F',
2193
- files: ['index.js'],
2194
- },
2195
- {
2196
- // Go Function
2197
- id: 'GoFunctionCA95FBAA',
2198
- files: ['bootstrap'],
2199
- },
2200
- {
2201
- // Docker Image Function
2202
- id: 'DockerImageFunction28B773E6',
2203
- files: ['app.js', 'Dockerfile', 'package.json'],
2204
- },
2205
- ];
2206
-
2207
- for (const resource of expectedBundledAssets) {
2208
- const assetPath = template.Resources[resource.id].Metadata['aws:asset:path'];
2209
- for (const file of resource.files) {
2210
- fixture.output.write(`validate Path ${file} for resource ${resource}`);
2211
- expect(existsSync(path.join(fixture.integTestDir, 'cdk.out', assetPath, file))).toBeTruthy();
2212
- }
2213
- }
2214
- }),
2215
- );
2216
-
2217
- integTest(
2218
- 'sam can locally test the synthesized cdk application',
2219
- withSamIntegrationFixture(async (fixture) => {
2220
- // Synth first
2221
- await fixture.cdkSynth();
2222
-
2223
- const result = await fixture.samLocalStartApi(
2224
- 'TestStack',
2225
- false,
2226
- randomInteger(30000, 40000),
2227
- '/restapis/spec/pythonFunction',
2228
- );
2229
- expect(result.actionSucceeded).toBeTruthy();
2230
- expect(result.actionOutput).toEqual(
2231
- expect.objectContaining({
2232
- message: 'Hello World',
2233
- }),
2234
- );
2235
- }),
2236
- );
2237
-
2238
- integTest(
2239
- 'skips notice refresh',
2240
- withDefaultFixture(async (fixture) => {
2241
- const output = await fixture.cdkSynth({
2242
- options: ['--no-notices'],
2243
- modEnv: {
2244
- INTEG_STACK_SET: 'stage-using-context',
2245
- },
2246
- allowErrExit: true,
2247
- });
2248
-
2249
- // Neither succeeds nor fails, but skips the refresh
2250
- await expect(output).not.toContain('Notices refreshed');
2251
- await expect(output).not.toContain('Notices refresh failed');
2252
- }),
2253
- );
2254
-
2255
- /**
2256
- * Create an S3 bucket, orphan that bucket, then import the bucket, with a NodeJSFunction lambda also in the stack.
2257
- *
2258
- * Validates fix for https://github.com/aws/aws-cdk/issues/31999 (import fails)
2259
- */
2260
- integTest(
2261
- 'test resource import with construct that requires bundling',
2262
- withDefaultFixture(async (fixture) => {
2263
- // GIVEN
2264
- const outputsFile = path.join(fixture.integTestDir, 'outputs', 'outputs.json');
2265
- await fs.mkdir(path.dirname(outputsFile), { recursive: true });
2266
-
2267
- // First, create a stack that includes a NodeJSFunction lambda and one bucket that will be removed from the stack but NOT deleted from AWS.
2268
- await fixture.cdkDeploy('importable-stack', {
2269
- modEnv: { INCLUDE_NODEJS_FUNCTION_LAMBDA: '1', INCLUDE_SINGLE_BUCKET: '1', RETAIN_SINGLE_BUCKET: '1' },
2270
- options: ['--outputs-file', outputsFile],
2271
- });
2272
-
2273
- try {
2274
- // Second, now the bucket we will remove is in the stack and has a logicalId. We can now make the resource mapping file.
2275
- // This resource mapping file will be used to tell the import operation what bucket to bring into the stack.
2276
- const fullStackName = fixture.fullStackName('importable-stack');
2277
- const outputs = JSON.parse((await fs.readFile(outputsFile, { encoding: 'utf-8' })).toString());
2278
- const bucketLogicalId = outputs[fullStackName].BucketLogicalId;
2279
- const bucketName = outputs[fullStackName].BucketName;
2280
- const bucketResourceMap = {
2281
- [bucketLogicalId]: {
2282
- BucketName: bucketName,
2283
- },
2284
- };
2285
- const mappingFile = path.join(fixture.integTestDir, 'outputs', 'mapping.json');
2286
- await fs.writeFile(mappingFile, JSON.stringify(bucketResourceMap), { encoding: 'utf-8' });
2287
-
2288
- // Third, remove the bucket from the stack, but don't delete the bucket from AWS.
2289
- await fixture.cdkDeploy('importable-stack', {
2290
- modEnv: { INCLUDE_NODEJS_FUNCTION_LAMBDA: '1', INCLUDE_SINGLE_BUCKET: '0', RETAIN_SINGLE_BUCKET: '0' },
2291
- });
2292
- const cfnTemplateBeforeImport = await fixture.aws.cloudFormation.send(
2293
- new GetTemplateCommand({ StackName: fullStackName }),
2294
- );
2295
- expect(cfnTemplateBeforeImport.TemplateBody).not.toContain(bucketLogicalId);
2296
-
2297
- // WHEN
2298
- await fixture.cdk(['import', '--resource-mapping', mappingFile, fixture.fullStackName('importable-stack')], {
2299
- modEnv: { INCLUDE_NODEJS_FUNCTION_LAMBDA: '1', INCLUDE_SINGLE_BUCKET: '1', RETAIN_SINGLE_BUCKET: '0' },
2300
- });
2301
-
2302
- // THEN
2303
- const describeStacksResponse = await fixture.aws.cloudFormation.send(
2304
- new DescribeStacksCommand({ StackName: fullStackName }),
2305
- );
2306
- const cfnTemplateAfterImport = await fixture.aws.cloudFormation.send(
2307
- new GetTemplateCommand({ StackName: fullStackName }),
2308
- );
2309
-
2310
- // If bundling is skipped during import for NodeJSFunction lambda, then the operation should fail and exit
2311
- expect(describeStacksResponse.Stacks![0].StackStatus).toEqual('IMPORT_COMPLETE');
2312
-
2313
- // If the import operation is successful, the template should contain the imported bucket
2314
- expect(cfnTemplateAfterImport.TemplateBody).toContain(bucketLogicalId);
2315
- } finally {
2316
- // Clean up the resources we created
2317
- await fixture.cdkDestroy('importable-stack');
2318
- }
2319
- }),
2320
- );
2321
-
2322
- /**
2323
- * Create a queue, orphan that queue, then import the queue.
2324
- *
2325
- * We want to test with a large template to make sure large templates can work with import.
2326
- */
2327
- integTest(
2328
- 'test resource import',
2329
- withDefaultFixture(async (fixture) => {
2330
- // GIVEN
2331
- const randomPrefix = randomString();
2332
- const uniqueOutputsFileName = `${randomPrefix}Outputs.json`; // other tests use the outputs file. Make sure we don't collide.
2333
- const outputsFile = path.join(fixture.integTestDir, 'outputs', uniqueOutputsFileName);
2334
- await fs.mkdir(path.dirname(outputsFile), { recursive: true });
2335
-
2336
- // First, create a stack that includes many queues, and one queue that will be removed from the stack but NOT deleted from AWS.
2337
- await fixture.cdkDeploy('importable-stack', {
2338
- modEnv: { LARGE_TEMPLATE: '1', INCLUDE_SINGLE_QUEUE: '1', RETAIN_SINGLE_QUEUE: '1' },
2339
- options: ['--outputs-file', outputsFile],
2340
- });
2341
-
2342
- try {
2343
- // Second, now the queue we will remove is in the stack and has a logicalId. We can now make the resource mapping file.
2344
- // This resource mapping file will be used to tell the import operation what queue to bring into the stack.
2345
- const fullStackName = fixture.fullStackName('importable-stack');
2346
- const outputs = JSON.parse((await fs.readFile(outputsFile, { encoding: 'utf-8' })).toString());
2347
- const queueLogicalId = outputs[fullStackName].QueueLogicalId;
2348
- const queueResourceMap = {
2349
- [queueLogicalId]: { QueueUrl: outputs[fullStackName].QueueUrl },
2350
- };
2351
- const mappingFile = path.join(fixture.integTestDir, 'outputs', `${randomPrefix}Mapping.json`);
2352
- await fs.writeFile(mappingFile, JSON.stringify(queueResourceMap), { encoding: 'utf-8' });
2353
-
2354
- // Third, remove the queue from the stack, but don't delete the queue from AWS.
2355
- await fixture.cdkDeploy('importable-stack', {
2356
- modEnv: { LARGE_TEMPLATE: '1', INCLUDE_SINGLE_QUEUE: '0', RETAIN_SINGLE_QUEUE: '0' },
2357
- });
2358
- const cfnTemplateBeforeImport = await fixture.aws.cloudFormation.send(
2359
- new GetTemplateCommand({ StackName: fullStackName }),
2360
- );
2361
- expect(cfnTemplateBeforeImport.TemplateBody).not.toContain(queueLogicalId);
2362
-
2363
- // WHEN
2364
- await fixture.cdk(['import', '--resource-mapping', mappingFile, fixture.fullStackName('importable-stack')], {
2365
- modEnv: { LARGE_TEMPLATE: '1', INCLUDE_SINGLE_QUEUE: '1', RETAIN_SINGLE_QUEUE: '0' },
2366
- });
2367
-
2368
- // THEN
2369
- const describeStacksResponse = await fixture.aws.cloudFormation.send(
2370
- new DescribeStacksCommand({ StackName: fullStackName }),
2371
- );
2372
- const cfnTemplateAfterImport = await fixture.aws.cloudFormation.send(
2373
- new GetTemplateCommand({ StackName: fullStackName }),
2374
- );
2375
- expect(describeStacksResponse.Stacks![0].StackStatus).toEqual('IMPORT_COMPLETE');
2376
- expect(cfnTemplateAfterImport.TemplateBody).toContain(queueLogicalId);
2377
- } finally {
2378
- // Clean up
2379
- await fixture.cdkDestroy('importable-stack');
2380
- }
2381
- }),
2382
- );
2383
-
2384
- integTest(
2385
- 'test migrate deployment for app with localfile source in migrate.json',
2386
- withDefaultFixture(async (fixture) => {
2387
- const outputsFile = path.join(fixture.integTestDir, 'outputs', 'outputs.json');
2388
- await fs.mkdir(path.dirname(outputsFile), { recursive: true });
2389
-
2390
- // Initial deploy
2391
- await fixture.cdkDeploy('migrate-stack', {
2392
- modEnv: { ORPHAN_TOPIC: '1' },
2393
- options: ['--outputs-file', outputsFile],
2394
- });
2395
-
2396
- const outputs = JSON.parse((await fs.readFile(outputsFile, { encoding: 'utf-8' })).toString());
2397
- const stackName = fixture.fullStackName('migrate-stack');
2398
- const queueName = outputs[stackName].QueueName;
2399
- const queueUrl = outputs[stackName].QueueUrl;
2400
- const queueLogicalId = outputs[stackName].QueueLogicalId;
2401
- fixture.log(`Created queue ${queueUrl} in stack ${fixture.fullStackName}`);
2402
-
2403
- // Write the migrate file based on the ID from step one, then deploy the app with migrate
2404
- const migrateFile = path.join(fixture.integTestDir, 'migrate.json');
2405
- await fs.writeFile(
2406
- migrateFile,
2407
- JSON.stringify({
2408
- Source: 'localfile',
2409
- Resources: [
2410
- {
2411
- ResourceType: 'AWS::SQS::Queue',
2412
- LogicalResourceId: queueLogicalId,
2413
- ResourceIdentifier: { QueueUrl: queueUrl },
2414
- },
2415
- ],
2416
- }),
2417
- { encoding: 'utf-8' },
2418
- );
2419
-
2420
- await fixture.cdkDestroy('migrate-stack');
2421
- fixture.log(`Deleted stack ${fixture.fullStackName}, orphaning ${queueName}`);
2422
-
2423
- // Create new stack from existing queue
2424
- try {
2425
- fixture.log(`Deploying new stack ${fixture.fullStackName}, migrating ${queueName} into stack`);
2426
- await fixture.cdkDeploy('migrate-stack');
2427
- } finally {
2428
- // Cleanup
2429
- await fixture.cdkDestroy('migrate-stack');
2430
- }
2431
- }),
2432
- );
2433
-
2434
- integTest(
2435
- "hotswap deployment supports Lambda function's description and environment variables",
2436
- withDefaultFixture(async (fixture) => {
2437
- // GIVEN
2438
- const stackArn = await fixture.cdkDeploy('lambda-hotswap', {
2439
- captureStderr: false,
2440
- modEnv: {
2441
- DYNAMIC_LAMBDA_PROPERTY_VALUE: 'original value',
2442
- },
2443
- });
2444
-
2445
- // WHEN
2446
- const deployOutput = await fixture.cdkDeploy('lambda-hotswap', {
2447
- options: ['--hotswap'],
2448
- captureStderr: true,
2449
- onlyStderr: true,
2450
- modEnv: {
2451
- DYNAMIC_LAMBDA_PROPERTY_VALUE: 'new value',
2452
- },
2453
- });
2454
-
2455
- const response = await fixture.aws.cloudFormation.send(
2456
- new DescribeStacksCommand({
2457
- StackName: stackArn,
2458
- }),
2459
- );
2460
- const functionName = response.Stacks?.[0].Outputs?.[0].OutputValue;
2461
-
2462
- // THEN
2463
- // The deployment should not trigger a full deployment, thus the stack's status must remains
2464
- // "CREATE_COMPLETE"
2465
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
2466
- // The entire string fails locally due to formatting. Making this test less specific
2467
- expect(deployOutput).toMatch(/hotswapped!/);
2468
- expect(deployOutput).toContain(functionName);
2469
- }),
2470
- );
2471
-
2472
- integTest(
2473
- 'hotswap deployment supports Fn::ImportValue intrinsic',
2474
- withDefaultFixture(async (fixture) => {
2475
- // GIVEN
2476
- try {
2477
- await fixture.cdkDeploy('export-value-stack');
2478
- const stackArn = await fixture.cdkDeploy('lambda-hotswap', {
2479
- captureStderr: false,
2480
- modEnv: {
2481
- DYNAMIC_LAMBDA_PROPERTY_VALUE: 'original value',
2482
- USE_IMPORT_VALUE_LAMBDA_PROPERTY: 'true',
2483
- },
2484
- });
2485
-
2486
- // WHEN
2487
- const deployOutput = await fixture.cdkDeploy('lambda-hotswap', {
2488
- options: ['--hotswap'],
2489
- captureStderr: true,
2490
- onlyStderr: true,
2491
- modEnv: {
2492
- DYNAMIC_LAMBDA_PROPERTY_VALUE: 'new value',
2493
- USE_IMPORT_VALUE_LAMBDA_PROPERTY: 'true',
2494
- },
2495
- });
2496
-
2497
- const response = await fixture.aws.cloudFormation.send(
2498
- new DescribeStacksCommand({
2499
- StackName: stackArn,
2500
- }),
2501
- );
2502
- const functionName = response.Stacks?.[0].Outputs?.[0].OutputValue;
2503
-
2504
- // THEN
2505
-
2506
- // The deployment should not trigger a full deployment, thus the stack's status must remains
2507
- // "CREATE_COMPLETE"
2508
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
2509
- // The entire string fails locally due to formatting. Making this test less specific
2510
- expect(deployOutput).toMatch(/hotswapped!/);
2511
- expect(deployOutput).toContain(functionName);
2512
- } finally {
2513
- // Ensure cleanup in reverse order due to use of import/export
2514
- await fixture.cdkDestroy('lambda-hotswap');
2515
- await fixture.cdkDestroy('export-value-stack');
2516
- }
2517
- }),
2518
- );
2519
-
2520
- integTest(
2521
- 'hotswap deployment supports ecs service',
2522
- withDefaultFixture(async (fixture) => {
2523
- // GIVEN
2524
- const stackArn = await fixture.cdkDeploy('ecs-hotswap', {
2525
- captureStderr: false,
2526
- });
2527
-
2528
- // WHEN
2529
- const deployOutput = await fixture.cdkDeploy('ecs-hotswap', {
2530
- options: ['--hotswap'],
2531
- captureStderr: true,
2532
- onlyStderr: true,
2533
- modEnv: {
2534
- DYNAMIC_ECS_PROPERTY_VALUE: 'new value',
2535
- },
2536
- });
2537
-
2538
- const response = await fixture.aws.cloudFormation.send(
2539
- new DescribeStacksCommand({
2540
- StackName: stackArn,
2541
- }),
2542
- );
2543
- const serviceName = response.Stacks?.[0].Outputs?.find((output) => output.OutputKey == 'ServiceName')?.OutputValue;
2544
-
2545
- // THEN
2546
-
2547
- // The deployment should not trigger a full deployment, thus the stack's status must remains
2548
- // "CREATE_COMPLETE"
2549
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
2550
- // The entire string fails locally due to formatting. Making this test less specific
2551
- expect(deployOutput).toMatch(/hotswapped!/);
2552
- expect(deployOutput).toContain(serviceName);
2553
- }),
2554
- );
2555
-
2556
- integTest(
2557
- 'hotswap deployment for ecs service waits for deployment to complete',
2558
- withDefaultFixture(async (fixture) => {
2559
- // GIVEN
2560
- const stackArn = await fixture.cdkDeploy('ecs-hotswap', {
2561
- captureStderr: false,
2562
- });
2563
-
2564
- // WHEN
2565
- const deployOutput = await fixture.cdkDeploy('ecs-hotswap', {
2566
- options: ['--hotswap'],
2567
- modEnv: {
2568
- DYNAMIC_ECS_PROPERTY_VALUE: 'new value',
2569
- },
2570
- });
2571
-
2572
- const describeStacksResponse = await fixture.aws.cloudFormation.send(
2573
- new DescribeStacksCommand({
2574
- StackName: stackArn,
2575
- }),
2576
- );
2577
- const clusterName = describeStacksResponse.Stacks?.[0].Outputs?.find((output) => output.OutputKey == 'ClusterName')
2578
- ?.OutputValue!;
2579
- const serviceName = describeStacksResponse.Stacks?.[0].Outputs?.find((output) => output.OutputKey == 'ServiceName')
2580
- ?.OutputValue!;
2581
-
2582
- // THEN
2583
-
2584
- const describeServicesResponse = await fixture.aws.ecs.send(
2585
- new DescribeServicesCommand({
2586
- cluster: clusterName,
2587
- services: [serviceName],
2588
- }),
2589
- );
2590
- expect(describeServicesResponse.services?.[0].deployments).toHaveLength(1); // only one deployment present
2591
- expect(deployOutput).toMatch(/hotswapped!/);
2592
- }),
2593
- );
2594
-
2595
- integTest(
2596
- 'hotswap deployment for ecs service detects failed deployment and errors',
2597
- withExtendedTimeoutFixture(async (fixture) => {
2598
- // GIVEN
2599
- await fixture.cdkDeploy('ecs-hotswap', { verbose: true });
2600
-
2601
- // WHEN
2602
- const deployOutput = await fixture.cdkDeploy('ecs-hotswap', {
2603
- options: ['--hotswap'],
2604
- modEnv: {
2605
- USE_INVALID_ECS_HOTSWAP_IMAGE: 'true',
2606
- },
2607
- allowErrExit: true,
2608
- verbose: true,
2609
- });
2610
-
2611
- // THEN
2612
- const expectedSubstring = 'Resource is not in the expected state due to waiter status: TIMEOUT';
2613
- expect(deployOutput).toContain(expectedSubstring);
2614
- expect(deployOutput).toContain('Observed responses:');
2615
- expect(deployOutput).toContain('200: OK');
2616
- expect(deployOutput).not.toContain('hotswapped!');
2617
- }),
2618
- );
2619
-
2620
- integTest('hotswap deployment supports AppSync APIs with many functions',
2621
- withDefaultFixture(async (fixture) => {
2622
- // GIVEN
2623
- const stackArn = await fixture.cdkDeploy('appsync-hotswap', {
2624
- captureStderr: false,
2625
- });
2626
-
2627
- // WHEN
2628
- const deployOutput = await fixture.cdkDeploy('appsync-hotswap', {
2629
- options: ['--hotswap'],
2630
- captureStderr: true,
2631
- onlyStderr: true,
2632
- modEnv: {
2633
- DYNAMIC_APPSYNC_PROPERTY_VALUE: '$util.qr($ctx.stash.put("newTemplate", []))\n$util.toJson({})',
2634
- },
2635
- });
2636
-
2637
- const response = await fixture.aws.cloudFormation.send(
2638
- new DescribeStacksCommand({
2639
- StackName: stackArn,
2640
- }),
2641
- );
2642
-
2643
- expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
2644
- // assert all 50 functions were hotswapped
2645
- for (const i of Array(50).keys()) {
2646
- expect(deployOutput).toContain(`AWS::AppSync::FunctionConfiguration 'appsync_function${i}' hotswapped!`);
2647
- }
2648
- }),
2649
- );
2650
-
2651
- integTest('hotswap ECS deployment respects properties override', withDefaultFixture(async (fixture) => {
2652
- // Update the CDK context with the new ECS properties
2653
- let ecsMinimumHealthyPercent = 100;
2654
- let ecsMaximumHealthyPercent = 200;
2655
- let cdkJson = JSON.parse(await fs.readFile(path.join(fixture.integTestDir, 'cdk.json'), 'utf8'));
2656
- cdkJson = {
2657
- ...cdkJson,
2658
- hotswap: {
2659
- ecs: {
2660
- minimumHealthyPercent: ecsMinimumHealthyPercent,
2661
- maximumHealthyPercent: ecsMaximumHealthyPercent,
2662
- },
2663
- },
2664
- };
2665
-
2666
- await fs.writeFile(path.join(fixture.integTestDir, 'cdk.json'), JSON.stringify(cdkJson));
2667
-
2668
- // GIVEN
2669
- const stackArn = await fixture.cdkDeploy('ecs-hotswap', {
2670
- captureStderr: false,
2671
- });
2672
-
2673
- // WHEN
2674
- await fixture.cdkDeploy('ecs-hotswap', {
2675
- options: [
2676
- '--hotswap',
2677
- ],
2678
- modEnv: {
2679
- DYNAMIC_ECS_PROPERTY_VALUE: 'new value',
2680
- },
2681
- });
2682
-
2683
- const describeStacksResponse = await fixture.aws.cloudFormation.send(
2684
- new DescribeStacksCommand({
2685
- StackName: stackArn,
2686
- }),
2687
- );
2688
-
2689
- const clusterName = describeStacksResponse.Stacks?.[0].Outputs?.find(output => output.OutputKey == 'ClusterName')?.OutputValue!;
2690
- const serviceName = describeStacksResponse.Stacks?.[0].Outputs?.find(output => output.OutputKey == 'ServiceName')?.OutputValue!;
2691
-
2692
- // THEN
2693
- const describeServicesResponse = await fixture.aws.ecs.send(
2694
- new DescribeServicesCommand({
2695
- cluster: clusterName,
2696
- services: [serviceName],
2697
- }),
2698
- );
2699
- expect(describeServicesResponse.services?.[0].deploymentConfiguration?.minimumHealthyPercent).toEqual(ecsMinimumHealthyPercent);
2700
- expect(describeServicesResponse.services?.[0].deploymentConfiguration?.maximumPercent).toEqual(ecsMaximumHealthyPercent);
2701
- }));
2702
-
2703
- async function listChildren(parent: string, pred: (x: string) => Promise<boolean>) {
2704
- const ret = new Array<string>();
2705
- for (const child of await fs.readdir(parent, { encoding: 'utf-8' })) {
2706
- const fullPath = path.join(parent, child.toString());
2707
- if (await pred(fullPath)) {
2708
- ret.push(fullPath);
2709
- }
2710
- }
2711
- return ret;
2712
- }
2713
-
2714
- async function listChildDirs(parent: string) {
2715
- return listChildren(parent, async (fullPath: string) => (await fs.stat(fullPath)).isDirectory());
2716
- }
2717
-
2718
- integTest(
2719
- 'cdk notices with --unacknowledged',
2720
- withDefaultFixture(async (fixture) => {
2721
- const noticesUnacknowledged = await fixture.cdk(['notices', '--unacknowledged'], { verbose: false });
2722
- const noticesUnacknowledgedAlias = await fixture.cdk(['notices', '-u'], { verbose: false });
2723
- expect(noticesUnacknowledged).toEqual(expect.stringMatching(/There are \d{1,} unacknowledged notice\(s\)./));
2724
- expect(noticesUnacknowledged).toEqual(noticesUnacknowledgedAlias);
2725
- }),
2726
- );
2727
-
2728
- integTest(
2729
- 'test cdk rollback',
2730
- withSpecificFixture('rollback-test-app', async (fixture) => {
2731
- let phase = '1';
2732
-
2733
- // Should succeed
2734
- await fixture.cdkDeploy('test-rollback', {
2735
- options: ['--no-rollback'],
2736
- modEnv: { PHASE: phase },
2737
- verbose: false,
2738
- });
2739
- try {
2740
- phase = '2a';
2741
-
2742
- // Should fail
2743
- const deployOutput = await fixture.cdkDeploy('test-rollback', {
2744
- options: ['--no-rollback'],
2745
- modEnv: { PHASE: phase },
2746
- verbose: false,
2747
- allowErrExit: true,
2748
- });
2749
- expect(deployOutput).toContain('UPDATE_FAILED');
2750
-
2751
- // Rollback
2752
- await fixture.cdk(['rollback'], {
2753
- modEnv: { PHASE: phase },
2754
- verbose: false,
2755
- });
2756
- } finally {
2757
- await fixture.cdkDestroy('test-rollback');
2758
- }
2759
- }),
2760
- );
2761
-
2762
- integTest(
2763
- 'automatic rollback if paused and change contains a replacement',
2764
- withSpecificFixture('rollback-test-app', async (fixture) => {
2765
- let phase = '1';
2766
-
2767
- // Should succeed
2768
- await fixture.cdkDeploy('test-rollback', {
2769
- options: ['--no-rollback'],
2770
- modEnv: { PHASE: phase },
2771
- verbose: false,
2772
- });
2773
- try {
2774
- phase = '2a';
2775
-
2776
- // Should fail
2777
- const deployOutput = await fixture.cdkDeploy('test-rollback', {
2778
- options: ['--no-rollback'],
2779
- modEnv: { PHASE: phase },
2780
- verbose: false,
2781
- allowErrExit: true,
2782
- });
2783
- expect(deployOutput).toContain('UPDATE_FAILED');
2784
-
2785
- // Do a deployment with a replacement and --force: this will roll back first and then deploy normally
2786
- phase = '3';
2787
- await fixture.cdkDeploy('test-rollback', {
2788
- options: ['--no-rollback', '--force'],
2789
- modEnv: { PHASE: phase },
2790
- verbose: false,
2791
- });
2792
- } finally {
2793
- await fixture.cdkDestroy('test-rollback');
2794
- }
2795
- }),
2796
- );
2797
-
2798
- integTest(
2799
- 'automatic rollback if paused and --no-rollback is removed from flags',
2800
- withSpecificFixture('rollback-test-app', async (fixture) => {
2801
- let phase = '1';
2802
-
2803
- // Should succeed
2804
- await fixture.cdkDeploy('test-rollback', {
2805
- options: ['--no-rollback'],
2806
- modEnv: { PHASE: phase },
2807
- verbose: false,
2808
- });
2809
- try {
2810
- phase = '2a';
2811
-
2812
- // Should fail
2813
- const deployOutput = await fixture.cdkDeploy('test-rollback', {
2814
- options: ['--no-rollback'],
2815
- modEnv: { PHASE: phase },
2816
- verbose: false,
2817
- allowErrExit: true,
2818
- });
2819
- expect(deployOutput).toContain('UPDATE_FAILED');
2820
-
2821
- // Do a deployment removing --no-rollback: this will roll back first and then deploy normally
2822
- phase = '1';
2823
- await fixture.cdkDeploy('test-rollback', {
2824
- options: ['--force'],
2825
- modEnv: { PHASE: phase },
2826
- verbose: false,
2827
- });
2828
- } finally {
2829
- await fixture.cdkDestroy('test-rollback');
2830
- }
2831
- }),
2832
- );
2833
-
2834
- integTest(
2835
- 'automatic rollback if replacement and --no-rollback is removed from flags',
2836
- withSpecificFixture('rollback-test-app', async (fixture) => {
2837
- let phase = '1';
2838
-
2839
- // Should succeed
2840
- await fixture.cdkDeploy('test-rollback', {
2841
- options: ['--no-rollback'],
2842
- modEnv: { PHASE: phase },
2843
- verbose: false,
2844
- });
2845
- try {
2846
- // Do a deployment with a replacement and removing --no-rollback: this will do a regular rollback deploy
2847
- phase = '3';
2848
- await fixture.cdkDeploy('test-rollback', {
2849
- options: ['--force'],
2850
- modEnv: { PHASE: phase },
2851
- verbose: false,
2852
- });
2853
- } finally {
2854
- await fixture.cdkDestroy('test-rollback');
2855
- }
2856
- }),
2857
- );
2858
-
2859
- integTest(
2860
- 'test cdk rollback --force',
2861
- withSpecificFixture('rollback-test-app', async (fixture) => {
2862
- let phase = '1';
2863
-
2864
- // Should succeed
2865
- await fixture.cdkDeploy('test-rollback', {
2866
- options: ['--no-rollback'],
2867
- modEnv: { PHASE: phase },
2868
- verbose: false,
2869
- });
2870
- try {
2871
- phase = '2b'; // Fail update and also fail rollback
2872
-
2873
- // Should fail
2874
- const deployOutput = await fixture.cdkDeploy('test-rollback', {
2875
- options: ['--no-rollback'],
2876
- modEnv: { PHASE: phase },
2877
- verbose: false,
2878
- allowErrExit: true,
2879
- });
2880
-
2881
- expect(deployOutput).toContain('UPDATE_FAILED');
2882
-
2883
- // Should still fail
2884
- const rollbackOutput = await fixture.cdk(['rollback'], {
2885
- modEnv: { PHASE: phase },
2886
- verbose: false,
2887
- allowErrExit: true,
2888
- });
2889
-
2890
- expect(rollbackOutput).toContain('Failing rollback');
2891
-
2892
- // Rollback and force cleanup
2893
- await fixture.cdk(['rollback', '--force'], {
2894
- modEnv: { PHASE: phase },
2895
- verbose: false,
2896
- });
2897
- } finally {
2898
- await fixture.cdkDestroy('test-rollback');
2899
- }
2900
- }),
2901
- );
2902
-
2903
- integTest('cdk notices are displayed correctly', withDefaultFixture(async (fixture) => {
2904
- const cache = {
2905
- expiration: 4125963264000, // year 2100 so we never overwrite the cache
2906
- notices: [
2907
- {
2908
- title: 'Bootstrap 1999 Notice',
2909
- issueNumber: 4444,
2910
- overview: 'Overview for Bootstrap 1999 Notice. AffectedEnvironments:<{resolve:ENVIRONMENTS}>',
2911
- components: [
2912
- {
2913
- name: 'bootstrap',
2914
- version: '<1999', // so we include all possible environments
2915
- },
2916
- ],
2917
- schemaVersion: '1',
2918
- },
2919
- ],
2920
- };
2921
-
2922
- const cdkCacheDir = path.join(fixture.integTestDir, 'cache');
2923
- await fs.mkdir(cdkCacheDir);
2924
- await fs.writeFile(path.join(cdkCacheDir, 'notices.json'), JSON.stringify(cache));
2925
-
2926
- const output = await fixture.cdkDeploy('notices', {
2927
- verbose: false,
2928
- modEnv: {
2929
- CDK_HOME: fixture.integTestDir,
2930
- },
2931
- });
2932
-
2933
- expect(output).toContain('Overview for Bootstrap 1999 Notice');
2934
-
2935
- // assert dynamic environments are resolved
2936
- expect(output).toContain(`AffectedEnvironments:<aws://${await fixture.aws.account()}/${fixture.aws.region}>`);
2937
- }));
2938
-
2939
- integTest('requests go through a proxy when configured',
2940
- withDefaultFixture(async (fixture) => {
2941
- const proxyServer = await startProxyServer();
2942
- try {
2943
- // Delete notices cache if it exists
2944
- await fs.rm(path.join(process.env.HOME ?? os.userInfo().homedir, '.cdk/cache/notices.json'), { force: true });
2945
-
2946
- await fixture.cdkDeploy('test-2', {
2947
- captureStderr: true,
2948
- options: [
2949
- '--proxy', proxyServer.url,
2950
- '--ca-bundle-path', proxyServer.certPath,
2951
- ],
2952
- modEnv: {
2953
- CDK_HOME: fixture.integTestDir,
2954
- },
2955
- });
2956
-
2957
- const requests = await proxyServer.getSeenRequests();
2958
-
2959
- expect(requests.map(req => req.url))
2960
- .toContain('https://cli.cdk.dev-tools.aws.dev/notices.json');
2961
-
2962
- const actionsUsed = awsActionsFromRequests(requests);
2963
- expect(actionsUsed).toContain('AssumeRole');
2964
- expect(actionsUsed).toContain('CreateChangeSet');
2965
- } finally {
2966
- await proxyServer.stop();
2967
- }
2968
- }),
2969
- );