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)
Esempio n. 2
0
class LoggingConfig(Resource):

    resource_name = "logging_config"
    dot_ignore = True

    enabled = argument.Boolean(field="Enabled", default=False)
    include_cookies = argument.Boolean(field="IncludeCookies", default=False)
    bucket = argument.Resource(Bucket,
                               field="Bucket",
                               serializer=serializers.Default(default=None),
                               default="")
    prefix = argument.String(field="Prefix", default="")
Esempio n. 3
0
class Attributes(Resource):

    resource_name = "attributes"
    dot_ignore = True

    idle_timeout = argument.Integer(
        default=30,
        field="ConnectionSettings",
        serializer=serializers.Dict(IdleTimeout=serializers.Identity(), ),
    )

    connection_draining = argument.Integer(
        default=0,
        field="ConnectionDraining",
        serializer=serializers.Dict(
            Enabled=serializers.Expression(lambda runner, object: object > 0),
            Timeout=serializers.Identity(),
        ))

    cross_zone_load_balancing = argument.Boolean(
        default=True,
        field="CrossZoneLoadBalancing",
        serializer=serializers.Dict(Enabled=serializers.Identity(), ))

    access_log = argument.Resource(
        Bucket,
        field="AccessLog",
        serializer=serializers.Dict(
            Enabled=serializers.Expression(
                lambda runner, object: object is not None),
            S3BucketName=serializers.Identifier(),
        ))
Esempio 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)
Esempio n. 5
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)
Esempio n. 6
0
class ReplicationGroup(BaseCacheCluster, Resource):

    resource_name = "replication_group"

    name = argument.String(regex=r"[a-z1-9\-]{1,20}",
                           field="ReplicationGroupId")
    description = argument.String(default=lambda resource: resource.name,
                                  field="ReplicationGroupDescription")

    primary_cluster = argument.Resource(
        "touchdown.aws.elasticache.cache.CacheCluster",
        field="PrimaryClusterId")
    automatic_failover = argument.Boolean(field="AutomaticFailoverEnabled")
    num_cache_clusters = argument.Integer(field="NumCacheClusters")
Esempio n. 7
0
class Zone(Resource):

    name = argument.String()

    prefix = argument.Integer(default=24)

    cidr_block = argument.IPNetwork()
    """ Is this zone on the public internet? """
    public = argument.Boolean(default=False)
    """ The availability zones to create this zone in """
    availability_zones = argument.List(
        argument.String(min=1, max=1),
        min=2,
        max=2,
        default=["a", "b"],
    )

    environment = argument.Resource(Environment)
Esempio n. 8
0
class ForwardedValues(Resource):

    resource_name = "forwarded_values"
    dot_ignore = True

    extra_serializers = {
        "Cookies":
        serializers.Dict(
            Forward=serializers.Argument("forward_cookies"),
            WhitelistedNames=CloudFrontList(
                serializers.Argument("cookie_whitelist")),
        )
    }
    query_string = argument.Boolean(field="QueryString", default=False)
    headers = argument.List(field="Headers",
                            serializer=CloudFrontList(serializers.List()))

    forward_cookies = argument.String(default="whitelist")
    cookie_whitelist = argument.List()
Esempio n. 9
0
class VpnConnection(Resource):

    resource_name = "vpn_connection"

    name = argument.String()
    customer_gateway = argument.Resource(CustomerGateway, field="CustomerGatewayId")
    vpn_gateway = argument.Resource(VpnGateway, field="VpnGatewayId")
    type = argument.String(default="ipsec.1", choices=["ipsec.1"], field="Type")

    static_routes_only = argument.Boolean(
        default=True,
        field="Options",
        serializer=serializers.Dict(StaticRoutesOnly=serializers.Boolean()),
    )

    static_routes = argument.List()
    # FIXME: This should somehow be a list of argument.IPNetwork

    tags = argument.Dict()
    vpc = argument.Resource(VPC)
Esempio n. 10
0
class ViewerCertificate(Resource):

    resource_name = "viewer_certificate"

    certificate = argument.Resource(
        ServerCertificate,
        field="IAMCertificateId",
        serializer=serializers.Property("ServerCertificateId"),
    )

    default_certificate = argument.Boolean(
        field="CloudFrontDefaultCertificate")

    ssl_support_method = argument.String(
        default="sni-only",
        choices=["sni-only", "vip"],
        field="SSLSupportMethod",
    )

    minimum_protocol_version = argument.String(
        default="TLSv1",
        choices=["TLSv1", "SSLv3"],
        field="MinimumProtocolVersion",
    )
Esempio n. 11
0
class DefaultCacheBehavior(Resource):

    resource_name = "default_cache_behaviour"
    dot_ignore = True

    extra_serializers = {
        # TrustedSigners are not supported yet, so include stub in serialized form
        "TrustedSigners":
        serializers.Const({
            "Enabled": False,
            "Quantity": 0,
        }),
        "AllowedMethods":
        CloudFrontList(
            inner=serializers.Context(serializers.Argument("allowed_methods"),
                                      serializers.List()),
            CachedMethods=serializers.Context(
                serializers.Argument("cached_methods"), CloudFrontList()),
        ),
    }

    target_origin = argument.String(field='TargetOriginId')
    forwarded_values = argument.Resource(
        ForwardedValues,
        default=lambda instance: dict(),
        field="ForwardedValues",
        serializer=serializers.Resource(),
    )
    viewer_protocol_policy = argument.String(
        choices=['allow-all', 'https-only', 'redirect-to-https'],
        default='allow-all',
        field="ViewerProtocolPolicy")
    min_ttl = argument.Integer(default=0, field="MinTTL")
    allowed_methods = argument.List(default=lambda x: ["GET", "HEAD"])
    cached_methods = argument.List(default=lambda x: ["GET", "HEAD"])
    smooth_streaming = argument.Boolean(default=False, field='SmoothStreaming')
Esempio n. 12
0
 def test_bool_false(self):
     self.assertEqual(argument.Boolean().clean(None, "off"), False)
     self.assertEqual(argument.Boolean().clean(None, "no"), False)
     self.assertEqual(argument.Boolean().clean(None, "0"), False)
     self.assertEqual(argument.Boolean().clean(None, "false"), False)
Esempio n. 13
0
 def test_bool_true(self):
     self.assertEqual(argument.Boolean().clean(None, "on"), True)
     self.assertEqual(argument.Boolean().clean(None, "yes"), True)
     self.assertEqual(argument.Boolean().clean(None, "1"), True)
     self.assertEqual(argument.Boolean().clean(None, "true"), True)
Esempio n. 14
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)