From f65d3970aac1173f88cf40716df87ec1618db4c5 Mon Sep 17 00:00:00 2001 From: Brian Pandola Date: Fri, 13 May 2022 18:51:31 -0700 Subject: [PATCH] Add `Ipv6Native` field to ec2:Subnet response templates This is currently just a placeholder because Moto does not yet fully support Ipv6 subnets, but it is included in the Ipv4 subnet responses (set to `False`). --- moto/ec2/models/subnets.py | 3 +++ moto/ec2/responses/subnets.py | 2 ++ tests/test_ec2/test_subnets.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/moto/ec2/models/subnets.py b/moto/ec2/models/subnets.py index ec5b96a7c..73621ce5b 100644 --- a/moto/ec2/models/subnets.py +++ b/moto/ec2/models/subnets.py @@ -59,6 +59,9 @@ class Subnet(TaggedEC2Resource, CloudFormationModel): self._subnet_ips = {} # has IP: instance self.state = "available" + # Placeholder for response templates until Ipv6 support implemented. + self.ipv6_native = False + @property def owner_id(self): return get_account_id() diff --git a/moto/ec2/responses/subnets.py b/moto/ec2/responses/subnets.py index 90269ead4..a82149768 100644 --- a/moto/ec2/responses/subnets.py +++ b/moto/ec2/responses/subnets.py @@ -105,6 +105,7 @@ CREATE_SUBNET_RESPONSE = """ {% endif %} {% endfor %} + {{ 'false' if not subnet.ipv6_native else 'true' }} arn:aws:ec2:{{ subnet._availability_zone.name[0:-1] }}:{{ subnet.owner_id }}:subnet/{{ subnet.id }} {% for tag in subnet.get_tags() %} @@ -156,6 +157,7 @@ DESCRIBE_SUBNETS_RESPONSE = """ {% endfor %} arn:aws:ec2:{{ subnet._availability_zone.name[0:-1] }}:{{ subnet.owner_id }}:subnet/{{ subnet.id }} + {{ 'false' if not subnet.ipv6_native else 'true' }} {% if subnet.get_tags() %} {% for tag in subnet.get_tags() %} diff --git a/tests/test_ec2/test_subnets.py b/tests/test_ec2/test_subnets.py index 21cf97b4c..53ee8a7eb 100644 --- a/tests/test_ec2/test_subnets.py +++ b/tests/test_ec2/test_subnets.py @@ -354,6 +354,7 @@ def test_create_subnet_response_fields(): subnet.should.have.key("MapPublicIpOnLaunch").which.should.equal(False) subnet.should.have.key("OwnerId") subnet.should.have.key("AssignIpv6AddressOnCreation").which.should.equal(False) + subnet.should.have.key("Ipv6Native").which.should.equal(False) subnet_arn = "arn:aws:ec2:{region}:{owner_id}:subnet/{subnet_id}".format( region=subnet["AvailabilityZone"][0:-1], @@ -390,6 +391,7 @@ def test_describe_subnet_response_fields(): subnet.should.have.key("MapPublicIpOnLaunch").which.should.equal(False) subnet.should.have.key("OwnerId") subnet.should.have.key("AssignIpv6AddressOnCreation").which.should.equal(False) + subnet.should.have.key("Ipv6Native").which.should.equal(False) subnet_arn = "arn:aws:ec2:{region}:{owner_id}:subnet/{subnet_id}".format( region=subnet["AvailabilityZone"][0:-1],