File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
packages/@aws-cdk-testing/cli-integ
resources/cdk-apps/context-app
tests/cli-integ-tests/flags Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 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 ( ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "app" : " node app.js" ,
3+ "context" : {
4+ "@aws-cdk/core:newStyleStackSynthesis" : true
5+ }
6+ }
Original file line number Diff line number Diff line change 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+ ) ;
You can’t perform that action at this time.
0 commit comments