Exemplo n.º 1
0
class RouteTable(Resource):

    resource_name = "route_table"

    name = argument.String()
    routes = argument.ResourceList(Route)
    propagating_vpn_gateways = argument.ResourceList(VpnGateway)
    tags = argument.Dict()
    vpc = argument.Resource(VPC, field='VpcId')
Exemplo n.º 2
0
class NetworkACL(Resource):

    resource_name = "network_acl"

    name = argument.String()
    inbound = argument.ResourceList(Rule)
    outbound = argument.ResourceList(Rule)

    tags = argument.Dict()
    vpc = argument.Resource(VPC, field="VpcId")
Exemplo n.º 3
0
class SecurityGroup(Resource):

    resource_name = "security_group"

    name = argument.String(field="GroupName")
    description = argument.String(field="Description")

    ingress = argument.ResourceList(Rule)
    egress = argument.ResourceList(
        Rule,
        default=lambda instance: [dict(protocol=-1, network=['0.0.0.0/0'])],
    )

    tags = argument.Dict()
    vpc = argument.Resource(VPC, field="VpcId")
Exemplo n.º 4
0
class HostedZone(Resource):
    """ A DNS zone hosted at Amazon Route53 """

    resource_name = "hosted_zone"

    extra_serializers = {
        "CallerReference":
        serializers.Expression(lambda x, y: str(uuid.uuid4())),
    }

    name = argument.String(field="Name")
    vpc = argument.Resource(VPC, field="VPC")
    comment = argument.String(
        field="HostedZoneConfig",
        serializer=serializers.Dict(Comment=serializers.Identity(), ),
    )

    records = argument.ResourceList(Record)

    shared = argument.Boolean()
    """ If a hosted zone is shared then it won't be destroyed and DNS records will never be deleted """

    account = argument.Resource(BaseAccount)

    def clean_name(self, name):
        return _normalize(name)
Exemplo n.º 5
0
class InstanceProfile(Resource):

    resource_name = "instance_profile"

    name = argument.String(field="InstanceProfileName")
    path = argument.String(field='Path')
    roles = argument.ResourceList(Role)
    account = argument.Resource(Account)
Exemplo n.º 6
0
class LaunchConfiguration(Resource):

    resource_name = "launch_configuration"

    name = argument.String(max=255, field="LaunchConfigurationName", update=False)

    image = argument.String(max=255, field="ImageId")

    key_pair = argument.Resource(KeyPair, field="KeyName")

    security_groups = argument.ResourceList(SecurityGroup, field="SecurityGroups")

    user_data = argument.Serializer(field="UserData")

    instance_type = argument.String(max=255, field="InstanceType")

    kernel = argument.String(max=255, field="KernelId")

    ramdisk = argument.String(max=255, field="RamdiskId")

    # block_devices = argument.Dict(field="BlockDeviceMappings")

    instance_monitoring = argument.Boolean(
        default=False,
        field="InstanceMonitoring",
        serializer=serializers.Dict(Enabled=serializers.Identity()),
    )

    spot_price = argument.String(field="SpotPrice")

    instance_profile = argument.Resource(
        InstanceProfile,
        field="IamInstanceProfile",
        serializers=serializers.Property("Arn"),
    )

    ebs_optimized = argument.Boolean(field="EbsOptimized")

    associate_public_ip_address = argument.Boolean(field="AssociatePublicIpAddress")

    placement_tenancy = argument.String(
        max=64,
        choices=[
            "default",
            "dedicated",
        ],
        field="PlacementTenancy",
    )

    account = argument.Resource(Account)

    def matches(self, runner, remote):
        if "UserData" in remote and remote["UserData"]:
            import base64
            remote["UserData"] = base64.b64decode(remote["UserData"])
        return super(LaunchConfiguration, self).matches(runner, remote)
Exemplo n.º 7
0
class SubnetGroup(Resource):

    resource_name = "db_subnet_group"

    name = argument.String(field="DBSubnetGroupName")
    description = argument.String(field="DBSubnetGroupDescription")
    subnets = argument.ResourceList(Subnet, field="SubnetIds")
    # tags = argument.Dict()

    account = argument.Resource(Account)
Exemplo n.º 8
0
class LoadBalancer(Resource):

    resource_name = "load_balancer"

    name = argument.String(field="LoadBalancerName")
    listeners = argument.ResourceList(
        Listener,
        field="Listeners",
        serializer=serializers.List(serializers.Resource()),
    )
    availability_zones = argument.List(field="AvailabilityZones")
    scheme = argument.String(choices=["internet-facing", "private"],
                             field="Scheme")
    subnets = argument.ResourceList(Subnet, field="Subnets")
    security_groups = argument.ResourceList(SecurityGroup,
                                            field="SecurityGroups")
    # tags = argument.Dict()

    health_check = argument.Resource(HealthCheck)
    attributes = argument.Resource(Attributes)

    account = argument.Resource(Account)
Exemplo n.º 9
0
class AutoScalingGroup(Resource):

    resource_name = "auto_scaling_group"

    name = argument.String(field="AutoScalingGroupName")
    launch_configuration = argument.Resource(LaunchConfiguration,
                                             field="LaunchConfigurationName")
    min_size = argument.Integer(field="MinSize")
    max_size = argument.Integer(field="MaxSize")
    desired_capacity = argument.Integer(field="DesiredCapacity")
    default_cooldown = argument.Integer(default=300, field="DefaultCooldown")
    availability_zones = argument.List(
        field="AvailabilityZones",
        serializer=serializers.List(skip_empty=True))
    subnets = argument.ResourceList(
        Subnet,
        field="VPCZoneIdentifier",
        serializer=serializers.CommaSeperatedList(
            serializers.List(serializers.Identifier())),
    )
    load_balancers = argument.ResourceList(LoadBalancer,
                                           field="LoadBalancerNames",
                                           aws_update=False)
    health_check_type = argument.String(
        max=32,
        default=lambda instance: "ELB" if instance.load_balancers else None,
        field="HealthCheckType",
    )
    health_check_grace_period = argument.Integer(
        default=lambda instance: 480 if instance.load_balancers else None,
        field="HealthCheckGracePeriod",
    )
    placement_group = argument.String(max=255, field="PlacementGroup")
    termination_policies = argument.List(default=lambda i: ["Default"],
                                         field="TerminationPolicies")
    replacement_policy = argument.String(choices=['singleton', 'graceful'],
                                         default='graceful')

    account = argument.Resource(BaseAccount)
Exemplo n.º 10
0
class Database(Resource):

    resource_name = "database"

    name = argument.String(field="DBInstanceIdentifier")
    db_name = argument.String(field="DBName")
    allocated_storage = argument.Integer(min=5,
                                         max=3072,
                                         field="AllocatedStorage")
    iops = argument.Integer(field="Iops")
    instance_class = argument.String(field="DBInstanceClass")
    engine = argument.String(default='postgres',
                             field="Engine",
                             aws_update=False)
    engine_version = argument.String(field="EngineVersion")
    license_model = argument.String()
    master_username = argument.String(field="MasterUsername")
    master_password = argument.String(field="MasterUserPassword")
    security_groups = argument.ResourceList(SecurityGroup,
                                            field="VpcSecurityGroupIds")
    publically_accessible = argument.Boolean(field="PubliclyAccessible",
                                             aws_update=False)
    availability_zone = argument.String(field="AvailabilityZone")
    subnet_group = argument.Resource(SubnetGroup,
                                     field="DBSubnetGroupName",
                                     aws_update=False)
    preferred_maintenance_window = argument.String(
        field="PreferredMaintenanceWindow")
    multi_az = argument.Boolean(field="MultiAZ")
    storage_type = argument.String(field="StorageType")
    allow_major_version_upgrade = argument.Boolean(
        field="AllowMajorVersionUpgrade")
    auto_minor_version_upgrade = argument.Boolean(
        field="AutoMinorVersionUpgrade")
    character_set_name = argument.String(field="CharacterSetName")
    backup_retention_period = argument.Integer(field="BackupRetentionPeriod")
    preferred_backup_window = argument.String(field="PreferredBackupWindow")
    license_model = argument.String(field="LicenseModel")
    port = argument.Integer(min=1, max=32768, field="Port")
    # paramter_group = argument.Resource(ParameterGroup, field="DBParameterGroupName")
    # option_group = argument.Resource(OptionGroup, field="OptionGroupName")
    apply_immediately = argument.Boolean(field="ApplyImmediately",
                                         aws_create=False)
    # tags = argument.Dict()
    account = argument.Resource(Account)
Exemplo n.º 11
0
class AutoScalingGroup(zone.Zone):

    resource_name = "auto_scaling_group"

    name = argument.String()

    replacement_policy = argument.String(choices=['singleton', 'graceful'], )

    load_balancers = argument.ResourceList(LoadBalancer, )

    user_data = argument.Dict()

    def clean_user_data(self, value):
        value = serializers.Dict(**value)
        for dep in value.dependencies(self):
            if dep != self:
                self.add_dependency(dep)
        return value
Exemplo n.º 12
0
class Distribution(Resource):

    resource_name = "distribution"

    extra_serializers = {
        "CallerReference":
        serializers.Expression(lambda runner, object: runner.get_plan(object).
                               object.get('DistributionConfig', {}).get(
                                   'CallerReference', str(uuid.uuid4()))),
        "Aliases":
        CloudFrontList(
            serializers.Chain(
                serializers.Context(serializers.Argument("name"),
                                    serializers.ListOfOne()),
                serializers.Context(serializers.Argument("aliases"),
                                    serializers.List()),
            )),
        # We don't support GeoRestrictions yet - so include a stubbed default
        # when serializing
        "Restrictions":
        serializers.Const({
            "GeoRestriction": {
                "RestrictionType": "none",
                "Quantity": 0,
            },
        }),
    }

    name = argument.String()
    comment = argument.String(field='Comment',
                              default=lambda instance: instance.name)
    aliases = argument.List()
    root_object = argument.String(default='/', field="DefaultRootObject")
    enabled = argument.Boolean(default=True, field="Enabled")
    origins = argument.ResourceList(
        (S3Origin, CustomOrigin),
        field="Origins",
        serializer=CloudFrontResourceList(),
    )
    default_cache_behavior = argument.Resource(
        DefaultCacheBehavior,
        field="DefaultCacheBehavior",
        serializer=serializers.Resource(),
    )
    behaviors = argument.ResourceList(
        CacheBehavior,
        field="CacheBehaviors",
        serializer=CloudFrontResourceList(),
    )
    error_responses = argument.ResourceList(
        ErrorResponse,
        field="CustomErrorResponses",
        serializer=CloudFrontResourceList(),
    )
    logging = argument.Resource(
        LoggingConfig,
        default=lambda instance: dict(enabled=False),
        field="Logging",
        serializer=serializers.Resource(),
    )
    price_class = argument.String(
        default="PriceClass_100",
        choices=['PriceClass_100', 'PriceClass_200', 'PriceClass_All'],
        field="PriceClass",
    )
    viewer_certificate = argument.Resource(
        ViewerCertificate,
        field="ViewerCertificate",
        serializer=serializers.Resource(),
    )

    account = argument.Resource(Account)