@aws-cdk-testing/cli-integ 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/.eslintrc.js +9 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +16 -0
  4. package/README.md +205 -0
  5. package/bin/apply-patches +22 -0
  6. package/bin/download-and-run-old-tests +52 -0
  7. package/bin/query-github +2 -0
  8. package/bin/query-github.d.ts +1 -0
  9. package/bin/query-github.js +54 -0
  10. package/bin/query-github.ts +56 -0
  11. package/bin/run-suite +2 -0
  12. package/bin/run-suite.d.ts +1 -0
  13. package/bin/run-suite.js +131 -0
  14. package/bin/run-suite.ts +140 -0
  15. package/bin/stage-distribution +2 -0
  16. package/bin/stage-distribution.d.ts +1 -0
  17. package/bin/stage-distribution.js +217 -0
  18. package/bin/stage-distribution.ts +267 -0
  19. package/bin/test-root +2 -0
  20. package/bin/test-root.d.ts +1 -0
  21. package/bin/test-root.js +6 -0
  22. package/bin/test-root.ts +3 -0
  23. package/entrypoints/test-cli-regression-against-current-code.sh +11 -0
  24. package/entrypoints/test-cli-regression-against-latest-release.sh +11 -0
  25. package/entrypoints/test-cli-regression.bash +83 -0
  26. package/entrypoints/test.sh +12 -0
  27. package/lib/aws.d.ts +51 -0
  28. package/lib/aws.js +206 -0
  29. package/lib/aws.ts +263 -0
  30. package/lib/corking.d.ts +12 -0
  31. package/lib/corking.js +35 -0
  32. package/lib/corking.ts +33 -0
  33. package/lib/eventually.d.ts +20 -0
  34. package/lib/eventually.js +34 -0
  35. package/lib/eventually.ts +42 -0
  36. package/lib/files.d.ts +15 -0
  37. package/lib/files.js +80 -0
  38. package/lib/files.ts +80 -0
  39. package/lib/github.d.ts +4 -0
  40. package/lib/github.js +43 -0
  41. package/lib/github.ts +43 -0
  42. package/lib/index.d.ts +13 -0
  43. package/lib/index.js +30 -0
  44. package/lib/index.ts +13 -0
  45. package/lib/integ-test.d.ts +10 -0
  46. package/lib/integ-test.js +70 -0
  47. package/lib/integ-test.ts +81 -0
  48. package/lib/lists.d.ts +1 -0
  49. package/lib/lists.js +11 -0
  50. package/lib/lists.ts +9 -0
  51. package/lib/memoize.d.ts +6 -0
  52. package/lib/memoize.js +18 -0
  53. package/lib/memoize.ts +14 -0
  54. package/lib/npm.d.ts +8 -0
  55. package/lib/npm.js +38 -0
  56. package/lib/npm.ts +41 -0
  57. package/lib/package-sources/release-source.d.ts +23 -0
  58. package/lib/package-sources/release-source.js +71 -0
  59. package/lib/package-sources/release-source.ts +81 -0
  60. package/lib/package-sources/repo-source.d.ts +30 -0
  61. package/lib/package-sources/repo-source.js +97 -0
  62. package/lib/package-sources/repo-source.ts +111 -0
  63. package/lib/package-sources/repo-tools/npm +2 -0
  64. package/lib/package-sources/repo-tools/npm.d.ts +1 -0
  65. package/lib/package-sources/repo-tools/npm.js +43 -0
  66. package/lib/package-sources/repo-tools/npm.ts +48 -0
  67. package/lib/package-sources/source.d.ts +28 -0
  68. package/lib/package-sources/source.js +3 -0
  69. package/lib/package-sources/source.ts +35 -0
  70. package/lib/package-sources/subprocess.d.ts +3 -0
  71. package/lib/package-sources/subprocess.js +17 -0
  72. package/lib/package-sources/subprocess.ts +15 -0
  73. package/lib/resource-pool.d.ts +50 -0
  74. package/lib/resource-pool.js +117 -0
  75. package/lib/resource-pool.ts +140 -0
  76. package/lib/resources.d.ts +1 -0
  77. package/lib/resources.js +6 -0
  78. package/lib/resources.ts +4 -0
  79. package/lib/shell.d.ts +56 -0
  80. package/lib/shell.js +123 -0
  81. package/lib/shell.ts +168 -0
  82. package/lib/staging/codeartifact.d.ts +44 -0
  83. package/lib/staging/codeartifact.js +281 -0
  84. package/lib/staging/codeartifact.ts +387 -0
  85. package/lib/staging/maven.d.ts +5 -0
  86. package/lib/staging/maven.js +91 -0
  87. package/lib/staging/maven.ts +95 -0
  88. package/lib/staging/npm.d.ts +4 -0
  89. package/lib/staging/npm.js +55 -0
  90. package/lib/staging/npm.ts +62 -0
  91. package/lib/staging/nuget.d.ts +4 -0
  92. package/lib/staging/nuget.js +69 -0
  93. package/lib/staging/nuget.ts +75 -0
  94. package/lib/staging/parallel-shell.d.ts +5 -0
  95. package/lib/staging/parallel-shell.js +45 -0
  96. package/lib/staging/parallel-shell.ts +51 -0
  97. package/lib/staging/pypi.d.ts +4 -0
  98. package/lib/staging/pypi.js +48 -0
  99. package/lib/staging/pypi.ts +50 -0
  100. package/lib/staging/usage-dir.d.ts +31 -0
  101. package/lib/staging/usage-dir.js +87 -0
  102. package/lib/staging/usage-dir.ts +99 -0
  103. package/lib/with-aws.d.ts +14 -0
  104. package/lib/with-aws.js +60 -0
  105. package/lib/with-aws.ts +67 -0
  106. package/lib/with-cdk-app.d.ts +210 -0
  107. package/lib/with-cdk-app.js +539 -0
  108. package/lib/with-cdk-app.ts +742 -0
  109. package/lib/with-cli-lib.d.ts +17 -0
  110. package/lib/with-cli-lib.js +123 -0
  111. package/lib/with-cli-lib.ts +134 -0
  112. package/lib/with-packages.d.ts +5 -0
  113. package/lib/with-packages.js +13 -0
  114. package/lib/with-packages.ts +15 -0
  115. package/lib/with-sam.d.ts +33 -0
  116. package/lib/with-sam.js +258 -0
  117. package/lib/with-sam.ts +288 -0
  118. package/lib/with-temporary-directory.d.ts +5 -0
  119. package/lib/with-temporary-directory.js +31 -0
  120. package/lib/with-temporary-directory.ts +35 -0
  121. package/lib/with-timeout.d.ts +19 -0
  122. package/lib/with-timeout.js +34 -0
  123. package/lib/with-timeout.ts +33 -0
  124. package/lib/xpmutex.d.ts +43 -0
  125. package/lib/xpmutex.js +207 -0
  126. package/lib/xpmutex.ts +218 -0
  127. package/package.json +111 -0
  128. package/resources/bootstrap-templates/session-tags.all-roles-deny-all.yaml +703 -0
  129. package/resources/bootstrap-templates/session-tags.deploy-role-deny-sqs.yaml +700 -0
  130. package/resources/cdk-apps/app/app.js +926 -0
  131. package/resources/cdk-apps/app/appsync.hotswap.graphql +3 -0
  132. package/resources/cdk-apps/app/cdk.json +7 -0
  133. package/resources/cdk-apps/app/docker/Dockerfile +2 -0
  134. package/resources/cdk-apps/app/docker/Dockerfile.Custom +2 -0
  135. package/resources/cdk-apps/app/lambda/index.js +4 -0
  136. package/resources/cdk-apps/app/lambda/response.json +3 -0
  137. package/resources/cdk-apps/app/nested-stack.js +65 -0
  138. package/resources/cdk-apps/cfn-include-app/cdk.json +4 -0
  139. package/resources/cdk-apps/cfn-include-app/cfn-include-app.js +21 -0
  140. package/resources/cdk-apps/cfn-include-app/example-template.json +13 -0
  141. package/resources/cdk-apps/rollback-test-app/app.js +110 -0
  142. package/resources/cdk-apps/rollback-test-app/cdk.json +7 -0
  143. package/resources/cdk-apps/sam_cdk_integ_app/bin/test-app.js +11 -0
  144. package/resources/cdk-apps/sam_cdk_integ_app/cdk.json +6 -0
  145. package/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js +19 -0
  146. package/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js +134 -0
  147. package/resources/cdk-apps/sam_cdk_integ_app/src/docker/DockerImageFunctionConstruct/.no-packagejson-validator +0 -0
  148. package/resources/cdk-apps/sam_cdk_integ_app/src/docker/DockerImageFunctionConstruct/Dockerfile +9 -0
  149. package/resources/cdk-apps/sam_cdk_integ_app/src/docker/DockerImageFunctionConstruct/app.js +22 -0
  150. package/resources/cdk-apps/sam_cdk_integ_app/src/docker/DockerImageFunctionConstruct/package.json +18 -0
  151. package/resources/cdk-apps/sam_cdk_integ_app/src/go/GoFunctionConstruct/go.mod +5 -0
  152. package/resources/cdk-apps/sam_cdk_integ_app/src/go/GoFunctionConstruct/go.sum +17 -0
  153. package/resources/cdk-apps/sam_cdk_integ_app/src/go/GoFunctionConstruct/main.go +17 -0
  154. package/resources/cdk-apps/sam_cdk_integ_app/src/nodejs/NodeJsFunctionConstruct/.no-packagejson-validator +0 -0
  155. package/resources/cdk-apps/sam_cdk_integ_app/src/nodejs/NodeJsFunctionConstruct/app.ts +16 -0
  156. package/resources/cdk-apps/sam_cdk_integ_app/src/nodejs/NodeJsFunctionConstruct/package-lock.json +12 -0
  157. package/resources/cdk-apps/sam_cdk_integ_app/src/nodejs/NodeJsFunctionConstruct/package.json +5 -0
  158. package/resources/cdk-apps/sam_cdk_integ_app/src/python/Function/app.py +15 -0
  159. package/resources/cdk-apps/sam_cdk_integ_app/src/python/Function/requirements.txt +1 -0
  160. package/resources/cdk-apps/sam_cdk_integ_app/src/python/Layer/layer_version_dependency.py +5 -0
  161. package/resources/cdk-apps/sam_cdk_integ_app/src/python/Layer/requirements.txt +1 -0
  162. package/resources/cdk-apps/sam_cdk_integ_app/src/rest-api-definition.yaml +12 -0
  163. package/resources/cdk-apps/simple-app/app.js +26 -0
  164. package/resources/cdk-apps/simple-app/cdk.json +7 -0
  165. package/resources/cli-regression-patches/v1.119.0/NOTES.md +5 -0
  166. package/resources/cli-regression-patches/v1.119.0/cli.integtest.js +659 -0
  167. package/resources/cli-regression-patches/v1.130.0/NOTES.md +12 -0
  168. package/resources/cli-regression-patches/v1.130.0/app/app.js +378 -0
  169. package/resources/cli-regression-patches/v1.130.0/bootstrapping.integtest.js +220 -0
  170. package/resources/cli-regression-patches/v1.44.0/NOTES.md +18 -0
  171. package/resources/cli-regression-patches/v1.44.0/bootstrapping.integtest.js +126 -0
  172. package/resources/cli-regression-patches/v1.44.0/test.sh +26 -0
  173. package/resources/cli-regression-patches/v1.61.1/NOTES.md +2 -0
  174. package/resources/cli-regression-patches/v1.61.1/skip-tests.txt +16 -0
  175. package/resources/cli-regression-patches/v1.62.0/NOTES.md +2 -0
  176. package/resources/cli-regression-patches/v1.62.0/aws-helpers.js +245 -0
  177. package/resources/cli-regression-patches/v1.63.0/NOTES.md +1 -0
  178. package/resources/cli-regression-patches/v1.63.0/skip-tests.txt +7 -0
  179. package/resources/cli-regression-patches/v1.64.0/NOTES.md +3 -0
  180. package/resources/cli-regression-patches/v1.64.0/cdk-helpers.js +325 -0
  181. package/resources/cli-regression-patches/v1.64.0/cli.integtest.js +599 -0
  182. package/resources/cli-regression-patches/v1.64.1/NOTES.md +3 -0
  183. package/resources/cli-regression-patches/v1.64.1/cdk-helpers.js +324 -0
  184. package/resources/cli-regression-patches/v1.64.1/cli.integtest.js +599 -0
  185. package/resources/cli-regression-patches/v1.67.0/NOTES.md +2 -0
  186. package/resources/cli-regression-patches/v1.67.0/cdk-helpers.js +331 -0
  187. package/resources/cli-regression-patches/v2.130.0/NOTES.md +1 -0
  188. package/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/nested-stack.js +19 -0
  189. package/resources/cli-regression-patches/v2.130.0/node_modules/@aws-cdk-testing/cli-integ/resources/cdk-apps/sam_cdk_integ_app/lib/test-stack.js +134 -0
  190. package/resources/cli-regression-patches/v2.130.0/skip-tests.txt +5 -0
  191. package/resources/cli-regression-patches/v2.132.0/NOTES.md +1 -0
  192. package/resources/cli-regression-patches/v2.132.0/skip-tests.txt +4 -0
  193. package/resources/cli-regression-patches/v2.142.0/NOTES.md +1 -0
  194. package/resources/cli-regression-patches/v2.142.0/skip-tests.txt +4 -0
  195. package/resources/cli-regression-patches/v2.160.0/skip-tests.txt +2 -0
  196. package/resources/cli-regression-patches/v2.161.0/NOTES.md +1 -0
  197. package/resources/cli-regression-patches/v2.161.0/skip-tests.txt +5 -0
  198. package/resources/cli-regression-patches/v2.166.0/NOTES.md +1 -0
  199. package/resources/cli-regression-patches/v2.166.0/skip-tests.txt +2 -0
  200. package/resources/cloud-assemblies/0.36.0/InitStack.template.json +1 -0
  201. package/resources/cloud-assemblies/0.36.0/cdk.out +1 -0
  202. package/resources/cloud-assemblies/0.36.0/manifest.json +19 -0
  203. package/resources/cloud-assemblies/1.10.0-lookup-default-vpc/InitStack.template.json +2 -0
  204. package/resources/cloud-assemblies/1.10.0-lookup-default-vpc/cdk.out +1 -0
  205. package/resources/cloud-assemblies/1.10.0-lookup-default-vpc/manifest.json.js +37 -0
  206. package/resources/cloud-assemblies/1.10.0-request-azs/InitStack.template.json +2 -0
  207. package/resources/cloud-assemblies/1.10.0-request-azs/cdk.out +1 -0
  208. package/resources/cloud-assemblies/1.10.0-request-azs/manifest.json.js +34 -0
  209. package/resources/integ.jest.config.js +25 -0
  210. package/resources/templates/sqs-template.json +36 -0
  211. package/skip-tests.txt +8 -0
  212. package/tests/cli-integ-tests/README.md +47 -0
  213. package/tests/cli-integ-tests/bootstrapping.integtest.d.ts +1 -0
  214. package/tests/cli-integ-tests/bootstrapping.integtest.js +412 -0
  215. package/tests/cli-integ-tests/bootstrapping.integtest.ts +493 -0
  216. package/tests/cli-integ-tests/cli-lib.integtest.d.ts +1 -0
  217. package/tests/cli-integ-tests/cli-lib.integtest.js +62 -0
  218. package/tests/cli-integ-tests/cli-lib.integtest.ts +90 -0
  219. package/tests/cli-integ-tests/cli.integtest.d.ts +1 -0
  220. package/tests/cli-integ-tests/cli.integtest.js +2104 -0
  221. package/tests/cli-integ-tests/cli.integtest.ts +2874 -0
  222. package/tests/cli-integ-tests/garbage-collection.integtest.d.ts +1 -0
  223. package/tests/cli-integ-tests/garbage-collection.integtest.js +314 -0
  224. package/tests/cli-integ-tests/garbage-collection.integtest.ts +392 -0
  225. package/tests/init-csharp/init-csharp.integtest.d.ts +1 -0
  226. package/tests/init-csharp/init-csharp.integtest.js +14 -0
  227. package/tests/init-csharp/init-csharp.integtest.ts +15 -0
  228. package/tests/init-fsharp/init-fsharp.integtest.d.ts +1 -0
  229. package/tests/init-fsharp/init-fsharp.integtest.js +14 -0
  230. package/tests/init-fsharp/init-fsharp.integtest.ts +15 -0
  231. package/tests/init-go/init-go.integtest.d.ts +1 -0
  232. package/tests/init-go/init-go.integtest.js +21 -0
  233. package/tests/init-go/init-go.integtest.ts +23 -0
  234. package/tests/init-java/init-java.integtest.d.ts +1 -0
  235. package/tests/init-java/init-java.integtest.js +14 -0
  236. package/tests/init-java/init-java.integtest.ts +14 -0
  237. package/tests/init-javascript/init-javascript.integtest.d.ts +1 -0
  238. package/tests/init-javascript/init-javascript.integtest.js +53 -0
  239. package/tests/init-javascript/init-javascript.integtest.ts +59 -0
  240. package/tests/init-python/init-python.integtest.d.ts +1 -0
  241. package/tests/init-python/init-python.integtest.js +19 -0
  242. package/tests/init-python/init-python.integtest.ts +20 -0
  243. package/tests/init-typescript-app/init-typescript-app.integtest.d.ts +1 -0
  244. package/tests/init-typescript-app/init-typescript-app.integtest.js +54 -0
  245. package/tests/init-typescript-app/init-typescript-app.integtest.ts +66 -0
  246. package/tests/init-typescript-lib/init-typescript-lib.integtest.d.ts +1 -0
  247. package/tests/init-typescript-lib/init-typescript-lib.integtest.js +13 -0
  248. package/tests/init-typescript-lib/init-typescript-lib.integtest.ts +13 -0
  249. package/tests/tool-integrations/amplify.integtest.d.ts +1 -0
  250. package/tests/tool-integrations/amplify.integtest.js +39 -0
  251. package/tests/tool-integrations/amplify.integtest.ts +43 -0
  252. package/tests/tool-integrations/with-tool-context.d.ts +9 -0
  253. package/tests/tool-integrations/with-tool-context.js +13 -0
  254. package/tests/tool-integrations/with-tool-context.ts +14 -0
  255. package/tests/uberpackage/uberpackage.integtest.d.ts +1 -0
  256. package/tests/uberpackage/uberpackage.integtest.js +11 -0
  257. package/tests/uberpackage/uberpackage.integtest.ts +11 -0
@@ -0,0 +1,926 @@
1
+ const path = require('path');
2
+
3
+ var constructs = require('constructs');
4
+ if (process.env.PACKAGE_LAYOUT_VERSION === '1') {
5
+ var cdk = require('@aws-cdk/core');
6
+ var ec2 = require('@aws-cdk/aws-ec2');
7
+ var ecs = require('@aws-cdk/aws-ecs');
8
+ var s3 = require('@aws-cdk/aws-s3');
9
+ var ssm = require('@aws-cdk/aws-ssm');
10
+ var iam = require('@aws-cdk/aws-iam');
11
+ var sns = require('@aws-cdk/aws-sns');
12
+ var sqs = require('@aws-cdk/aws-sqs');
13
+ var lambda = require('@aws-cdk/aws-lambda');
14
+ var sso = require('@aws-cdk/aws-sso');
15
+ var docker = require('@aws-cdk/aws-ecr-assets');
16
+ var appsync = require('@aws-cdk/aws-appsync');
17
+ } else {
18
+ var cdk = require('aws-cdk-lib');
19
+ var {
20
+ DefaultStackSynthesizer,
21
+ LegacyStackSynthesizer,
22
+ aws_ec2: ec2,
23
+ aws_ecs: ecs,
24
+ aws_sso: sso,
25
+ aws_s3: s3,
26
+ aws_ssm: ssm,
27
+ aws_iam: iam,
28
+ aws_sns: sns,
29
+ aws_sqs: sqs,
30
+ aws_lambda: lambda,
31
+ aws_ecr_assets: docker,
32
+ aws_appsync: appsync,
33
+ Stack
34
+ } = require('aws-cdk-lib');
35
+ }
36
+
37
+ const { Annotations } = cdk;
38
+ const { StackWithNestedStack, StackWithDoublyNestedStack, StackWithNestedStackUsingParameters } = require('./nested-stack');
39
+
40
+ const stackPrefix = process.env.STACK_NAME_PREFIX;
41
+ if (!stackPrefix) {
42
+ throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
43
+ }
44
+
45
+ class MyStack extends cdk.Stack {
46
+ constructor(parent, id, props) {
47
+ super(parent, id, props);
48
+ new sns.Topic(this, 'topic');
49
+
50
+ if (cdk.AvailabilityZoneProvider) { // <= 0.34.0
51
+ new cdk.AvailabilityZoneProvider(this).availabilityZones;
52
+ } else if (cdk.Context) { // <= 0.35.0
53
+ cdk.Context.getAvailabilityZones(this);
54
+ } else {
55
+ this.availabilityZones;
56
+ }
57
+
58
+ const parameterName = '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2';
59
+ getSsmParameterValue(this, parameterName);
60
+ }
61
+ }
62
+
63
+ function getSsmParameterValue(scope, parameterName) {
64
+ return ssm.StringParameter.valueFromLookup(scope, parameterName);
65
+ }
66
+
67
+ class YourStack extends cdk.Stack {
68
+ constructor(parent, id, props) {
69
+ super(parent, id, props);
70
+ new sns.Topic(this, 'topic1');
71
+ new sns.Topic(this, 'topic2');
72
+ }
73
+ }
74
+
75
+ class NoticesStack extends cdk.Stack {
76
+ constructor(parent, id, props) {
77
+ super(parent, id, props);
78
+ new sqs.Queue(this, 'queue');
79
+ }
80
+ }
81
+
82
+ class SsoPermissionSetNoPolicy extends Stack {
83
+ constructor(scope, id) {
84
+ super(scope, id);
85
+
86
+ new sso.CfnPermissionSet(this, "permission-set-without-managed-policy", {
87
+ instanceArn: 'arn:aws:sso:::instance/testvalue',
88
+ name: 'testName',
89
+ permissionsBoundary: { customerManagedPolicyReference: { name: 'why', path: '/how/' }},
90
+ })
91
+ }
92
+ }
93
+
94
+ class SsoPermissionSetManagedPolicy extends Stack {
95
+ constructor(scope, id) {
96
+ super(scope, id);
97
+ new sso.CfnPermissionSet(this, "permission-set-with-managed-policy", {
98
+ managedPolicies: ['arn:aws:iam::aws:policy/administratoraccess'],
99
+ customerManagedPolicyReferences: [{ name: 'forSSO' }],
100
+ permissionsBoundary: { managedPolicyArn: 'arn:aws:iam::aws:policy/AdministratorAccess' },
101
+ instanceArn: 'arn:aws:sso:::instance/testvalue',
102
+ name: 'niceWork',
103
+ })
104
+ }
105
+ }
106
+
107
+ class SsoAssignment extends Stack {
108
+ constructor(scope, id) {
109
+ super(scope, id);
110
+ new sso.CfnAssignment(this, "assignment", {
111
+ instanceArn: 'arn:aws:sso:::instance/testvalue',
112
+ permissionSetArn: 'arn:aws:sso:::testvalue',
113
+ principalId: '11111111-2222-3333-4444-test',
114
+ principalType: 'USER',
115
+ targetId: '111111111111',
116
+ targetType: 'AWS_ACCOUNT'
117
+ });
118
+ }
119
+ }
120
+
121
+ class SsoInstanceAccessControlConfig extends Stack {
122
+ constructor(scope, id) {
123
+ super(scope, id);
124
+ new sso.CfnInstanceAccessControlAttributeConfiguration(this, 'instanceAccessControlConfig', {
125
+ instanceArn: 'arn:aws:sso:::instance/testvalue',
126
+ accessControlAttributes: [
127
+ { key: 'first', value: { source: ['a'] } },
128
+ { key: 'second', value: { source: ['b'] } },
129
+ { key: 'third', value: { source: ['c'] } },
130
+ { key: 'fourth', value: { source: ['d'] } },
131
+ { key: 'fifth', value: { source: ['e'] } },
132
+ { key: 'sixth', value: { source: ['f'] } },
133
+ ]
134
+ })
135
+ }
136
+ }
137
+
138
+ class ListMultipleDependentStack extends Stack {
139
+ constructor(scope, id) {
140
+ super(scope, id);
141
+
142
+ const dependentStack1 = new DependentStack1(this, 'DependentStack1');
143
+ const dependentStack2 = new DependentStack2(this, 'DependentStack2');
144
+
145
+ this.addDependency(dependentStack1);
146
+ this.addDependency(dependentStack2);
147
+ }
148
+ }
149
+
150
+ class DependentStack1 extends Stack {
151
+ constructor(scope, id) {
152
+ super(scope, id);
153
+
154
+ }
155
+ }
156
+
157
+ class DependentStack2 extends Stack {
158
+ constructor(scope, id) {
159
+ super(scope, id);
160
+
161
+ }
162
+ }
163
+
164
+ class ListStack extends Stack {
165
+ constructor(scope, id) {
166
+ super(scope, id);
167
+
168
+ const dependentStack = new DependentStack(this, 'DependentStack');
169
+
170
+ this.addDependency(dependentStack);
171
+ }
172
+ }
173
+
174
+ class DependentStack extends Stack {
175
+ constructor(scope, id) {
176
+ super(scope, id);
177
+
178
+ const innerDependentStack = new InnerDependentStack(this, 'InnerDependentStack');
179
+
180
+ this.addDependency(innerDependentStack);
181
+ }
182
+ }
183
+
184
+ class InnerDependentStack extends Stack {
185
+ constructor(scope, id) {
186
+ super(scope, id);
187
+
188
+ }
189
+ }
190
+
191
+ class MigrateStack extends cdk.Stack {
192
+ constructor(parent, id, props) {
193
+ super(parent, id, props);
194
+
195
+ if (!process.env.OMIT_TOPIC) {
196
+ const queue = new sqs.Queue(this, 'Queue', {
197
+ removalPolicy: process.env.ORPHAN_TOPIC ? cdk.RemovalPolicy.RETAIN : cdk.RemovalPolicy.DESTROY,
198
+ });
199
+
200
+ new cdk.CfnOutput(this, 'QueueName', {
201
+ value: queue.queueName,
202
+ });
203
+
204
+ new cdk.CfnOutput(this, 'QueueUrl', {
205
+ value: queue.queueUrl,
206
+ });
207
+
208
+ new cdk.CfnOutput(this, 'QueueLogicalId', {
209
+ value: queue.node.defaultChild.logicalId,
210
+ });
211
+ }
212
+ if (process.env.SAMPLE_RESOURCES) {
213
+ const myTopic = new sns.Topic(this, 'migratetopic1', {
214
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
215
+ });
216
+ cdk.Tags.of(myTopic).add('tag1', 'value1');
217
+ const myTopic2 = new sns.Topic(this, 'migratetopic2', {
218
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
219
+ });
220
+ cdk.Tags.of(myTopic2).add('tag2', 'value2');
221
+ const myQueue = new sqs.Queue(this, 'migratequeue1', {
222
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
223
+ });
224
+ cdk.Tags.of(myQueue).add('tag3', 'value3');
225
+ }
226
+ if (process.env.LAMBDA_RESOURCES) {
227
+ const myFunction = new lambda.Function(this, 'migratefunction1', {
228
+ code: lambda.Code.fromInline('console.log("hello world")'),
229
+ handler: 'index.handler',
230
+ runtime: lambda.Runtime.NODEJS_18_X,
231
+ });
232
+ cdk.Tags.of(myFunction).add('lambda-tag', 'lambda-value');
233
+
234
+ const myFunction2 = new lambda.Function(this, 'migratefunction2', {
235
+ code: lambda.Code.fromInline('console.log("hello world2")'),
236
+ handler: 'index.handler',
237
+ runtime: lambda.Runtime.NODEJS_18_X,
238
+ });
239
+ cdk.Tags.of(myFunction2).add('lambda-tag', 'lambda-value');
240
+ }
241
+ }
242
+ }
243
+
244
+ class ImportableStack extends cdk.Stack {
245
+ constructor(parent, id, props) {
246
+ super(parent, id, props);
247
+ new cdk.CfnWaitConditionHandle(this, 'Handle');
248
+
249
+ if (process.env.INCLUDE_SINGLE_QUEUE === '1') {
250
+ const queue = new sqs.Queue(this, 'Queue', {
251
+ removalPolicy: (process.env.RETAIN_SINGLE_QUEUE === '1') ? cdk.RemovalPolicy.RETAIN : cdk.RemovalPolicy.DESTROY,
252
+ });
253
+
254
+ new cdk.CfnOutput(this, 'QueueName', {
255
+ value: queue.queueName,
256
+ });
257
+
258
+ new cdk.CfnOutput(this, 'QueueUrl', {
259
+ value: queue.queueUrl,
260
+ });
261
+
262
+ new cdk.CfnOutput(this, 'QueueLogicalId', {
263
+ value: queue.node.defaultChild.logicalId,
264
+ });
265
+ }
266
+
267
+ if (process.env.LARGE_TEMPLATE === '1') {
268
+ for (let i = 1; i <= 70; i++) {
269
+ new sqs.Queue(this, `cdk-import-queue-test${i}`, {
270
+ enforceSSL: true,
271
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
272
+ });
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ class StackUsingContext extends cdk.Stack {
279
+ constructor(parent, id, props) {
280
+ super(parent, id, props);
281
+ new cdk.CfnResource(this, 'Handle', {
282
+ type: 'AWS::CloudFormation::WaitConditionHandle'
283
+ });
284
+
285
+ new cdk.CfnOutput(this, 'Output', {
286
+ value: this.availabilityZones[0],
287
+ });
288
+ }
289
+ }
290
+
291
+ class ParameterStack extends cdk.Stack {
292
+ constructor(parent, id, props) {
293
+ super(parent, id, props);
294
+
295
+ new sns.Topic(this, 'TopicParameter', {
296
+ topicName: new cdk.CfnParameter(this, 'TopicNameParam').valueAsString
297
+ });
298
+ }
299
+ }
300
+
301
+ class OtherParameterStack extends cdk.Stack {
302
+ constructor(parent, id, props) {
303
+ super(parent, id, props);
304
+
305
+ new sns.Topic(this, 'TopicParameter', {
306
+ topicName: new cdk.CfnParameter(this, 'OtherTopicNameParam').valueAsString
307
+ });
308
+ }
309
+ }
310
+
311
+ class MultiParameterStack extends cdk.Stack {
312
+ constructor(parent, id, props) {
313
+ super(parent, id, props);
314
+
315
+ new sns.Topic(this, 'TopicParameter', {
316
+ displayName: new cdk.CfnParameter(this, 'DisplayNameParam').valueAsString
317
+ });
318
+ new sns.Topic(this, 'OtherTopicParameter', {
319
+ displayName: new cdk.CfnParameter(this, 'OtherDisplayNameParam').valueAsString
320
+ });
321
+ }
322
+ }
323
+
324
+ class OutputsStack extends cdk.Stack {
325
+ constructor(parent, id, props) {
326
+ super(parent, id, props);
327
+
328
+ const topic = new sns.Topic(this, 'MyOutput', {
329
+ topicName: `${cdk.Stack.of(this).stackName}MyTopic`
330
+ });
331
+
332
+ new cdk.CfnOutput(this, 'TopicName', {
333
+ value: topic.topicName
334
+ })
335
+ }
336
+ }
337
+
338
+ class AnotherOutputsStack extends cdk.Stack {
339
+ constructor(parent, id, props) {
340
+ super(parent, id, props);
341
+
342
+ const topic = new sns.Topic(this, 'MyOtherOutput', {
343
+ topicName: `${cdk.Stack.of(this).stackName}MyOtherTopic`
344
+ });
345
+
346
+ new cdk.CfnOutput(this, 'TopicName', {
347
+ value: topic.topicName
348
+ });
349
+ }
350
+ }
351
+
352
+ class IamStack extends cdk.Stack {
353
+ constructor(parent, id, props) {
354
+ super(parent, id, props);
355
+
356
+ new iam.Role(this, 'SomeRole', {
357
+ assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
358
+ });
359
+ }
360
+ }
361
+
362
+ class ProvidingStack extends cdk.Stack {
363
+ constructor(parent, id, props) {
364
+ super(parent, id, props);
365
+
366
+ this.topic = new sns.Topic(this, 'BogusTopic'); // Some filler
367
+ }
368
+ }
369
+
370
+ class StackWithError extends cdk.Stack {
371
+ constructor(parent, id, props) {
372
+ super(parent, id, props);
373
+
374
+ this.topic = new sns.Topic(this, 'BogusTopic'); // Some filler
375
+ Annotations.of(this).addError('This is an error');
376
+ }
377
+ }
378
+
379
+ class StageWithError extends cdk.Stage {
380
+ constructor(parent, id, props) {
381
+ super(parent, id, props);
382
+
383
+ new StackWithError(this, 'Stack');
384
+ }
385
+ }
386
+
387
+ class ConsumingStack extends cdk.Stack {
388
+ constructor(parent, id, props) {
389
+ super(parent, id, props);
390
+
391
+ new sns.Topic(this, 'BogusTopic'); // Some filler
392
+ new cdk.CfnOutput(this, 'IConsumedSomething', { value: props.providingStack.topic.topicArn });
393
+ }
394
+ }
395
+
396
+ class MissingSSMParameterStack extends cdk.Stack {
397
+ constructor(parent, id, props) {
398
+ super(parent, id, props);
399
+
400
+ const parameterName = constructs.Node.of(this).tryGetContext('test:ssm-parameter-name');
401
+ if (parameterName) {
402
+ const param = getSsmParameterValue(this, parameterName);
403
+ new iam.Role(this, 'PhonyRole', { assumedBy: new iam.AccountPrincipal(param) });
404
+ }
405
+ }
406
+ }
407
+
408
+ class LambdaStack extends cdk.Stack {
409
+ constructor(parent, id, props) {
410
+ // sometimes we need to specify the custom bootstrap bucket to use
411
+ // see the 'upgrade legacy bootstrap stack' test
412
+ const synthesizer = parent.node.tryGetContext('legacySynth') === 'true' ?
413
+ new LegacyStackSynthesizer({
414
+ fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
415
+ })
416
+ : new DefaultStackSynthesizer({
417
+ fileAssetsBucketName: parent.node.tryGetContext('bootstrapBucket'),
418
+ })
419
+ super(parent, id, {
420
+ ...props,
421
+ synthesizer: synthesizer,
422
+ });
423
+
424
+ const fn = new lambda.Function(this, 'my-function', {
425
+ code: lambda.Code.asset(path.join(__dirname, 'lambda')),
426
+ runtime: lambda.Runtime.NODEJS_LATEST,
427
+ handler: 'index.handler'
428
+ });
429
+
430
+ new cdk.CfnOutput(this, 'FunctionArn', { value: fn.functionArn });
431
+ }
432
+ }
433
+
434
+ class IamRolesStack extends cdk.Stack {
435
+ constructor(parent, id, props) {
436
+ super(parent, id, props);
437
+
438
+ // Environment variabile is used to create a bunch of roles to test
439
+ // that large diff templates are uploaded to S3 to create the changeset.
440
+ for(let i = 1; i <= Number(process.env.NUMBER_OF_ROLES) ; i++) {
441
+ const role = new iam.Role(this, `Role${i}`, {
442
+ assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
443
+ });
444
+ const cfnRole = role.node.defaultChild;
445
+
446
+ // For any extra IAM roles created, add a ton of metadata so that the template size is > 50 KiB.
447
+ if (i > 1) {
448
+ for(let i = 1; i <= 30 ; i++) {
449
+ cfnRole.addMetadata('a'.repeat(1000), 'v');
450
+ }
451
+ }
452
+ }
453
+ }
454
+ }
455
+
456
+ class SessionTagsStack extends cdk.Stack {
457
+ constructor(parent, id, props) {
458
+ super(parent, id, {
459
+ ...props,
460
+ synthesizer: new DefaultStackSynthesizer({
461
+ deployRoleAdditionalOptions: {
462
+ Tags: [{ Key: 'Department', Value: 'Engineering' }]
463
+ },
464
+ fileAssetPublishingRoleAdditionalOptions: {
465
+ Tags: [{ Key: 'Department', Value: 'Engineering' }]
466
+ },
467
+ imageAssetPublishingRoleAdditionalOptions: {
468
+ Tags: [{ Key: 'Department', Value: 'Engineering' }]
469
+ },
470
+ lookupRoleAdditionalOptions: {
471
+ Tags: [{ Key: 'Department', Value: 'Engineering' }]
472
+ }
473
+ })
474
+ });
475
+
476
+ // VPC lookup to test LookupRole
477
+ ec2.Vpc.fromLookup(this, 'DefaultVPC', { isDefault: true });
478
+
479
+ // Lambda Function to test AssetPublishingRole
480
+ const fn = new lambda.Function(this, 'my-function', {
481
+ code: lambda.Code.asset(path.join(__dirname, 'lambda')),
482
+ runtime: lambda.Runtime.NODEJS_LATEST,
483
+ handler: 'index.handler'
484
+ });
485
+
486
+ // DockerImageAsset to test ImageAssetPublishingRole
487
+ new docker.DockerImageAsset(this, 'image', {
488
+ directory: path.join(__dirname, 'docker')
489
+ });
490
+ }
491
+ }
492
+
493
+ class NoExecutionRoleCustomSynthesizer extends cdk.DefaultStackSynthesizer {
494
+
495
+ emitArtifact(session, options) {
496
+ super.emitArtifact(session, {
497
+ ...options,
498
+ cloudFormationExecutionRoleArn: undefined,
499
+ })
500
+ }
501
+ }
502
+
503
+ class SessionTagsWithNoExecutionRoleCustomSynthesizerStack extends cdk.Stack {
504
+ constructor(parent, id, props) {
505
+ super(parent, id, {
506
+ ...props,
507
+ synthesizer: new NoExecutionRoleCustomSynthesizer({
508
+ deployRoleAdditionalOptions: {
509
+ Tags: [{ Key: 'Department', Value: 'Engineering' }]
510
+ },
511
+ })
512
+ });
513
+
514
+ new sqs.Queue(this, 'sessionTagsQueue');
515
+ }
516
+ }
517
+ class LambdaHotswapStack extends cdk.Stack {
518
+ constructor(parent, id, props) {
519
+ super(parent, id, props);
520
+
521
+ const fn = new lambda.Function(this, 'my-function', {
522
+ code: lambda.Code.asset(path.join(__dirname, 'lambda')),
523
+ runtime: lambda.Runtime.NODEJS_LATEST,
524
+ handler: 'index.handler',
525
+ description: process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "description",
526
+ environment: {
527
+ SomeVariable:
528
+ process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "environment",
529
+ ImportValueVariable: process.env.USE_IMPORT_VALUE_LAMBDA_PROPERTY
530
+ ? cdk.Fn.importValue(TEST_EXPORT_OUTPUT_NAME)
531
+ : "no-import",
532
+ },
533
+ });
534
+
535
+ new cdk.CfnOutput(this, 'FunctionName', { value: fn.functionName });
536
+ }
537
+ }
538
+
539
+ class EcsHotswapStack extends cdk.Stack {
540
+ constructor(parent, id, props) {
541
+ super(parent, id, props);
542
+
543
+ // define a simple vpc and cluster
544
+ const vpc = new ec2.Vpc(this, 'vpc', {
545
+ natGateways: 0,
546
+ subnetConfiguration: [
547
+ {
548
+ cidrMask: 24,
549
+ name: 'Public',
550
+ subnetType: ec2.SubnetType.PUBLIC,
551
+ },
552
+ ],
553
+ maxAzs: 1,
554
+ });
555
+ const cluster = new ecs.Cluster(this, 'cluster', {
556
+ vpc,
557
+ });
558
+
559
+ // allow stack to be used to test failed deployments
560
+ const image =
561
+ process.env.USE_INVALID_ECS_HOTSWAP_IMAGE == 'true'
562
+ ? 'nginx:invalidtag'
563
+ : 'nginx:alpine';
564
+
565
+ // deploy basic service
566
+ const taskDefinition = new ecs.FargateTaskDefinition(
567
+ this,
568
+ 'task-definition'
569
+ );
570
+ taskDefinition.addContainer('nginx', {
571
+ image: ecs.ContainerImage.fromRegistry(image),
572
+ environment: {
573
+ SOME_VARIABLE: process.env.DYNAMIC_ECS_PROPERTY_VALUE ?? 'environment',
574
+ },
575
+ healthCheck: {
576
+ command: ['CMD-SHELL', 'exit 0'], // fake health check to speed up deployment
577
+ interval: cdk.Duration.seconds(5),
578
+ },
579
+ });
580
+ const service = new ecs.FargateService(this, 'service', {
581
+ cluster,
582
+ taskDefinition,
583
+ assignPublicIp: true, // required without NAT to pull image
584
+ circuitBreaker: { rollback: false },
585
+ desiredCount: 1,
586
+ });
587
+
588
+ new cdk.CfnOutput(this, 'ClusterName', { value: cluster.clusterName });
589
+ new cdk.CfnOutput(this, 'ServiceName', { value: service.serviceName });
590
+ }
591
+ }
592
+
593
+ class DockerStack extends cdk.Stack {
594
+ constructor(parent, id, props) {
595
+ super(parent, id, props);
596
+
597
+ new docker.DockerImageAsset(this, 'image', {
598
+ directory: path.join(__dirname, 'docker')
599
+ });
600
+
601
+ // Add at least a single resource (WaitConditionHandle), otherwise this stack will never
602
+ // be deployed (and its assets never built)
603
+ new cdk.CfnResource(this, 'Handle', {
604
+ type: 'AWS::CloudFormation::WaitConditionHandle'
605
+ });
606
+ }
607
+ }
608
+
609
+ class DockerInUseStack extends cdk.Stack {
610
+ constructor(parent, id, props) {
611
+ super(parent, id, props);
612
+
613
+ // Use the docker file in a lambda otherwise it will not be referenced in the template
614
+ const fn = new lambda.Function(this, 'my-function', {
615
+ code: lambda.Code.fromAssetImage(path.join(__dirname, 'docker')),
616
+ runtime: lambda.Runtime.FROM_IMAGE,
617
+ handler: lambda.Handler.FROM_IMAGE,
618
+ });
619
+ }
620
+ }
621
+
622
+ class DockerStackWithCustomFile extends cdk.Stack {
623
+ constructor(parent, id, props) {
624
+ super(parent, id, props);
625
+
626
+ new docker.DockerImageAsset(this, 'image', {
627
+ directory: path.join(__dirname, 'docker'),
628
+ file: 'Dockerfile.Custom'
629
+ });
630
+
631
+ // Add at least a single resource (WaitConditionHandle), otherwise this stack will never
632
+ // be deployed (and its assets never built)
633
+ new cdk.CfnResource(this, 'Handle', {
634
+ type: 'AWS::CloudFormation::WaitConditionHandle'
635
+ });
636
+ }
637
+ }
638
+
639
+ /**
640
+ * A stack that will never succeed deploying (done in a way that CDK cannot detect but CFN will complain about)
641
+ */
642
+ class FailedStack extends cdk.Stack {
643
+
644
+ constructor(parent, id, props) {
645
+ super(parent, id, props);
646
+
647
+ // fails on 'Property PolicyDocument cannot be empty'.
648
+ new cdk.CfnResource(this, 'EmptyPolicy', {
649
+ type: 'AWS::IAM::Policy'
650
+ })
651
+
652
+ }
653
+
654
+ }
655
+
656
+ const VPC_TAG_NAME = 'custom-tag';
657
+ const VPC_TAG_VALUE = `${stackPrefix}-bazinga!`;
658
+
659
+ class DefineVpcStack extends cdk.Stack {
660
+ constructor(parent, id, props) {
661
+ super(parent, id, props);
662
+
663
+ const vpc = new ec2.Vpc(this, 'VPC', {
664
+ maxAzs: 1,
665
+ })
666
+ cdk.Aspects.of(vpc).add(new cdk.Tag(VPC_TAG_NAME, VPC_TAG_VALUE));
667
+ }
668
+ }
669
+
670
+ class ImportVpcStack extends cdk.Stack {
671
+ constructor(parent, id, props) {
672
+ super(parent, id, props);
673
+
674
+ ec2.Vpc.fromLookup(this, 'DefaultVPC', { isDefault: true });
675
+ ec2.Vpc.fromLookup(this, 'ByTag', { tags: { [VPC_TAG_NAME]: VPC_TAG_VALUE } });
676
+ }
677
+ }
678
+
679
+ class ConditionalResourceStack extends cdk.Stack {
680
+ constructor(parent, id, props) {
681
+ super(parent, id, props);
682
+
683
+ if (!process.env.NO_RESOURCE) {
684
+ new iam.User(this, 'User');
685
+ }
686
+ }
687
+ }
688
+
689
+ const TEST_EXPORT_OUTPUT_NAME = 'test-export-output';
690
+
691
+ class ExportValueStack extends cdk.Stack {
692
+ constructor(parent, id, props) {
693
+ super(parent, id, props);
694
+
695
+ // just need any resource to exist within the stack
696
+ const topic = new sns.Topic(this, 'Topic');
697
+
698
+ new cdk.CfnOutput(this, 'ExportValueOutput', {
699
+ exportName: TEST_EXPORT_OUTPUT_NAME,
700
+ value: topic.topicArn,
701
+ });
702
+ }
703
+ }
704
+
705
+ class BundlingStage extends cdk.Stage {
706
+ constructor(parent, id, props) {
707
+ super(parent, id, props);
708
+ const stack = new cdk.Stack(this, 'BundlingStack');
709
+
710
+ new lambda.Function(stack, 'Handler', {
711
+ code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
712
+ handler: 'index.handler',
713
+ runtime: lambda.Runtime.NODEJS_LATEST,
714
+ });
715
+ }
716
+ }
717
+
718
+ class SomeStage extends cdk.Stage {
719
+ constructor(parent, id, props) {
720
+ super(parent, id, props);
721
+
722
+ new YourStack(this, 'StackInStage');
723
+ }
724
+ }
725
+
726
+ class StageUsingContext extends cdk.Stage {
727
+ constructor(parent, id, props) {
728
+ super(parent, id, props);
729
+
730
+ new StackUsingContext(this, 'StackInStage');
731
+ }
732
+ }
733
+
734
+ class BuiltinLambdaStack extends cdk.Stack {
735
+ constructor(parent, id, props) {
736
+ super(parent, id, props);
737
+
738
+ new s3.Bucket(this, 'Bucket', {
739
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
740
+ autoDeleteObjects: true, // will deploy a Nodejs lambda backed custom resource
741
+ });
742
+ }
743
+ }
744
+
745
+ class NotificationArnsStack extends cdk.Stack {
746
+ constructor(parent, id, props) {
747
+
748
+ const arnsFromEnv = process.env.INTEG_NOTIFICATION_ARNS;
749
+ super(parent, id, {
750
+ ...props,
751
+ // comma separated list of arns.
752
+ // empty string means empty list.
753
+ // undefined means undefined
754
+ notificationArns: arnsFromEnv == '' ? [] : (arnsFromEnv ? arnsFromEnv.split(',') : undefined)
755
+ });
756
+
757
+ new cdk.CfnWaitConditionHandle(this, 'WaitConditionHandle');
758
+
759
+ }
760
+ }
761
+
762
+ class AppSyncHotswapStack extends cdk.Stack {
763
+ constructor(parent, id, props) {
764
+ super(parent, id, props);
765
+
766
+ const api = new appsync.GraphqlApi(this, "Api", {
767
+ name: "appsync-hotswap",
768
+ definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.hotswap.graphql')),
769
+ authorizationConfig: {
770
+ defaultAuthorization: {
771
+ authorizationType: appsync.AuthorizationType.IAM,
772
+ },
773
+ },
774
+ });
775
+
776
+ const noneDataSource = api.addNoneDataSource("none");
777
+ // create 50 appsync functions to hotswap
778
+ for (const i of Array(50).keys()) {
779
+ const appsyncFunction = new appsync.AppsyncFunction(this, `Function${i}`, {
780
+ name: `appsync_function${i}`,
781
+ api,
782
+ dataSource: noneDataSource,
783
+ requestMappingTemplate: appsync.MappingTemplate.fromString(process.env.DYNAMIC_APPSYNC_PROPERTY_VALUE ?? "$util.toJson({})"),
784
+ responseMappingTemplate: appsync.MappingTemplate.fromString('$util.toJson({})'),
785
+ });
786
+ }
787
+ }
788
+ }
789
+
790
+ class MetadataStack extends cdk.Stack {
791
+ constructor(parent, id, props) {
792
+ super(parent, id, props);
793
+ const handle = new cdk.CfnWaitConditionHandle(this, 'WaitConditionHandle');
794
+ handle.addMetadata('Key', process.env.INTEG_METADATA_VALUE ?? 'default')
795
+
796
+ }
797
+ }
798
+
799
+ const app = new cdk.App({
800
+ context: {
801
+ '@aws-cdk/core:assetHashSalt': process.env.CODEBUILD_BUILD_ID, // Force all assets to be unique, but consistent in one build
802
+ },
803
+ });
804
+
805
+ const defaultEnv = {
806
+ account: process.env.CDK_DEFAULT_ACCOUNT,
807
+ region: process.env.CDK_DEFAULT_REGION
808
+ };
809
+
810
+ // Sometimes we don't want to synthesize all stacks because it will impact the results
811
+ const stackSet = process.env.INTEG_STACK_SET || 'default';
812
+
813
+ switch (stackSet) {
814
+ case 'default':
815
+ // Deploy all does a wildcard ${stackPrefix}-test-*
816
+ new MyStack(app, `${stackPrefix}-test-1`, { env: defaultEnv });
817
+ new YourStack(app, `${stackPrefix}-test-2`);
818
+ new NoticesStack(app, `${stackPrefix}-notices`);
819
+ // Deploy wildcard with parameters does ${stackPrefix}-param-test-*
820
+ new ParameterStack(app, `${stackPrefix}-param-test-1`);
821
+ new OtherParameterStack(app, `${stackPrefix}-param-test-2`);
822
+ // Deploy stack with multiple parameters
823
+ new MultiParameterStack(app, `${stackPrefix}-param-test-3`);
824
+ // Deploy stack with outputs does ${stackPrefix}-outputs-test-*
825
+ new OutputsStack(app, `${stackPrefix}-outputs-test-1`);
826
+ new AnotherOutputsStack(app, `${stackPrefix}-outputs-test-2`);
827
+ // Not included in wildcard
828
+ new IamStack(app, `${stackPrefix}-iam-test`, { env: defaultEnv });
829
+ const providing = new ProvidingStack(app, `${stackPrefix}-order-providing`);
830
+ new ConsumingStack(app, `${stackPrefix}-order-consuming`, { providingStack: providing });
831
+
832
+ new MissingSSMParameterStack(app, `${stackPrefix}-missing-ssm-parameter`, { env: defaultEnv });
833
+
834
+ new LambdaStack(app, `${stackPrefix}-lambda`);
835
+
836
+ // This stack is used to test diff with large templates by creating a role with a ton of metadata
837
+ new IamRolesStack(app, `${stackPrefix}-iam-roles`);
838
+
839
+ if (process.env.ENABLE_VPC_TESTING == 'IMPORT') {
840
+ // this stack performs a VPC lookup so we gate synth
841
+ const env = { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION };
842
+ new SessionTagsStack(app, `${stackPrefix}-session-tags`, { env });
843
+ }
844
+
845
+ new SessionTagsWithNoExecutionRoleCustomSynthesizerStack(app, `${stackPrefix}-session-tags-with-custom-synthesizer`);
846
+ new LambdaHotswapStack(app, `${stackPrefix}-lambda-hotswap`);
847
+ new EcsHotswapStack(app, `${stackPrefix}-ecs-hotswap`);
848
+ new AppSyncHotswapStack(app, `${stackPrefix}-appsync-hotswap`);
849
+ new DockerStack(app, `${stackPrefix}-docker`);
850
+ new DockerInUseStack(app, `${stackPrefix}-docker-in-use`);
851
+ new DockerStackWithCustomFile(app, `${stackPrefix}-docker-with-custom-file`);
852
+
853
+ new NotificationArnsStack(app, `${stackPrefix}-notification-arns`);
854
+
855
+ // SSO stacks
856
+ new SsoInstanceAccessControlConfig(app, `${stackPrefix}-sso-access-control`);
857
+ new SsoAssignment(app, `${stackPrefix}-sso-assignment`);
858
+ new SsoPermissionSetManagedPolicy(app, `${stackPrefix}-sso-perm-set-with-managed-policy`);
859
+ new SsoPermissionSetNoPolicy(app, `${stackPrefix}-sso-perm-set-without-managed-policy`);
860
+
861
+ const failed = new FailedStack(app, `${stackPrefix}-failed`)
862
+
863
+ // A stack that depends on the failed stack -- used to test that '-e' does not deploy the failing stack
864
+ const dependsOnFailed = new OutputsStack(app, `${stackPrefix}-depends-on-failed`);
865
+ dependsOnFailed.addDependency(failed);
866
+
867
+ if (process.env.ENABLE_VPC_TESTING) { // Gating so we don't do context fetching unless that's what we are here for
868
+ const env = { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION };
869
+ if (process.env.ENABLE_VPC_TESTING === 'DEFINE')
870
+ new DefineVpcStack(app, `${stackPrefix}-define-vpc`, { env });
871
+ if (process.env.ENABLE_VPC_TESTING === 'IMPORT')
872
+ new ImportVpcStack(app, `${stackPrefix}-import-vpc`, { env });
873
+ }
874
+
875
+ new ConditionalResourceStack(app, `${stackPrefix}-conditional-resource`)
876
+
877
+ new StackWithNestedStack(app, `${stackPrefix}-with-nested-stack`);
878
+ new StackWithNestedStackUsingParameters(app, `${stackPrefix}-with-nested-stack-using-parameters`);
879
+ new StackWithDoublyNestedStack(app, `${stackPrefix}-with-doubly-nested-stack`);
880
+ new ListStack(app, `${stackPrefix}-list-stacks`)
881
+ new ListMultipleDependentStack(app, `${stackPrefix}-list-multiple-dependent-stacks`);
882
+
883
+ new YourStack(app, `${stackPrefix}-termination-protection`, {
884
+ terminationProtection: process.env.TERMINATION_PROTECTION !== 'FALSE' ? true : false,
885
+ });
886
+
887
+ new SomeStage(app, `${stackPrefix}-stage`);
888
+
889
+ new BuiltinLambdaStack(app, `${stackPrefix}-builtin-lambda-function`);
890
+
891
+ new ImportableStack(app, `${stackPrefix}-importable-stack`);
892
+
893
+ new MigrateStack(app, `${stackPrefix}-migrate-stack`);
894
+
895
+ new ExportValueStack(app, `${stackPrefix}-export-value-stack`);
896
+
897
+ new BundlingStage(app, `${stackPrefix}-bundling-stage`);
898
+
899
+ new MetadataStack(app, `${stackPrefix}-metadata`);
900
+ break;
901
+
902
+ case 'stage-using-context':
903
+ // Cannot be combined with other test stacks, because we use this to test
904
+ // that stage context is propagated up and causes synth to fail when combined
905
+ // with '--no-lookups'.
906
+
907
+ // Needs a dummy stack at the top level because the CLI will fail otherwise
908
+ new YourStack(app, `${stackPrefix}-toplevel`, { env: defaultEnv });
909
+ new StageUsingContext(app, `${stackPrefix}-stage-using-context`, {
910
+ env: defaultEnv,
911
+ });
912
+ break;
913
+
914
+ case 'stage-with-errors':
915
+ const stage = new StageWithError(app, `${stackPrefix}-stage-with-errors`);
916
+ stage.synth({ validateOnSynthesis: true });
917
+ break;
918
+
919
+ case 'stage-with-no-stacks':
920
+ break;
921
+
922
+ default:
923
+ throw new Error(`Unrecognized INTEG_STACK_SET: '${stackSet}'`);
924
+ }
925
+
926
+ app.synth();