From e061d371c9b15cf6ffabdeda525486c0717db9ed Mon Sep 17 00:00:00 2001 From: Mohit Alonja Date: Fri, 10 Sep 2021 22:51:29 +0530 Subject: [PATCH] Basic requirements VPN GW (#4276) --- moto/ec2/models.py | 3 ++- moto/ec2/responses/virtual_private_gateways.py | 10 +++------- tests/terraform-tests.success.txt | 3 +++ tests/test_ec2/test_virtual_private_gateways.py | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 6c15cf410..99c52b8f0 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -6702,9 +6702,10 @@ class VpnGatewayBackend(object): def detach_vpn_gateway(self, vpn_gateway_id, vpc_id): vpn_gateway = self.get_vpn_gateway(vpn_gateway_id) self.get_vpc(vpc_id) - detached = vpn_gateway.attachments.pop(vpc_id, None) + detached = vpn_gateway.attachments.get(vpc_id, None) if not detached: raise InvalidVPCIdError(vpc_id) + detached.state = "detached" return detached diff --git a/moto/ec2/responses/virtual_private_gateways.py b/moto/ec2/responses/virtual_private_gateways.py index 71960f27e..1d2d325eb 100644 --- a/moto/ec2/responses/virtual_private_gateways.py +++ b/moto/ec2/responses/virtual_private_gateways.py @@ -53,15 +53,13 @@ CREATE_VPN_GATEWAY_RESPONSE = """ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE {{ vpn_gateway.id }} - available + {{ vpn_gateway.state }} {{ vpn_gateway.type }} {{ vpn_gateway.availability_zone }} {% for tag in vpn_gateway.get_tags() %} - {{ tag.resource_id }} - {{ tag.resource_type }} {{ tag.key }} {{ tag.value }} @@ -77,9 +75,9 @@ DESCRIBE_VPN_GATEWAYS_RESPONSE = """ {% for vpn_gateway in vpn_gateways %} {{ vpn_gateway.id }} - available + {{ vpn_gateway.state }} {{ vpn_gateway.id }} - us-east-1a + {{ vpn_gateway.availability_zone }} {% for attachment in vpn_gateway.attachments.values() %} @@ -92,8 +90,6 @@ DESCRIBE_VPN_GATEWAYS_RESPONSE = """ {% for tag in vpn_gateway.get_tags() %} - {{ tag.resource_id }} - {{ tag.resource_type }} {{ tag.key }} {{ tag.value }} diff --git a/tests/terraform-tests.success.txt b/tests/terraform-tests.success.txt index c221a2f63..100544d70 100644 --- a/tests/terraform-tests.success.txt +++ b/tests/terraform-tests.success.txt @@ -120,4 +120,7 @@ TestAccAwsEc2ManagedPrefixList TestAccAWSEgressOnlyInternetGateway TestAccAWSSecurityGroup_ TestAccAWSInternetGateway +TestAccAWSVpnGateway_basic +TestAccAWSVpnGateway_delete +TestAccAWSVpnGateway_tags TestAccAWSSecurityGroupRule_ diff --git a/tests/test_ec2/test_virtual_private_gateways.py b/tests/test_ec2/test_virtual_private_gateways.py index 8cc898af5..151f26782 100644 --- a/tests/test_ec2/test_virtual_private_gateways.py +++ b/tests/test_ec2/test_virtual_private_gateways.py @@ -271,4 +271,5 @@ def test_detach_vpn_gateway(): gateway = conn.get_all_vpn_gateways()[0] attachments = gateway.attachments - attachments.should.have.length_of(0) + attachments.should.have.length_of(1) + attachments[0].state.should.equal("detached")