How to use the runway.cfngin.providers.base.Template function in runway

To help you get started, we’ve selected a few runway 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 onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
generate_change_set_response(
                status="CREATE_COMPLETE", execution_status="AVAILABLE",
                changes=changes,
            )
        )

        self.stubber.add_response("set_stack_policy", {})

        self.stubber.add_response("execute_change_set", {})

        with self.stubber:
            self.provider.noninteractive_changeset_update(
                fqn=stack_name,
                template=Template(url="http://fake.template.url.com/"),
                old_parameters=[],
                parameters=[], stack_policy=Template(body="{}"), tags=[],
            )
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
def test_create_stack_with_changeset(self, patched_create_change_set,
                                         patched_update_term):
        """Test create_stack, force changeset, termination protection."""
        stack_name = 'fake_stack'
        template_path = Path('./tests/cfngin/fixtures/cfn_template.yaml')
        template = Template(body=template_path.read_text())
        parameters = []
        tags = []

        changeset_id = 'CHANGESETID'

        patched_create_change_set.return_value = ([], changeset_id)

        self.stubber.add_response(
            'execute_change_set',
            {},
            {'ChangeSetName': changeset_id}
        )

        with self.stubber:
            self.provider.create_stack(stack_name, template, parameters, tags,
                                       force_change_set=True,
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
"create_change_set",
            {'Id': 'CHANGESETID', 'StackId': 'STACKID'}
        )

        self.stubber.add_response(
            "describe_change_set",
            generate_change_set_response(
                status="CREATE_COMPLETE", execution_status="UNAVAILABLE",
            )
        )

        with self.stubber:
            with self.assertRaises(exceptions.UnableToExecuteChangeSet):
                create_change_set(
                    cfn_client=self.cfn, fqn="my-fake-stack",
                    template=Template(url="http://fake.template.url.com/"),
                    parameters=[], tags=[]
                )
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
{'Stacks': [generate_describe_stacks_stack(
                stack_name, stack_status='REVIEW_IN_PROGRESS'
            )]}
        )
        self.stubber.add_response(
            'describe_stacks',
            {'Stacks': [generate_describe_stacks_stack(
                stack_name, stack_status='REVIEW_IN_PROGRESS'
            )]}
        )

        self.stubber.add_response("delete_stack", {})

        with self.stubber:
            self.provider.get_stack_changes(
                stack=mock_stack, template=Template(
                    url="http://fake.template.url.com/"
                ), parameters=[], tags=[])

        mock_output_full_cs.assert_called_with(full_changeset=changes,
                                               params_diff=[],
                                               fqn=stack_name,
                                               answer='y')
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
result = generate_cloudformation_args(change_set_name="MyChanges",
                                              **std_args)
        change_set_result = copy.deepcopy(std_return)
        change_set_result["ChangeSetName"] = "MyChanges"
        self.assertEqual(result, change_set_result)

        # Check stack policy
        stack_policy = Template(body="{}")
        result = generate_cloudformation_args(stack_policy=stack_policy,
                                              **std_args)
        stack_policy_result = copy.deepcopy(std_return)
        stack_policy_result["StackPolicyBody"] = "{}"
        self.assertEqual(result, stack_policy_result)

        # If not TemplateURL is provided, use TemplateBody
        std_args["template"] = Template(body=template_body)
        template_body_result = copy.deepcopy(std_return)
        del template_body_result["TemplateURL"]
        template_body_result["TemplateBody"] = template_body
        result = generate_cloudformation_args(**std_args)
        self.assertEqual(result, template_body_result)
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
def test_create_stack_no_changeset(self):
        """Test create_stack, no changeset, template url."""
        stack_name = 'fake_stack'
        template = Template(url="http://fake.template.url.com/")
        parameters = []
        tags = []

        expected_args = generate_cloudformation_args(stack_name,
                                                     parameters,
                                                     tags,
                                                     template)
        expected_args['EnableTerminationProtection'] = False

        self.stubber.add_response(
            'create_stack',
            {'StackId': stack_name},
            expected_args
        )

        with self.stubber:
github onicagroup / runway / tests / cfngin / providers / aws / test_default.py View on Github external
status="CREATE_COMPLETE", execution_status="AVAILABLE",
                changes=changes,
            )
        )

        self.stubber.add_response("set_stack_policy", {})

        self.stubber.add_response("execute_change_set", {})

        with self.stubber:
            self.provider.update_stack(
                fqn=stack_name,
                template=Template(url="http://fake.template.url.com/"),
                old_parameters=[],
                parameters=[], tags=[],
                stack_policy=Template(body="{}"),
            )

        patched_approval.assert_called_once_with(full_changeset=changes,
                                                 params_diff=[],
                                                 include_verbose=True,
                                                 fqn=stack_name)
        patched_update_term.assert_called_once_with(stack_name, False)
github onicagroup / runway / runway / cfngin / actions / build.py View on Github external
def _template(self, blueprint):
        """Generate a template based on whether or not an S3 bucket is set.

        If an S3 bucket is set, then the template will be uploaded to S3 first,
        and CreateStack/UpdateStack operations will use the uploaded template.
        If not bucket is set, then the template will be inlined.

        """
        if self.bucket_name:
            return Template(url=self.s3_stack_push(blueprint))
        return Template(body=blueprint.rendered)
github onicagroup / runway / runway / cfngin / actions / build.py View on Github external
def _template(self, blueprint):
        """Generate a template based on whether or not an S3 bucket is set.

        If an S3 bucket is set, then the template will be uploaded to S3 first,
        and CreateStack/UpdateStack operations will use the uploaded template.
        If not bucket is set, then the template will be inlined.

        """
        if self.bucket_name:
            return Template(url=self.s3_stack_push(blueprint))
        return Template(body=blueprint.rendered)