override def execute()

in magenta-lib/src/main/scala/magenta/tasks/ChangeSetTasks.scala [382:438]


  override def execute(
      resources: DeploymentResources,
      stopFlag: => Boolean
  ): Unit = {
    CloudFormation.withCfnClient(keyRing, region, resources) { cfnClient =>
      val (stackName, _, _, _) =
        stackLookup.lookup(resources.reporter, cfnClient)
      val changeSetName = stackLookup.changeSetName

      val changeSet = CloudFormation.describeChangeSetByName(
        stackName,
        changeSetName,
        cfnClient
      )

      val changeSetArn = changeSet.changeSetId()

      if (changeSet.changes.isEmpty) {
        resources.reporter.info(
          s"No changes to perform for $changeSetName on stack $stackName"
        )
      } else {
        changeSet.changes.asScala.foreach { change =>
          resources.reporter.verbose(
            s"${change.`type`} - ${change.resourceChange}"
          )
        }

        CloudFormation.executeChangeSet(stackName, changeSetName, cfnClient)

        new CloudFormationStackEventPoller(
          stackName,
          cfnClient,
          resources,
          stopFlag
        )
          .check(
            None,
            () => {
              val executionStatus = CloudFormation
                .describeChangeSetByArn(changeSetArn, cfnClient)
                .executionStatusAsString()

              // Any other status is a failure condition, which `CloudFormationStackEventPoller` is handling at the CloudFormation event log level
              val isComplete = executionStatus == "EXECUTE_COMPLETE"

              if (!isComplete) {
                resources.reporter.verbose(
                  s"Execution status for change set $changeSetName on stack $stackName is $executionStatus"
                )
              }
              isComplete
            }
          )
      }
    }
  }