@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,3 @@
1
+ type Query {
2
+ listString: [String]
3
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "app": "node app.js",
3
+ "versionReporting": false,
4
+ "context": {
5
+ "aws-cdk:enableDiffNoFail": "true"
6
+ }
7
+ }
@@ -0,0 +1,2 @@
1
+ FROM public.ecr.aws/docker/library/alpine:latest
2
+
@@ -0,0 +1,2 @@
1
+ FROM public.ecr.aws/docker/library/alpine:latest
2
+
@@ -0,0 +1,4 @@
1
+ exports.handler = async function(event) {
2
+ const response = require('./response.json');
3
+ return response;
4
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "response": "hello, dear asset!"
3
+ }
@@ -0,0 +1,65 @@
1
+ if (process.env.PACKAGE_LAYOUT_VERSION === '1') {
2
+ var cfn = require('@aws-cdk/aws-cloudformation');
3
+ var sns = require('@aws-cdk/aws-sns');
4
+ var { Stack, CfnParameter } = require('@aws-cdk/core');
5
+ } else {
6
+ var {
7
+ aws_cloudformation: cfn,
8
+ aws_sns: sns,
9
+ } = require('aws-cdk-lib');
10
+ var { Stack, CfnParameter } = require('aws-cdk-lib');
11
+ }
12
+
13
+ class StackWithNestedStack extends Stack {
14
+ constructor(scope, id) {
15
+ super(scope, id);
16
+ new MyNestedStack(this, 'MyNested');
17
+ }
18
+ }
19
+
20
+ class MyNestedStack extends cfn.NestedStack {
21
+ constructor(scope, id) {
22
+ super(scope, id);
23
+
24
+ new sns.Topic(this, 'MyTopic');
25
+ }
26
+ }
27
+
28
+ class DoublyNestedStack extends cfn.NestedStack {
29
+ constructor(scope, id) {
30
+ super(scope, id);
31
+
32
+ new MyNestedStack(this, 'Nestor');
33
+ }
34
+ }
35
+
36
+ class StackWithDoublyNestedStack extends Stack {
37
+ constructor(scope, id) {
38
+ super(scope, id);
39
+ new DoublyNestedStack(this, 'DoubleDouble');
40
+ }
41
+ }
42
+
43
+ class StackWithNestedStackUsingParameters extends Stack {
44
+ constructor(scope, id) {
45
+ super(scope, id);
46
+ const topicNameParam = new CfnParameter(this, 'MyTopicParam');
47
+ new MyNestedStackUsingParameters(this, 'MyNested', {
48
+ parameters: {'MyTopicParam': topicNameParam.valueAsString}
49
+ });
50
+ }
51
+ }
52
+
53
+ class MyNestedStackUsingParameters extends cfn.NestedStack {
54
+ constructor(scope, id, props) {
55
+ super(scope, id, props);
56
+
57
+ new sns.Topic(this, 'MyTopic', {
58
+ topicName: new CfnParameter(this, 'MyTopicParam')
59
+ });
60
+ }
61
+ }
62
+
63
+ exports.StackWithNestedStack = StackWithNestedStack;
64
+ exports.StackWithNestedStackUsingParameters = StackWithNestedStackUsingParameters;
65
+ exports.StackWithDoublyNestedStack = StackWithDoublyNestedStack;
@@ -0,0 +1,4 @@
1
+ {
2
+ "app": "node cfn-include-app.js",
3
+ "versionReporting": false
4
+ }
@@ -0,0 +1,21 @@
1
+ const path = require('path');
2
+
3
+ const uberPackage = process.env.UBERPACKAGE;
4
+ if (!uberPackage) {
5
+ throw new Error('The UBERPACKAGE environment variable is required for running this app!');
6
+ }
7
+
8
+ const cfn_inc = require(`${uberPackage}/cloudformation-include`);
9
+ const core = require(`${uberPackage}`);
10
+
11
+ const app = new core.App();
12
+ const stack = new core.Stack(app, 'Stack');
13
+ const cfnInclude = new cfn_inc.CfnInclude(stack, 'Template', {
14
+ templateFile: path.join(__dirname, 'example-template.json'),
15
+ });
16
+ const cfnBucket = cfnInclude.getResource('Bucket');
17
+ if (cfnBucket.bucketName !== 'my-example-bucket') {
18
+ throw new Error(`Expected bucketName to be 'my-example-bucket', got: '${cfnBucket.bucketName}'`);
19
+ }
20
+
21
+ app.synth();
@@ -0,0 +1,13 @@
1
+ {
2
+ "Resources": {
3
+ "NoopHandle": {
4
+ "Type": "AWS::CloudFormation::WaitConditionHandle"
5
+ },
6
+ "Bucket": {
7
+ "Type": "AWS::S3::Bucket",
8
+ "Properties": {
9
+ "BucketName": "my-example-bucket"
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,110 @@
1
+ const cdk = require('aws-cdk-lib');
2
+ const lambda = require('aws-cdk-lib/aws-lambda');
3
+ const sqs = require('aws-cdk-lib/aws-sqs');
4
+ const cr = require('aws-cdk-lib/custom-resources');
5
+
6
+ /**
7
+ * This stack will be deployed in multiple phases, to achieve a very specific effect
8
+ *
9
+ * It contains resources r1 and r2, and a queue q, where r1 gets deployed first.
10
+ *
11
+ * - PHASE = 1: both resources deploy regularly.
12
+ * - PHASE = 2a: r1 gets updated, r2 will fail to update
13
+ * - PHASE = 2b: r1 gets updated, r2 will fail to update, and r1 will fail its rollback.
14
+ * - PHASE = 3: q gets replaced w.r.t. phases 1 and 2
15
+ *
16
+ * To exercise this app:
17
+ *
18
+ * ```
19
+ * env PHASE=1 npx cdk deploy
20
+ * env PHASE=2b npx cdk deploy --no-rollback
21
+ * # This will leave the stack in UPDATE_FAILED
22
+ *
23
+ * env PHASE=2b npx cdk rollback
24
+ * # This will start a rollback that will fail because r1 fails its rollabck
25
+ *
26
+ * env PHASE=2b npx cdk rollback --force
27
+ * # This will retry the rollback and skip r1
28
+ * ```
29
+ */
30
+ class RollbacktestStack extends cdk.Stack {
31
+ constructor(scope, id, props) {
32
+ super(scope, id, props);
33
+
34
+ let r1props = {};
35
+ let r2props = {};
36
+ let fifo = false;
37
+
38
+ const phase = process.env.PHASE;
39
+ switch (phase) {
40
+ case '1':
41
+ // Normal deployment
42
+ break;
43
+ case '2a':
44
+ // r1 updates normally, r2 fails updating
45
+ r2props.FailUpdate = true;
46
+ break;
47
+ case '2b':
48
+ // r1 updates normally, r2 fails updating, r1 fails rollback
49
+ r1props.FailRollback = true;
50
+ r2props.FailUpdate = true;
51
+ break;
52
+ case '3':
53
+ fifo = true;
54
+ break;
55
+ }
56
+
57
+ const fn = new lambda.Function(this, 'Fun', {
58
+ runtime: lambda.Runtime.NODEJS_LATEST,
59
+ code: lambda.Code.fromInline(`exports.handler = async function(event, ctx) {
60
+ const key = \`Fail\${event.RequestType}\`;
61
+ if (event.ResourceProperties[key]) {
62
+ throw new Error(\`\${event.RequestType} fails!\`);
63
+ }
64
+ if (event.OldResourceProperties?.FailRollback) {
65
+ throw new Error('Failing rollback!');
66
+ }
67
+ return {};
68
+ }`),
69
+ handler: 'index.handler',
70
+ timeout: cdk.Duration.minutes(1),
71
+ });
72
+ const provider = new cr.Provider(this, "MyProvider", {
73
+ onEventHandler: fn,
74
+ });
75
+
76
+ const r1 = new cdk.CustomResource(this, 'r1', {
77
+ serviceToken: provider.serviceToken,
78
+ properties: r1props,
79
+ });
80
+ const r2 = new cdk.CustomResource(this, 'r2', {
81
+ serviceToken: provider.serviceToken,
82
+ properties: r2props,
83
+ });
84
+ r2.node.addDependency(r1);
85
+
86
+ new sqs.Queue(this, 'Queue', {
87
+ fifo,
88
+ });
89
+ }
90
+ }
91
+
92
+ const app = new cdk.App({
93
+ context: {
94
+ '@aws-cdk/core:assetHashSalt': process.env.CODEBUILD_BUILD_ID, // Force all assets to be unique, but consistent in one build
95
+ },
96
+ });
97
+
98
+ const defaultEnv = {
99
+ account: process.env.CDK_DEFAULT_ACCOUNT,
100
+ region: process.env.CDK_DEFAULT_REGION
101
+ };
102
+
103
+ const stackPrefix = process.env.STACK_NAME_PREFIX;
104
+ if (!stackPrefix) {
105
+ throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
106
+ }
107
+
108
+ // Sometimes we don't want to synthesize all stacks because it will impact the results
109
+ new RollbacktestStack(app, `${stackPrefix}-test-rollback`, { env: defaultEnv });
110
+ app.synth();
@@ -0,0 +1,7 @@
1
+ {
2
+ "app": "node app.js",
3
+ "versionReporting": false,
4
+ "context": {
5
+ "aws-cdk:enableDiffNoFail": "true"
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ if (process.env.PACKAGE_LAYOUT_VERSION === '1') {
3
+ var { App } = require('@aws-cdk/core');
4
+ } else {
5
+ var { App } = require('aws-cdk-lib');
6
+ }
7
+ var test_stack_1 = require('../lib/test-stack');
8
+ var app = new App();
9
+ const stackPrefix = process.env.STACK_NAME_PREFIX;
10
+ new test_stack_1.CDKSupportDemoRootStack(app, `${stackPrefix}-TestStack`);
11
+ app.synth();
@@ -0,0 +1,6 @@
1
+ {
2
+ "app": "node bin/test-app.js",
3
+ "context": {
4
+
5
+ }
6
+ }
@@ -0,0 +1,19 @@
1
+ if (process.env.PACKAGE_LAYOUT_VERSION === '1') {
2
+ var { NestedStack } = require('@aws-cdk/core');
3
+ var { Function, Runtime, Code } = require('@aws-cdk/aws-lambda');
4
+ } else {
5
+ var { NestedStack } = require('aws-cdk-lib');
6
+ var { Function, Runtime, Code } = require('aws-cdk-lib/aws-lambda');
7
+ }
8
+
9
+ class NestedStack1 extends NestedStack {
10
+ constructor(scope, id, props) {
11
+ super(scope, id, props);
12
+ new Function(this, 'FunctionPythonRuntime', {
13
+ runtime: Runtime.PYTHON_3_12,
14
+ code: Code.fromAsset('./src/python/Function'),
15
+ handler: 'app.lambda_handler',
16
+ });
17
+ }
18
+ }
19
+ exports.NestedStack1 = NestedStack1;
@@ -0,0 +1,134 @@
1
+ var path = require('path');
2
+ var { NestedStack1 } = require('./nested-stack');
3
+ if (process.env.PACKAGE_LAYOUT_VERSION === '1') {
4
+ var { Stack } = require('@aws-cdk/core');
5
+ var { Runtime, LayerVersion, Code, Function, DockerImageFunction, DockerImageCode } = require('@aws-cdk/aws-lambda');
6
+ var { SpecRestApi, ApiDefinition } = require('@aws-cdk/aws-apigateway');
7
+ var { NodejsFunction } = require('@aws-cdk/aws-lambda-nodejs');
8
+ var { GoFunction } = require('@aws-cdk/aws-lambda-go');
9
+ var { PythonFunction, PythonLayerVersion } = require('@aws-cdk/aws-lambda-python');
10
+ var { Role, ServicePrincipal, PolicyStatement } = require('@aws-cdk/aws-iam');
11
+ var { RetentionDays } = require('@aws-cdk/aws-logs');
12
+ } else {
13
+ var { Stack } = require('aws-cdk-lib');
14
+ var { Runtime, LayerVersion, Code, Function, DockerImageFunction, DockerImageCode } = require('aws-cdk-lib/aws-lambda');
15
+ var { SpecRestApi, ApiDefinition } = require('aws-cdk-lib/aws-apigateway');
16
+ var { NodejsFunction } = require('aws-cdk-lib/aws-lambda-nodejs');
17
+ var { GoFunction } = require('@aws-cdk/aws-lambda-go-alpha');
18
+ var { PythonFunction, PythonLayerVersion } = require('@aws-cdk/aws-lambda-python-alpha');
19
+ var { Role, ServicePrincipal, PolicyStatement } = require('aws-cdk-lib/aws-iam');
20
+ var { RetentionDays } = require('aws-cdk-lib/aws-logs');
21
+ }
22
+
23
+ const isRunningOnCodeBuild = !!process.env.CODEBUILD_BUILD_ID;
24
+
25
+ class CDKSupportDemoRootStack extends Stack{
26
+ constructor(scope, id, props) {
27
+ super(scope, id, props);
28
+ // Python Runtime
29
+ // Layers
30
+ new PythonLayerVersion(this, 'PythonLayerVersion', {
31
+ compatibleRuntimes: [
32
+ Runtime.PYTHON_3_12,
33
+ ],
34
+ entry: './src/python/Layer',
35
+ });
36
+ new LayerVersion(this, 'LayerVersion', {
37
+ compatibleRuntimes: [
38
+ Runtime.PYTHON_3_12,
39
+ ],
40
+ code: Code.fromAsset('./src/python/Layer'),
41
+ });
42
+ new LayerVersion(this, 'BundledLayerVersionPythonRuntime', {
43
+ compatibleRuntimes: [
44
+ Runtime.PYTHON_3_12,
45
+ ],
46
+ code: Code.fromAsset('./src/python/Layer', {
47
+ bundling: {
48
+ command: [
49
+ '/bin/sh',
50
+ '-c',
51
+ 'rm -rf /tmp/asset-input && mkdir /tmp/asset-input && cp * /tmp/asset-input && cd /tmp/asset-input && pip install -r requirements.txt -t . && mkdir /asset-output/python && cp -R /tmp/asset-input/* /asset-output/python',
52
+ ],
53
+ image: Runtime.PYTHON_3_12.bundlingImage,
54
+ user: 'root',
55
+ }
56
+ }),
57
+ });
58
+
59
+ // ZIP package type Functions
60
+ new PythonFunction(this, 'PythonFunction', {
61
+ entry: './src/python/Function',
62
+ index: 'app.py',
63
+ handler: 'lambda_handler',
64
+ runtime: Runtime.PYTHON_3_12,
65
+ functionName: 'pythonFunc',
66
+ logRetention: RetentionDays.THREE_MONTHS,
67
+ });
68
+ new Function(this, 'FunctionPythonRuntime', {
69
+ runtime: Runtime.PYTHON_3_12,
70
+ code: Code.fromAsset('./src/python/Function'),
71
+ handler: 'app.lambda_handler',
72
+ });
73
+ new Function(this, 'BundledFunctionPythonRuntime', {
74
+ runtime: Runtime.PYTHON_3_12,
75
+ code: Code.fromAsset('./src/python/Function/', {
76
+ bundling: {
77
+ command: [
78
+ '/bin/sh',
79
+ '-c',
80
+ 'rm -rf /tmp/asset-input && mkdir /tmp/asset-input && cp * /tmp/asset-input && cd /tmp/asset-input && pip install -r requirements.txt -t . && cp -R /tmp/asset-input/* /asset-output',
81
+ ],
82
+ image: Runtime.PYTHON_3_12.bundlingImage,
83
+ user: 'root',
84
+ }
85
+ }),
86
+ handler: 'app.lambda_handler',
87
+ });
88
+
89
+ // NodeJs Runtime
90
+ new NodejsFunction(this, 'NodejsFunction', {
91
+ entry: path.join(__dirname, '../src/nodejs/NodeJsFunctionConstruct/app.ts'),
92
+ depsLockFilePath: path.join(__dirname, '../src/nodejs/NodeJsFunctionConstruct/package-lock.json'),
93
+ bundling: {
94
+ forceDockerBundling: true,
95
+ },
96
+ handler: 'lambdaHandler',
97
+ });
98
+
99
+ // Go Runtime
100
+ new GoFunction(this, 'GoFunction', {
101
+ entry: './src/go/GoFunctionConstruct',
102
+ bundling: {
103
+ forcedDockerBundling: true,
104
+ // Only use Google proxy in the CI tests, as it is blocked on workstations
105
+ goProxies: isRunningOnCodeBuild ? [GoFunction.GOOGLE_GOPROXY, 'direct'] : undefined,
106
+ },
107
+ });
108
+
109
+ // Image Package Type Functions
110
+ new DockerImageFunction(this, 'DockerImageFunction', {
111
+ code: DockerImageCode.fromImageAsset('./src/docker/DockerImageFunctionConstruct', {
112
+ file: 'Dockerfile',
113
+ }),
114
+ });
115
+
116
+ // Spec Rest Api
117
+ new SpecRestApi(this, 'SpecRestAPI', {
118
+ apiDefinition: ApiDefinition.fromAsset('./src/rest-api-definition.yaml'),
119
+ });
120
+ // Role to be used as credentials for the Spec rest APi
121
+ // it is used inside the spec rest api definition file
122
+ new Role(this, 'SpecRestApiRole', {
123
+ assumedBy: new ServicePrincipal('apigateway.amazonaws.com'),
124
+ roleName: 'SpecRestApiRole',
125
+ }).addToPolicy(new PolicyStatement({
126
+ actions: ['lambda:InvokeFunction'],
127
+ resources: ['*'],
128
+ }));
129
+
130
+ // Nested Stack
131
+ new NestedStack1(this, 'NestedStack', {});
132
+ }
133
+ }
134
+ exports.CDKSupportDemoRootStack = CDKSupportDemoRootStack;
@@ -0,0 +1,9 @@
1
+ FROM public.ecr.aws/lambda/nodejs:18
2
+
3
+ # Assumes your function is named "app.js", and there is a package.json file in the app directory
4
+ COPY app.js package.json ./
5
+
6
+ RUN npm install
7
+
8
+ # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
9
+ CMD [ "app.lambdaHandler" ]
@@ -0,0 +1,22 @@
1
+ var gen = require('unique-names-generator');
2
+
3
+ const colorName = gen.uniqueNamesGenerator({
4
+ dictionaries: [gen.colors]
5
+ });
6
+
7
+ exports.lambdaHandler = async(event, context) => {
8
+ let response;
9
+
10
+ try {
11
+ response = {
12
+ 'statusCode': 200,
13
+ 'body': JSON.stringify({
14
+ message: "Hello World",
15
+ })
16
+ };
17
+ } catch (err) {
18
+ console.log(err);
19
+ return err;
20
+ }
21
+ return response;
22
+ };
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "DockerImageFunctionConstruct",
3
+ "description": "testing docker lambda function ",
4
+ "version": "0.1.0",
5
+ "bin": {
6
+ "randomColors": "bin/app.js"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "watch": "tsc -w",
11
+ "test": "jest",
12
+ "cdk": "cdk"
13
+ },
14
+ "license": "Apache-2.0",
15
+ "dependencies": {
16
+ "unique-names-generator": "^4.6.0"
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ require github.com/aws/aws-lambda-go v1.28.0
2
+
3
+ module hello-world
4
+
5
+ go 1.15
@@ -0,0 +1,17 @@
1
+ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2
+ github.com/aws/aws-lambda-go v1.28.0 h1:fZiik1PZqW2IyAN4rj+Y0UBaO1IDFlsNo9Zz/XnArK4=
3
+ github.com/aws/aws-lambda-go v1.28.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
4
+ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
5
+ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
6
+ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9
+ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10
+ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
11
+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
12
+ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
13
+ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
14
+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15
+ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
16
+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17
+ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
@@ -0,0 +1,17 @@
1
+ package main
2
+
3
+ import (
4
+ "github.com/aws/aws-lambda-go/events"
5
+ "github.com/aws/aws-lambda-go/lambda"
6
+ )
7
+
8
+ func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
9
+ return events.APIGatewayProxyResponse{
10
+ Body: "{\"message\": \"Hello World\"}",
11
+ StatusCode: 200,
12
+ }, nil
13
+ }
14
+
15
+ func main() {
16
+ lambda.Start(handler)
17
+ }
@@ -0,0 +1,16 @@
1
+ let response;
2
+
3
+ exports.lambdaHandler = async(event, context) => {
4
+ try {
5
+ response = {
6
+ 'statusCode': 200,
7
+ 'body': JSON.stringify({
8
+ message: `Hello World`,
9
+ })
10
+ };
11
+ } catch (err) {
12
+ console.log(err);
13
+ return err;
14
+ }
15
+ return response;
16
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "hello_world",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 2,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "hello_world",
9
+ "version": "1.0.0"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "hello_world",
3
+ "version": "1.0.0",
4
+ "main": "app.js"
5
+ }
@@ -0,0 +1,15 @@
1
+ from geonamescache import GeonamesCache
2
+ import json
3
+
4
+
5
+ def lambda_handler(event, context):
6
+
7
+ response = {
8
+ "statusCode": 200,
9
+ "body": json.dumps(
10
+ {
11
+ "message": "Hello World",
12
+ }
13
+ ),
14
+ }
15
+ return response
@@ -0,0 +1,5 @@
1
+ from geonamescache import GeonamesCache
2
+
3
+
4
+ def get_dependency():
5
+ return 5
@@ -0,0 +1,12 @@
1
+ openapi: '3.0.2'
2
+ info:
3
+ title: API Gateway IP Filtering Example API
4
+
5
+ paths:
6
+ "/restapis/spec/pythonFunction":
7
+ get:
8
+ x-amazon-apigateway-integration:
9
+ httpMethod: POST
10
+ type: AWS_PROXY
11
+ uri: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:pythonFunc:$LATEST/invocations
12
+ credentials: arn:${AWS::Partition}:iam::${AWS::AccountId}:role/SpecRestApiRole
@@ -0,0 +1,26 @@
1
+ const cdk = require('aws-cdk-lib/core');
2
+ const iam = require('aws-cdk-lib/aws-iam');
3
+ const sqs = require('aws-cdk-lib/aws-sqs');
4
+
5
+ const stackPrefix = process.env.STACK_NAME_PREFIX;
6
+ if (!stackPrefix) {
7
+ throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
8
+ }
9
+
10
+ class SimpleStack extends cdk.Stack {
11
+ constructor(scope, id, props) {
12
+ super(scope, id, props);
13
+ const queue = new sqs.Queue(this, 'queue', {
14
+ visibilityTimeout: cdk.Duration.seconds(300),
15
+ });
16
+ const role = new iam.Role(this, 'role', {
17
+ assumedBy: new iam.AccountRootPrincipal(),
18
+ });
19
+ queue.grantConsumeMessages(role);
20
+ }
21
+ }
22
+
23
+ const app = new cdk.App();
24
+ new SimpleStack(app, `${stackPrefix}-simple-1`);
25
+
26
+ app.synth();
@@ -0,0 +1,7 @@
1
+ {
2
+ "app": "node app.js",
3
+ "versionReporting": false,
4
+ "context": {
5
+ "aws-cdk:enableDiffNoFail": "true"
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ This [PR](https://github.com/aws/aws-cdk/pull/16205) added a node version check to our CLI courtesy of [`@jsii/check-node/run`](https://github.com/aws/jsii/tree/main/packages/%40jsii/check-node).
2
+
3
+ This check now causes the CLI to print a deprecation warning that changes the output of the `synth` command. We don't consider this a breaking change since we have no guarantess for CLI output, but it did break some our integ tests (namely `cdk synth`) that used to rely on a specific output.
4
+
5
+ This patch brings the [fix](https://github.com/aws/aws-cdk/pull/16216) into the regression suite.