How to use the stacker.blueprints.base.Blueprint function in stacker

To help you get started, we’ve selected a few stacker 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 remind101 / stacker_blueprints / stacker_blueprints / sns.py View on Github external
]

    util.check_properties(topic, sns_topic_properties, "SNS")

    return topic


def validate_topics(topics):
    validated_topics = {}
    for topic_name, topic_config in topics.iteritems():
        validated_topics[topic_name] = validate_topic(topic_config)

    return validated_topics


class Topics(Blueprint):
    """
    Manages the creation of SNS topics.
    """

    VARIABLES = {
        "Topics": {
            "type": dict,
            "description": "Dictionary of SNS Topic definitions",
            "validator": validate_topics,
        }
    }

    def create_template(self):
        variables = self.get_variables()

        for topic_name, topic_config in variables["Topics"].iteritems():
github cloudtools / stacker / stacker / blueprints / empire / empire_base.py View on Github external
import logging

logger = logging.getLogger(__name__)

from troposphere import Base64, Join

from stacker.blueprints.base import Blueprint


class EmpireBase(Blueprint):
    def create_conditions(self):
        logger.debug("No conditions to setup for %s", self.name)

    def create_security_groups(self):
        logger.debug("No security_groups to setup for %s", self.name)

    def create_ecs_cluster(self):
        logger.debug("No ecs cluster to setup for %s", self.name)

    def create_load_balancer(self):
        logger.debug("No load_balancer to setup for %s", self.name)

    def create_iam_profile(self):
        logger.debug("No iam_profile to setup for %s", self.name)

    def create_autoscaling_group(self):
github remind101 / stacker_blueprints / stacker_blueprints / cloudwatch_logs.py View on Github external
]
LOG_RETENTION_STRINGS = [str(x) for x in LOG_RETENTION_VALUES]


def validate_cloudwatch_log_retention(value):
    if value not in LOG_RETENTION_VALUES:
        raise ValueError(
            "%d is not a valid retention period. Must be one of: %s" % (
                value,
                ', '.join(LOG_RETENTION_STRINGS)
            )
        )
    return value


class SubscriptionFilters(Blueprint):

    VARIABLES = {
        "SubscriptionFilters": {
            "type": TroposphereType(logs.SubscriptionFilter, many=True),
            "description": "Subscription filters to create.",
        }
    }

    def create_template(self):
        t = self.template
        variables = self.get_variables()

        for _filter in variables["SubscriptionFilters"]:
            t.add_resource(_filter)
            t.add_output(
                Output(
github cloudtools / stacker_cookiecutter / {{cookiecutter.repo_name}} / blueprints / touch.py View on Github external
from stacker.blueprints.base import Blueprint

from troposphere.cloudformation import WaitConditionHandle


class Touch(Blueprint):
    """Touch creates a wait condition handle and nothing else.

    For learning / functional testing.
    """

    def create_touch_wait_condition_handle(self):
        self.template.description = ("touch waits for nothing and "
                                     "returns quickly")
        self.template.add_resource(
            WaitConditionHandle("touchNothing")
        )

    def create_template(self):
        self.create_touch_wait_condition_handle()
github remind101 / stacker_blueprints / stacker_blueprints / efs.py View on Github external
from troposphere import ec2, efs
from troposphere import Join, Output, Ref, Tags

from stacker.blueprints.base import Blueprint
from stacker.blueprints.variables.types import TroposphereType
from stacker.exceptions import ValidatorError

from stacker_blueprints.util import merge_tags


class ElasticFileSystem(Blueprint):
    VARIABLES = {
        'VpcId': {
            'type': str,
            'description': 'VPC ID to create resources'
        },
        'PerformanceMode': {
            'type': str,
            'description': 'The performance mode of the file system',
            'default': 'generalPurpose'
        },
        'Tags': {
            'type': dict,
            'description': 'Tags to associate with the created resources',
            'default': {}
        },
        'Subnets': {
github remind101 / stacker_blueprints / stacker_blueprints / vpc.py View on Github external
eip_name,
                Domain='vpc',
                InstanceId=eip_instance_id,
                DependsOn=GW_ATTACH
            )
        )

    def create_template(self):
        self.create_vpc()
        self.create_internal_zone()
        self.create_default_security_group()
        self.create_dhcp_options()
        self.create_network()


class VPC2(Blueprint):
    """This is a stripped down version of the VPC Blueprint."""

    VARIABLES = {
        "VPC": {
            "type": TroposphereType(ec2.VPC),
        },
        "InternalZone": {
            "type": TroposphereType(route53.HostedZone, optional=True),
            "description": "The config for an internal zone. If provided, "
                           "the zone will be created with the VPCs setting "
                           "set to this VPC.",
            "default": None,
        },
    }

    def create_vpc(self):
github cloudtools / stacker / stacker / blueprints / asg.py View on Github external
from troposphere import (
    Ref, FindInMap, Not, Equals, And, Condition, Join, ec2, autoscaling,
    If, GetAtt
)
from troposphere import elasticloadbalancing as elb
from troposphere.autoscaling import Tag as ASTag
from troposphere.route53 import RecordSetType

from .base import Blueprint

CLUSTER_SG_NAME = "%sSG"
ELB_SG_NAME = "%sElbSG"
ELB_NAME = "%sLoadBalancer"


class AutoscalingGroup(Blueprint):
    PARAMETERS = {
        'VpcId': {'type': 'AWS::EC2::VPC::Id', 'description': 'Vpc Id'},
        'DefaultSG': {'type': 'AWS::EC2::SecurityGroup::Id',
                      'description': 'Top level security group.'},
        'BaseDomain': {
            'type': 'String',
            'default': '',
            'description': 'Base domain for the stack.'},
        'PrivateSubnets': {'type': 'List',
                           'description': 'Subnets to deploy private '
                                          'instances in.'},
        'PublicSubnets': {'type': 'List',
                          'description': 'Subnets to deploy public (elb) '
                                         'instances in.'},
        'AvailabilityZones': {'type': 'CommaDelimitedList',
                              'description': 'Availability Zones to deploy '
github cloudtools / stacker / stacker / blueprints / postgres.py View on Github external
from troposphere import (
    Ref, ec2, Output, GetAtt, Not, Equals, Condition, And, Join
)
from troposphere.rds import DBInstance, DBSubnetGroup
from troposphere.route53 import RecordSetType

from .base import Blueprint

RDS_INSTANCE_NAME = "PostgresRDS%s"
RDS_SUBNET_GROUP = "%sSubnetGroup"
RDS_SG_NAME = "RdsSG%s"


class PostgresRDS(Blueprint):
    PARAMETERS = {
        'VpcId': {'type': 'AWS::EC2::VPC::Id', 'description': 'Vpc Id'},
        'PrivateSubnets': {'type': 'List',
                           'description': 'Subnets to deploy private '
                                          'instances in.'},
        'InstanceType': {'type': 'String',
                         'description': 'AWS RDS Instance Type',
                         'default': 'db.m3.large'},
        'AllocatedStorage': {'type': 'Number',
                             'description': 'Space, in GB, to allocate to RDS '
                                            'instance.',
                             'default': '10'},
        'MasterUser': {'type': 'String',
                       'description': 'Name of the master user in the db.',
                       'default': 'dbuser'},
        'MasterUserPassword': {'type': 'String',
github remind101 / stacker_blueprints / stacker_blueprints / rds / base.py View on Github external
if value not in RDS_ENGINES:
        raise ValueError(
            "Engine must be one of: %s" % (", ".join(RDS_ENGINES))
        )
    return value


def validate_backup_retention_period(value):
    if not (0 <= value <= 35):
        raise ValueError(
            "Backup retention period must be between 0 and 35."
        )
    return value


class BaseRDS(Blueprint):
    """Base Blueprint for all RDS blueprints.

    Should not be used directly. Either use :class:`MasterInstance` or
    :class:`ReadReplica` classes, or a engine specific blueprint like
    :class:`stacker.blueprints.rds.postgres.MasterInstance` or
    :class:`stacker.blueprints.rds.postgres.ReadReplica`.
    """

    VARIABLES = {
        "DatabaseParameters": {
            "type": dict,
            "default": {},
        },
        "VpcId": {
            "type": str,
            "description": "Vpc Id"},
github remind101 / stacker_blueprints / stacker_blueprints / empire / daemon.py View on Github external
from .policies import (
    empire_policy,
    service_role_policy,
    sns_to_sqs_policy,
    sns_events_policy,
    runlogs_policy,
    logstream_policy,
)

ELB_SG_NAME = "ELBSecurityGroup"
EVENTS_TOPIC = "EventsTopic"
RUN_LOGS = "RunLogs"


class EmpireDaemon(Blueprint):
    VARIABLES = {
        "VpcId": {"type": EC2VPCId, "description": "Vpc Id"},
        "DefaultSG": {
            "type": EC2SecurityGroupId,
            "description": "Top level security group."},
        "ExternalDomain": {
            "type": CFNString,
            "description": "Base domain for the stack."},
        "PrivateSubnets": {
            "type": EC2SubnetIdList,
            "description": "Subnets to deploy private instances in."},
        "PublicSubnets": {
            "type": EC2SubnetIdList,
            "description": "Subnets to deploy public (elb) instances in."},
        "AvailabilityZones": {
            "type": CFNCommaDelimitedList,