def wait_for_changeset(self, changeset_id, stack_name): """ Waits until the changeset creation completes :param changeset_id: ID or name of the changeset :param stack_name: Stack name :return: Latest status of the create-change-set operation """ sys.stdout.write("\nWaiting for changeset to be created..\n") sys.stdout.flush() # Wait for changeset to be created waiter = self._client.get_waiter("change_set_create_complete") # Poll every 5 seconds. Changeset creation should be fast waiter_config = {'Delay': 5} try: waiter.wait(ChangeSetName=changeset_id, StackName=stack_name, WaiterConfig=waiter_config) except botocore.exceptions.WaiterError as ex: LOG.debug("Create changeset waiter exception", exc_info=ex) resp = ex.last_response status = resp["Status"] reason = resp["StatusReason"] if status == "FAILED" and \ "The submitted information didn't contain changes." in reason or \ "No updates are to be performed" in reason: raise exceptions.ChangeEmptyError(stack_name=stack_name) raise RuntimeError("Failed to create the changeset: {0} " "Status: {1}. Reason: {2}".format( ex, status, reason))
def test_deploy_raises_exception_on_empty_changeset(self): stack_name = "stack_name" parameters = ["a", "b"] template = "cloudformation template" capabilities = ["foo", "bar"] execute_changeset = True role_arn = "arn:aws:iam::1234567890:role" notification_arns = ["arn:aws:sns:region:1234567890:notify"] tags = [] empty_changeset = exceptions.ChangeEmptyError(stack_name=stack_name) changeset_func = self.deployer.create_and_wait_for_changeset changeset_func.side_effect = empty_changeset with self.assertRaises(exceptions.ChangeEmptyError): self.deploy_command.deploy(self.deployer, stack_name, template, parameters, capabilities, execute_changeset, role_arn, notification_arns, None, tags, fail_on_empty_changeset=True)