Beispiel #1
0
class Role(Resource):

    resource_name = "role"

    name = argument.String(field="RoleName")
    path = argument.String(field='Path')
    assume_role_policy = argument.Dict(field="AssumeRolePolicyDocument", serializer=serializers.Json())

    policies = argument.Dict()
    account = argument.Resource(Account)

    def clean_assume_role_policy(self, policy):
        if frozenset(policy.keys()).difference(frozenset(("Version", "Statement"))):
            raise errors.InvalidParameter("Unexpected policy key")

        result = {}
        result['Version'] = policy.get('Version', '2012-10-17')
        result['Statement'] = []
        for statement in policy.get("Statement", []):
            s = {
                "Action": statement["Action"],
                "Effect": statement["Effect"],
                "Principal": statement["Principal"],
                "Sid": statement.get("Sid", ""),
            }
            result['Statement'].append(s)
        return result
Beispiel #2
0
class Pipeline(Resource):

    resource_name = "pipeline"

    name = argument.String(field="Name")
    input_bucket = argument.Resource(Bucket, field="InputBucket")
    output_bucket = argument.Resource(Bucket, field="OutputBucket")
    role = argument.Resource(Role, field="Role")
    # key = argument.Resource(KmsKey, field="AwsKmsKeyArn")
    # notifications = argument.Resource(Topic, field="Notifications")
    content_config = argument.Dict(field="ContentConfig")
    thumbnail_config = argument.Dict(field="ThumbnailConfig")
    account = argument.Resource(Account)
class InternetGateway(Resource):

    resource_name = "internet_gateway"

    name = argument.String()
    tags = argument.Dict()
    vpc = argument.Resource(VPC)
Beispiel #4
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')
Beispiel #5
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")
Beispiel #6
0
class VpnGateway(Resource):

    resource_name = "vpn_gateway"

    name = argument.String()
    type = argument.String(default="ipsec.1",
                           choices=["ipsec.1"],
                           field="Type")
    availability_zone = argument.String(field="AvailabilityZone")
    tags = argument.Dict()
    vpc = argument.Resource(VPC)
class CustomerGateway(Resource):

    resource_name = "customer_gateway"

    name = argument.String()
    type = argument.String(default="ipsec.1",
                           choices=["ipsec.1"],
                           field="GatewayType")
    public_ip = argument.IPAddress(field="PublicIp")
    bgp_asn = argument.Integer(default=65000, field="BgpAsn")
    tags = argument.Dict()
    vpc = argument.Resource(VPC)
Beispiel #8
0
class VPC(Resource):

    resource_name = "vpc"

    name = argument.String()
    cidr_block = argument.IPNetwork(field='CidrBlock')
    tenancy = argument.String(default="default",
                              choices=["default", "dedicated"],
                              field="InstanceTenancy")

    tags = argument.Dict()

    account = argument.Resource(Account)
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")
Beispiel #10
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
Beispiel #11
0
class Subnet(Resource):

    resource_name = "subnet"

    field_order = ["vpc"]

    name = argument.String()
    cidr_block = argument.IPNetwork(field='CidrBlock')
    availability_zone = argument.String(field='AvailabilityZone')
    route_table = argument.Resource(RouteTable)
    network_acl = argument.Resource(NetworkACL)
    tags = argument.Dict()
    vpc = argument.Resource(VPC, field='VpcId')

    def clean_cidr_block(self, cidr_block):
        if not cidr_block in self.vpc.cidr_block:
            raise errors.InvalidParameter("{} not inside network {}".format(
                self.cidr_block, self.vpc.cidr_block))
        return cidr_block
Beispiel #12
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)
 def test_not_a_dict(self):
     self.assertRaises(errors.InvalidParameter,
                       argument.Dict().clean, None, [])
 def test_dict(self):
     self.assertEqual(argument.Dict().clean(None, {}), {})