def deploy_test_stack()

in example/my_example/cli.py [0:0]


def deploy_test_stack() -> None:
    """This function demonstrates using the codeseeder library and tools to deploy an additional CloudFormation Stack

    This additional CloudFormation Stack defines an IAM Role with Trust Relationship to AWS CodeBuild. This
    demonstrates how to use the Seedkit tools to create a dedicated IAM Role for use by CodeBuile. The example also
    attachs the Seedkit's IAM Managed Policy to this new Role, granting the Role access to the Seedkit's resources
    """
    toolkit_stack_name = services.cfn.get_stack_name("my-example")
    toolkit_stack_exists, stack_outputs = services.cfn.does_stack_exist(stack_name=toolkit_stack_name)

    if toolkit_stack_exists and not codeseeder.EXECUTING_REMOTELY:
        test_stack_name = "my-example-stack"
        test_stack_exists, _ = services.cfn.does_stack_exist(stack_name=test_stack_name)

        if not test_stack_exists:
            _logger.info("Deploying Test Stack")
            src_filename = os.path.join(CLI_ROOT, "resources", "template.yaml")
            with open(src_filename, "r") as src_file:
                src_template = load_yaml(src_file)

            src_template["Resources"]["CodeArtifactPolicy"]["Properties"]["Roles"] = [stack_outputs["CodeBuildRole"]]

            dst_template = Template(yaml.dump(src_template, Dumper=yaml_dumper.get_dumper()))

            dst_dir = create_output_dir("my-example")
            dst_filename = os.path.join(dst_dir, "template.yaml")
            with open(dst_filename, "w") as dst_file:
                dst_file.write(
                    dst_template.safe_substitute(account_id=services.get_account_id(), region=services.get_region())
                )
            services.cfn.deploy_template(stack_name=test_stack_name, filename=dst_filename, seedkit_tag="my-example")
        else:
            _logger.info("Test Stack already exists")