Repository: getmoto/moto

Issue:
Moto missing new EC2 Subnet attribute "Ipv6Native"
The EC2 Subnet data model was updated to support the launch of IPv6-only subnets as seen in the `Response Syntax` here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_subnets

As part of this release a new attribute was added to indicate that a subnet is IPv6 only.

While it would be nice to add full support for ipv6 only subnets to moto over time, in the short term it would be great if the relevant describe responses included this new attribute with value set to False


Discussion:
Hi @davidaah, thanks for raising this - will mark it as an enhancement.

If you want to contribute this to Moto, PR's are always welcome!

Patch:
diff --git a/moto/ec2/models/subnets.py b/moto/ec2/models/subnets.py
--- a/moto/ec2/models/subnets.py
+++ b/moto/ec2/models/subnets.py
@@ -59,6 +59,9 @@ def __init__(
         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
--- a/moto/ec2/responses/subnets.py
+++ b/moto/ec2/responses/subnets.py
@@ -105,6 +105,7 @@ def disassociate_subnet_cidr_block(self):
     {% endif %}
     {% endfor %}
     </ipv6CidrBlockAssociationSet>
+    <ipv6Native>{{ 'false' if not subnet.ipv6_native else 'true' }}</ipv6Native>
     <subnetArn>arn:aws:ec2:{{ subnet._availability_zone.name[0:-1] }}:{{ subnet.owner_id }}:subnet/{{ subnet.id }}</subnetArn>
     <tagSet>
         {% for tag in subnet.get_tags() %}
@@ -156,6 +157,7 @@ def disassociate_subnet_cidr_block(self):
         {% endfor %}
         </ipv6CidrBlockAssociationSet>
         <subnetArn>arn:aws:ec2:{{ subnet._availability_zone.name[0:-1] }}:{{ subnet.owner_id }}:subnet/{{ subnet.id }}</subnetArn>
+        <ipv6Native>{{ 'false' if not subnet.ipv6_native else 'true' }}</ipv6Native>
         {% if subnet.get_tags() %}
           <tagSet>
             {% for tag in subnet.get_tags() %}


Test patch:
diff --git a/tests/test_ec2/test_subnets.py b/tests/test_ec2/test_subnets.py
--- 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],