11const { CloudFormation, Organizations, EC2 } = require ( 'aws-sdk' ) ;
2+ const { CloudFormationClient, DescribeEventsCommand } = require ( "@aws-sdk/client-cloudformation" ) ;
23const Tmp = require ( 'tmp' ) ;
34Tmp . setGracefulCleanup ( ) ;
45const fs = require ( 'fs-extra' ) ;
@@ -27,6 +28,7 @@ function getChangeSetName(changeSetName) {
2728class CloudFormationDeployer {
2829 constructor ( region , bucketManager , deploymentBucket ) {
2930 this . cloudFormationClient = new CloudFormation ( { region } ) ;
31+ this . region = region ;
3032 this . bucketManager = bucketManager ;
3133 this . deploymentBucket = deploymentBucket ;
3234 }
@@ -272,7 +274,7 @@ class CloudFormationDeployer {
272274 stackParameters . TemplateBody = templateString ;
273275 }
274276
275- let executeParameters = {
277+ const executeParameters = {
276278 ChangeSetName : getChangeSetName ( stackParameters . ChangeSetName ) ,
277279 StackName : options . stackName
278280 } ;
@@ -294,7 +296,9 @@ class CloudFormationDeployer {
294296 if ( ! noUpdatesDict [ changeSetResponse . StatusReason ] ) {
295297 let events ;
296298 if ( changeSetResponse . StatusReason && changeSetResponse . StatusReason . includes ( 'AWS::EarlyValidation::PropertyValidation' ) ) {
297- events = await this . cloudFormationClient . describeStackEvents ( { StackName : options . stackName } ) . promise ( ) ;
299+ const client = new CloudFormationClient ( { region : this . region } ) ;
300+ const response = await client . send ( new DescribeEventsCommand ( { ChangeSetName : executeParameters . ChangeSetName } ) ) ;
301+ events = response . OperationEvents ;
298302 }
299303
300304 const changeSetFailureError = { title : 'Failed to create changeset, review the stack events' , details : changeSetResponse , events } ;
0 commit comments