Linting
This commit is contained in:
parent
f4888da334
commit
2d0087d500
@ -2881,24 +2881,25 @@ class VPCBackend(object):
|
||||
vpc = self.get_vpc(vpc_id)
|
||||
return vpc.associate_vpc_cidr_block(cidr_block, amazon_provided_ipv6_cidr_block)
|
||||
|
||||
def create_vpc_endpoint(self,
|
||||
vpc_id,
|
||||
service_name,
|
||||
type=None,
|
||||
policy_document=False,
|
||||
route_table_ids=None,
|
||||
subnet_ids=[],
|
||||
network_interface_ids=[],
|
||||
dns_entries=None,
|
||||
client_token=None,
|
||||
security_group=None,
|
||||
tag_specifications=None,
|
||||
private_dns_enabled=None
|
||||
):
|
||||
def create_vpc_endpoint(
|
||||
self,
|
||||
vpc_id,
|
||||
service_name,
|
||||
type=None,
|
||||
policy_document=False,
|
||||
route_table_ids=None,
|
||||
subnet_ids=[],
|
||||
network_interface_ids=[],
|
||||
dns_entries=None,
|
||||
client_token=None,
|
||||
security_group=None,
|
||||
tag_specifications=None,
|
||||
private_dns_enabled=None,
|
||||
):
|
||||
|
||||
vpc_endpoint_id = generate_vpc_end_point_id(vpc_id)
|
||||
|
||||
#validates if vpc is present or not.
|
||||
# validates if vpc is present or not.
|
||||
self.get_vpc(vpc_id)
|
||||
|
||||
if type and type.lower() == "interface":
|
||||
@ -2911,15 +2912,12 @@ class VPCBackend(object):
|
||||
|
||||
dns_entries = create_dns_entries(service_name, vpc_endpoint_id)
|
||||
|
||||
else :
|
||||
else:
|
||||
# considering gateway if type is not mentioned.
|
||||
service_destination_cidr = randor_ipv4_cidr()
|
||||
|
||||
for route_table_id in route_table_ids:
|
||||
self.create_route(
|
||||
route_table_id,
|
||||
service_destination_cidr
|
||||
)
|
||||
self.create_route(route_table_id, service_destination_cidr)
|
||||
if dns_entries:
|
||||
dns_entries = [dns_entries]
|
||||
|
||||
@ -2936,7 +2934,7 @@ class VPCBackend(object):
|
||||
client_token,
|
||||
security_group,
|
||||
tag_specifications,
|
||||
private_dns_enabled
|
||||
private_dns_enabled,
|
||||
)
|
||||
|
||||
self.vpc_end_points[vpc_endpoint_id] = vpc_end_point
|
||||
@ -3560,7 +3558,7 @@ class VPCEndPoint(TaggedEC2Resource):
|
||||
type=None,
|
||||
policy_document=False,
|
||||
route_table_ids=None,
|
||||
subnet_ids =None,
|
||||
subnet_ids=None,
|
||||
network_interface_ids=None,
|
||||
dns_entries=None,
|
||||
client_token=None,
|
||||
|
@ -176,22 +176,20 @@ class VPCs(BaseResponse):
|
||||
security_group = self._get_param("SecurityGroup")
|
||||
|
||||
vpc_end_point = self.ec2_backend.create_vpc_endpoint(
|
||||
vpc_id=vpc_id,
|
||||
service_name=service_name,
|
||||
type=type,
|
||||
policy_document=policy_document,
|
||||
route_table_ids=route_table_ids,
|
||||
subnet_ids=subnet_ids,
|
||||
client_token=client_token,
|
||||
security_group=security_group,
|
||||
tag_specifications=tag_specifications,
|
||||
private_dns_enabled=private_dns_enabled
|
||||
vpc_id=vpc_id,
|
||||
service_name=service_name,
|
||||
type=type,
|
||||
policy_document=policy_document,
|
||||
route_table_ids=route_table_ids,
|
||||
subnet_ids=subnet_ids,
|
||||
client_token=client_token,
|
||||
security_group=security_group,
|
||||
tag_specifications=tag_specifications,
|
||||
private_dns_enabled=private_dns_enabled,
|
||||
)
|
||||
|
||||
template = self.response_template(CREATE_VPC_END_POINT)
|
||||
return template.render(
|
||||
vpc_end_point=vpc_end_point
|
||||
)
|
||||
return template.render(vpc_end_point=vpc_end_point)
|
||||
|
||||
|
||||
CREATE_VPC_RESPONSE = """
|
||||
@ -450,4 +448,4 @@ CREATE_VPC_END_POINT = """ <CreateVpcEndpointResponse xmlns="http://monitoring.a
|
||||
</dnsEntrySet>
|
||||
<creationTimestamp>{{ vpc_end_point.created_at }}</creationTimestamp>
|
||||
</vpcEndpoint>
|
||||
</CreateVpcEndpointResponse>"""
|
||||
</CreateVpcEndpointResponse>"""
|
||||
|
@ -194,13 +194,14 @@ def generate_route_id(route_table_id, cidr_block):
|
||||
|
||||
|
||||
def generate_vpc_end_point_id(vpc_id):
|
||||
return "%s-%s" % ('vpce', vpc_id[4:])
|
||||
return "%s-%s" % ("vpce", vpc_id[4:])
|
||||
|
||||
|
||||
def create_dns_entries(service_name, vpc_endpoint_id):
|
||||
dns_entries = {}
|
||||
dns_entries["dns_name"] = "{}-{}.{}".format(vpc_endpoint_id,
|
||||
random_resource_id(8), service_name)
|
||||
dns_entries["dns_name"] = "{}-{}.{}".format(
|
||||
vpc_endpoint_id, random_resource_id(8), service_name
|
||||
)
|
||||
dns_entries["hosted_zone_id"] = random_resource_id(13).upper()
|
||||
return dns_entries
|
||||
|
||||
|
@ -625,8 +625,7 @@ def test_create_vpc_end_point():
|
||||
|
||||
ec2 = boto3.client("ec2", region_name="us-west-1")
|
||||
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
|
||||
subnet = ec2.create_subnet(VpcId=vpc["Vpc"]["VpcId"],
|
||||
CidrBlock="10.0.0.0/24")
|
||||
subnet = ec2.create_subnet(VpcId=vpc["Vpc"]["VpcId"], CidrBlock="10.0.0.0/24")
|
||||
|
||||
route_table = ec2.create_route_table(VpcId=vpc["Vpc"]["VpcId"])
|
||||
|
||||
@ -634,13 +633,15 @@ def test_create_vpc_end_point():
|
||||
vpc_end_point = ec2.create_vpc_endpoint(
|
||||
VpcId=vpc["Vpc"]["VpcId"],
|
||||
ServiceName="com.amazonaws.us-east-1.s3",
|
||||
RouteTableIds=[route_table["RouteTable"]["RouteTableId"]]
|
||||
)
|
||||
RouteTableIds=[route_table["RouteTable"]["RouteTableId"]],
|
||||
)
|
||||
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"].\
|
||||
should.equal("com.amazonaws.us-east-1.s3")
|
||||
vpc_end_point["VpcEndpoint"]["RouteTableIds"][0].\
|
||||
should.equal(route_table["RouteTable"]["RouteTableId"])
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"].should.equal(
|
||||
"com.amazonaws.us-east-1.s3"
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["RouteTableIds"][0].should.equal(
|
||||
route_table["RouteTable"]["RouteTableId"]
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["VpcId"].should.equal(vpc["Vpc"]["VpcId"])
|
||||
vpc_end_point["VpcEndpoint"]["DnsEntries"].should.have.length_of(0)
|
||||
|
||||
@ -649,13 +650,15 @@ def test_create_vpc_end_point():
|
||||
VpcId=vpc["Vpc"]["VpcId"],
|
||||
ServiceName="com.amazonaws.us-east-1.s3",
|
||||
RouteTableIds=[route_table["RouteTable"]["RouteTableId"]],
|
||||
VpcEndpointType="gateway"
|
||||
VpcEndpointType="gateway",
|
||||
)
|
||||
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"]. \
|
||||
should.equal("com.amazonaws.us-east-1.s3")
|
||||
vpc_end_point["VpcEndpoint"]["RouteTableIds"][0]. \
|
||||
should.equal(route_table["RouteTable"]["RouteTableId"])
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"].should.equal(
|
||||
"com.amazonaws.us-east-1.s3"
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["RouteTableIds"][0].should.equal(
|
||||
route_table["RouteTable"]["RouteTableId"]
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["VpcId"].should.equal(vpc["Vpc"]["VpcId"])
|
||||
vpc_end_point["VpcEndpoint"]["DnsEntries"].should.have.length_of(0)
|
||||
|
||||
@ -664,12 +667,14 @@ def test_create_vpc_end_point():
|
||||
VpcId=vpc["Vpc"]["VpcId"],
|
||||
ServiceName="com.amazonaws.us-east-1.s3",
|
||||
SubnetIds=[subnet["Subnet"]["SubnetId"]],
|
||||
VpcEndpointType="interface"
|
||||
VpcEndpointType="interface",
|
||||
)
|
||||
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"].\
|
||||
should.equal("com.amazonaws.us-east-1.s3")
|
||||
vpc_end_point["VpcEndpoint"]["SubnetIds"][0].\
|
||||
should.equal(subnet["Subnet"]["SubnetId"])
|
||||
vpc_end_point["VpcEndpoint"]["ServiceName"].should.equal(
|
||||
"com.amazonaws.us-east-1.s3"
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["SubnetIds"][0].should.equal(
|
||||
subnet["Subnet"]["SubnetId"]
|
||||
)
|
||||
vpc_end_point["VpcEndpoint"]["VpcId"].should.equal(vpc["Vpc"]["VpcId"])
|
||||
len(vpc_end_point["VpcEndpoint"]["DnsEntries"]).should.be.greater_than(0)
|
||||
len(vpc_end_point["VpcEndpoint"]["DnsEntries"]).should.be.greater_than(0)
|
||||
|
Loading…
Reference in New Issue
Block a user