@aws-cdk-testing/cli-integ 2.161.0 → 2.161.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.
- package/README.md +1 -1
- package/lib/with-cdk-app.d.ts +0 -5
- package/lib/with-cdk-app.js +4 -16
- package/package.json +3 -3
- package/resources/cli-regression-patches/v2.161.0/NOTES.md +1 -0
- package/resources/cli-regression-patches/v2.161.0/skip-tests.txt +5 -0
- package/tests/cli-integ-tests/cli.integtest.js +2 -65
- package/resources/cdk-apps/rollback-test-app/app.js +0 -100
- package/resources/cdk-apps/rollback-test-app/cdk.json +0 -7
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
const cdk = require('aws-cdk-lib');
|
|
2
|
-
const lambda = require('aws-cdk-lib/aws-lambda');
|
|
3
|
-
const cr = require('aws-cdk-lib/custom-resources');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This stack will be deployed in multiple phases, to achieve a very specific effect
|
|
7
|
-
*
|
|
8
|
-
* It contains resources r1 and r2, where r1 gets deployed first.
|
|
9
|
-
*
|
|
10
|
-
* - PHASE = 1: both resources deploy regularly.
|
|
11
|
-
* - PHASE = 2a: r1 gets updated, r2 will fail to update
|
|
12
|
-
* - PHASE = 2b: r1 gets updated, r2 will fail to update, and r1 will fail its rollback.
|
|
13
|
-
*
|
|
14
|
-
* To exercise this app:
|
|
15
|
-
*
|
|
16
|
-
* ```
|
|
17
|
-
* env PHASE=1 npx cdk deploy
|
|
18
|
-
* env PHASE=2b npx cdk deploy --no-rollback
|
|
19
|
-
* # This will leave the stack in UPDATE_FAILED
|
|
20
|
-
*
|
|
21
|
-
* env PHASE=2b npx cdk rollback
|
|
22
|
-
* # This will start a rollback that will fail because r1 fails its rollabck
|
|
23
|
-
*
|
|
24
|
-
* env PHASE=2b npx cdk rollback --force
|
|
25
|
-
* # This will retry the rollabck and skip r1
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
class RollbacktestStack extends cdk.Stack {
|
|
29
|
-
constructor(scope, id, props) {
|
|
30
|
-
super(scope, id, props);
|
|
31
|
-
|
|
32
|
-
let r1props = {};
|
|
33
|
-
let r2props = {};
|
|
34
|
-
|
|
35
|
-
const phase = process.env.PHASE;
|
|
36
|
-
switch (phase) {
|
|
37
|
-
case '1':
|
|
38
|
-
// Normal deployment
|
|
39
|
-
break;
|
|
40
|
-
case '2a':
|
|
41
|
-
// r1 updates normally, r2 fails updating
|
|
42
|
-
r2props.FailUpdate = true;
|
|
43
|
-
break;
|
|
44
|
-
case '2b':
|
|
45
|
-
// r1 updates normally, r2 fails updating, r1 fails rollback
|
|
46
|
-
r1props.FailRollback = true;
|
|
47
|
-
r2props.FailUpdate = true;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const fn = new lambda.Function(this, 'Fun', {
|
|
52
|
-
runtime: lambda.Runtime.NODEJS_LATEST,
|
|
53
|
-
code: lambda.Code.fromInline(`exports.handler = async function(event, ctx) {
|
|
54
|
-
const key = \`Fail\${event.RequestType}\`;
|
|
55
|
-
if (event.ResourceProperties[key]) {
|
|
56
|
-
throw new Error(\`\${event.RequestType} fails!\`);
|
|
57
|
-
}
|
|
58
|
-
if (event.OldResourceProperties?.FailRollback) {
|
|
59
|
-
throw new Error('Failing rollback!');
|
|
60
|
-
}
|
|
61
|
-
return {};
|
|
62
|
-
}`),
|
|
63
|
-
handler: 'index.handler',
|
|
64
|
-
timeout: cdk.Duration.minutes(1),
|
|
65
|
-
});
|
|
66
|
-
const provider = new cr.Provider(this, "MyProvider", {
|
|
67
|
-
onEventHandler: fn,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const r1 = new cdk.CustomResource(this, 'r1', {
|
|
71
|
-
serviceToken: provider.serviceToken,
|
|
72
|
-
properties: r1props,
|
|
73
|
-
});
|
|
74
|
-
const r2 = new cdk.CustomResource(this, 'r2', {
|
|
75
|
-
serviceToken: provider.serviceToken,
|
|
76
|
-
properties: r2props,
|
|
77
|
-
});
|
|
78
|
-
r2.node.addDependency(r1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const app = new cdk.App({
|
|
83
|
-
context: {
|
|
84
|
-
'@aws-cdk/core:assetHashSalt': process.env.CODEBUILD_BUILD_ID, // Force all assets to be unique, but consistent in one build
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const defaultEnv = {
|
|
89
|
-
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
90
|
-
region: process.env.CDK_DEFAULT_REGION
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const stackPrefix = process.env.STACK_NAME_PREFIX;
|
|
94
|
-
if (!stackPrefix) {
|
|
95
|
-
throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Sometimes we don't want to synthesize all stacks because it will impact the results
|
|
99
|
-
new RollbacktestStack(app, `${stackPrefix}-test-rollback`, { env: defaultEnv });
|
|
100
|
-
app.synth();
|