diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 118fc680..c35fa339 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -2901,7 +2901,7 @@ class VPCBackend(object): #validates if vpc is present or not. self.get_vpc(vpc_id) - if type == "interface" or "Interface ": + if type and type.lower() == "interface": network_interface_ids = [] for subnet_id in subnet_ids: @@ -2920,6 +2920,8 @@ class VPCBackend(object): route_table_id, service_destination_cidr ) + if dns_entries: + dns_entries = [dns_entries] vpc_end_point = VPCEndPoint( vpc_endpoint_id, @@ -2930,7 +2932,7 @@ class VPCBackend(object): route_table_ids, subnet_ids, network_interface_ids, - [dns_entries], + dns_entries, client_token, security_group, tag_specifications, diff --git a/moto/ec2/responses/vpcs.py b/moto/ec2/responses/vpcs.py index 2af4c0b2..4b0aa76d 100644 --- a/moto/ec2/responses/vpcs.py +++ b/moto/ec2/responses/vpcs.py @@ -439,12 +439,14 @@ CREATE_VPC_END_POINT = """ {{ entry["dns_name"] }} {% endfor %} + {% endif %} {{ vpc_end_point.created_at }} diff --git a/tests/test_ec2/test_route_tables.py b/tests/test_ec2/test_route_tables.py index 182776f9..f8be8dc8 100644 --- a/tests/test_ec2/test_route_tables.py +++ b/tests/test_ec2/test_route_tables.py @@ -630,6 +630,7 @@ def test_create_vpc_end_point(): route_table = ec2.create_route_table(VpcId=vpc["Vpc"]["VpcId"]) + # test without any end point type specified vpc_end_point = ec2.create_vpc_endpoint( VpcId=vpc["Vpc"]["VpcId"], ServiceName="com.amazonaws.us-east-1.s3", @@ -641,7 +642,24 @@ def test_create_vpc_end_point(): 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) + # test with any end point type as gateway + vpc_end_point = ec2.create_vpc_endpoint( + VpcId=vpc["Vpc"]["VpcId"], + ServiceName="com.amazonaws.us-east-1.s3", + RouteTableIds=[route_table["RouteTable"]["RouteTableId"]], + 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"]["VpcId"].should.equal(vpc["Vpc"]["VpcId"]) + vpc_end_point["VpcEndpoint"]["DnsEntries"].should.have.length_of(0) + + # test with end point type as interface vpc_end_point = ec2.create_vpc_endpoint( VpcId=vpc["Vpc"]["VpcId"], ServiceName="com.amazonaws.us-east-1.s3", @@ -654,3 +672,4 @@ def test_create_vpc_end_point(): 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) \ No newline at end of file