@@ -56,6 +56,7 @@ async function parseCommandLineArguments() {
5656 . option ( 'proxy' , { type : 'string' , desc : 'Use the indicated proxy. Will read from HTTPS_PROXY environment variable if not specified.' } )
5757 . option ( 'ec2creds' , { type : 'boolean' , alias : 'i' , default : undefined , desc : 'Force trying to fetch EC2 instance credentials. Default: guess EC2 instance status.' } )
5858 . option ( 'version-reporting' , { type : 'boolean' , desc : 'Disable insersion of the CDKMetadata resource in synthesized templates' , default : undefined } )
59+ . option ( 'role-arn' , { type : 'string' , alias : 'r' , desc : 'ARN of Role to use when invoking CloudFormation' , default : undefined } )
5960 . command ( [ 'list' , 'ls' ] , 'Lists all stacks in the app' , yargs => yargs
6061 . option ( 'long' , { type : 'boolean' , default : false , alias : 'l' , desc : 'display environment information for each stack' } ) )
6162 . command ( [ 'synthesize [STACKS..]' , 'synth [STACKS..]' ] , 'Synthesizes and prints the CloudFormation template for this stack' , yargs => yargs
@@ -188,13 +189,13 @@ async function initCommandLine() {
188189 return await diffStack ( await findStack ( args . STACK ) , args . template ) ;
189190
190191 case 'bootstrap' :
191- return await cliBootstrap ( args . ENVIRONMENTS , toolkitStackName ) ;
192+ return await cliBootstrap ( args . ENVIRONMENTS , toolkitStackName , args . roleArn ) ;
192193
193194 case 'deploy' :
194- return await cliDeploy ( args . STACKS , toolkitStackName ) ;
195+ return await cliDeploy ( args . STACKS , toolkitStackName , args . roleArn ) ;
195196
196197 case 'destroy' :
197- return await cliDestroy ( args . STACKS , args . force ) ;
198+ return await cliDestroy ( args . STACKS , args . force , args . roleArn ) ;
198199
199200 case 'synthesize' :
200201 case 'synth' :
@@ -266,7 +267,7 @@ async function initCommandLine() {
266267 * all stacks are implicitly selected.
267268 * @param toolkitStackName the name to be used for the CDK Toolkit stack.
268269 */
269- async function cliBootstrap ( environmentGlobs : string [ ] , toolkitStackName : string ) : Promise < void > {
270+ async function cliBootstrap ( environmentGlobs : string [ ] , toolkitStackName : string , roleArn : string | undefined ) : Promise < void > {
270271 if ( environmentGlobs . length === 0 ) {
271272 environmentGlobs = [ '**' ] ; // default to ALL
272273 }
@@ -282,7 +283,7 @@ async function initCommandLine() {
282283 await Promise . all ( environments . map ( async ( environment ) => {
283284 success ( ' ⏳ Bootstrapping environment %s...' , colors . blue ( environment . name ) ) ;
284285 try {
285- const result = await bootstrapEnvironment ( environment , aws , toolkitStackName ) ;
286+ const result = await bootstrapEnvironment ( environment , aws , toolkitStackName , roleArn ) ;
286287 const message = result . noOp ? ' ✅ Environment %s was already fully bootstrapped!'
287288 : ' ✅ Successfully bootstraped environment %s!' ;
288289 success ( message , colors . blue ( environment . name ) ) ;
@@ -575,7 +576,7 @@ async function initCommandLine() {
575576 return response.stacks;
576577 }
577578
578- async function cliDeploy ( stackNames : string [ ] , toolkitStackName : string ) {
579+ async function cliDeploy(stackNames: string[], toolkitStackName: string, roleArn: string | undefined ) {
579580 const stacks = await selectStacks(...stackNames);
580581 renames.validateSelectedStacks(stacks);
581582
@@ -595,7 +596,7 @@ async function initCommandLine() {
595596 }
596597
597598 try {
598- const result = await deployStack ( stack , aws , toolkitInfo , deployName ) ;
599+ const result = await deployStack({ stack, sdk: aws, toolkitInfo, deployName, roleArn } );
599600 const message = result.noOp ? ` ✅ Stack was already up - to - date , it has ARN $ { colors. blue ( result . stackArn ) } `
600601 : ` ✅ Deployment of stack % s completed successfully , it has ARN $ { colors. blue ( result . stackArn ) } `;
601602 data(result.stackArn);
@@ -611,7 +612,7 @@ async function initCommandLine() {
611612 }
612613 }
613614
614- async function cliDestroy ( stackNames : string [ ] , force : boolean ) {
615+ async function cliDestroy(stackNames: string[], force: boolean, roleArn: string | undefined ) {
615616 const stacks = await selectStacks(...stackNames);
616617 renames.validateSelectedStacks(stacks);
617618
@@ -628,7 +629,7 @@ async function initCommandLine() {
628629
629630 success(' ⏳ Starting destruction of stack %s...', colors.blue(deployName));
630631 try {
631- await destroyStack ( stack , aws , deployName ) ;
632+ await destroyStack({ stack, sdk: aws, deployName, roleArn } );
632633 success(' ✅ Stack %s successfully destroyed.', colors.blue(deployName));
633634 } catch (e) {
634635 error(' ❌ Destruction failed: %s', colors.blue(deployName), e);
0 commit comments