How to use the sceptre.exceptions.StackDoesNotExistError function in sceptre

To help you get started, we’ve selected a few sceptre examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sceptre / sceptre / tests / test_actions.py View on Github external
def test_delete_when_wait_for_completion_raises_stack_does_not_exist_error(
            self, mock_get_status, mock_wait_for_completion
    ):
        mock_get_status.return_value = "CREATE_COMPLETE"
        mock_wait_for_completion.side_effect = StackDoesNotExistError()
        status = self.actions.delete()
        assert status == StackStatus.COMPLETE
github Sceptre / sceptre / tests / test_resolvers / test_stack_output.py View on Github external
def test_get_stack_outputs_with_unlaunched_stack(self):
        self.stack.connection_manager.call.side_effect = ClientError(
            {
                "Error": {
                    "Code": "404",
                    "Message": "stack does not exist"
                }
            },
            sentinel.operation
        )

        with pytest.raises(StackDoesNotExistError):
            self.base_stack_output_resolver._get_stack_outputs(
                sentinel.stack_name
            )
github Sceptre / sceptre / tests / test_actions.py View on Github external
def test_launch_with_stack_that_does_not_exist(
            self, mock_get_status, mock_create
    ):
        mock_get_status.side_effect = StackDoesNotExistError()
        mock_create.return_value = sentinel.launch_response
        response = self.actions.launch()
        mock_create.assert_called_once_with()
        assert response == sentinel.launch_response
github Sceptre / sceptre / tests / test_actions.py View on Github external
def test_delete_with_non_existent_stack(
            self, mock_get_status, mock_wait_for_completion
    ):
        mock_get_status.side_effect = StackDoesNotExistError()
        status = self.actions.delete()
        assert status == StackStatus.COMPLETE
github Sceptre / sceptre / integration-tests / steps / helpers.py View on Github external
def step_impl(context, exception_type):
    if exception_type == "TemplateSceptreHandlerError":
        assert isinstance(context.error, TemplateSceptreHandlerError)
    elif exception_type == "UnsupportedTemplateFileTypeError":
        assert isinstance(context.error, UnsupportedTemplateFileTypeError)
    elif exception_type == "StackDoesNotExistError":
        assert isinstance(context.error, StackDoesNotExistError)
    elif exception_type == "ClientError":
        assert isinstance(context.error, ClientError)
    elif exception_type == "AttributeError":
        assert isinstance(context.error, AttributeError)
    elif exception_type == "UndefinedError":
        assert isinstance(context.error, jinja2.exceptions.UndefinedError)
    else:
        raise Exception("Step has incorrect message")
github Sceptre / sceptre / sceptre / plan / actions.py View on Github external
"""
        Launches the Stack.

        If the Stack status is create_failed or rollback_complete, the
        Stack is deleted. Launch then tries to create or update the Stack,
        depending if it already exists. If there are no updates to be
        performed, launch exits gracefully.

        :returns: The Stack's status.
        :rtype: sceptre.stack_status.StackStatus
        """
        self._protect_execution()
        self.logger.info("%s - Launching Stack", self.stack.name)
        try:
            existing_status = self._get_status()
        except StackDoesNotExistError:
            existing_status = "PENDING"

        self.logger.info(
            "%s - Stack is in the %s state", self.stack.name, existing_status
        )

        if existing_status == "PENDING":
            status = self.create()
        elif existing_status in ["CREATE_FAILED", "ROLLBACK_COMPLETE"]:
            self.delete()
            status = self.create()
        elif existing_status.endswith("COMPLETE"):
            status = self.update()
        elif existing_status.endswith("IN_PROGRESS"):
            self.logger.info(
                "%s - Stack action is already in progress state and cannot "
github Sceptre / sceptre / sceptre / resolvers / stack_output.py View on Github external
))
        connection_manager = self.stack.connection_manager

        try:
            response = connection_manager.call(
                service="cloudformation",
                command="describe_stacks",
                kwargs={"StackName": stack_name},
                profile=profile,
                region=region,
                stack_name=stack_name,
                iam_role=iam_role
            )
        except ClientError as e:
            if "does not exist" in e.response["Error"]["Message"]:
                raise StackDoesNotExistError(e.response["Error"]["Message"])
            else:
                raise e
        else:
            outputs = response["Stacks"][0].get("Outputs", {})

        self.logger.debug("Outputs: {0}".format(outputs))

        formatted_outputs = dict(
            (output["OutputKey"], output["OutputValue"])
            for output in outputs
        )

        return formatted_outputs
github Sceptre / sceptre / sceptre / plan / actions.py View on Github external
def _get_status(self):
        try:
            status = self._describe()["Stacks"][0]["StackStatus"]
        except botocore.exceptions.ClientError as exp:
            if exp.response["Error"]["Message"].endswith("does not exist"):
                raise StackDoesNotExistError(exp.response["Error"]["Message"])
            else:
                raise exp
        return status