Skip to content

Commit a58f867

Browse files
committed
integ
1 parent 232e45b commit a58f867

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const cdk = require('aws-cdk-lib');
2+
3+
const app = new cdk.App();
4+
5+
const contextValue = app.node.tryGetContext('myContextParam');
6+
7+
if (!contextValue) {
8+
throw new Error('Context parameter "myContextParam" is required');
9+
}
10+
11+
const stack = new cdk.Stack(app, 'TestStack', {
12+
description: `Stack created with context value: ${contextValue}`,
13+
});
14+
15+
// Add a simple resource
16+
new cdk.CfnOutput(stack, 'ContextValue', {
17+
value: contextValue,
18+
description: 'The context value passed via CLI',
19+
});
20+
21+
app.synth();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"app": "node app.js",
3+
"context": {
4+
"@aws-cdk/core:newStyleStackSynthesis": true
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { integTest, withAws, withSpecificCdkApp } from '../../../lib';
2+
3+
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
4+
5+
integTest(
6+
'flags command works with CLI context parameters',
7+
withAws(
8+
withSpecificCdkApp('context-app', async (fixture) => {
9+
await fixture.cdk(['bootstrap', '-c', 'myContextParam=testValue']);
10+
11+
const output = await fixture.cdk([
12+
'flags',
13+
'--unstable=flags',
14+
'--set',
15+
'--recommended',
16+
'--all',
17+
'-c', 'myContextParam=testValue',
18+
'--yes',
19+
]);
20+
21+
expect(output).toContain('Flag changes:');
22+
}),
23+
true,
24+
),
25+
);

0 commit comments

Comments
 (0)