Repository: getmoto/moto
Pull request #7134 (2023-12-18 11:27:26)

EC2: Fix invalid value for NetworkInfo.EnaSupport
This PR fixes an incorrect dict key and adds valid fallback value for the response field [`EnaSupport`](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_NetworkInfo.html) for the `DescribeInstanceTypes` API operation.

See https://github.com/localstack/localstack/issues/9854

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) Report
Attention: `3 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`2b077a2`)](https://app.codecov.io/gh/getmoto/moto/commit/2b077a2ccaa85a430725025c857b1bbcdf8504c0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) 95.88% compared to head [(`4f3c7b5`)](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) 95.88%.
> Report is 3 commits behind head on master.

| [Files](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Patch % | Lines |
|---|---|---|
| [moto/ec2/models/launch\_templates.py](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#diff-bW90by9lYzIvbW9kZWxzL2xhdW5jaF90ZW1wbGF0ZXMucHk=) | 75.00% | [3 Missing :warning: ](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #7134      +/-   ##
==========================================
- Coverage   95.88%   95.88%   -0.01%     
==========================================
  Files         834      834              
  Lines       82221    82233      +12     
==========================================
+ Hits        78838    78846       +8     
- Misses       3383     3387       +4     
```

| [Flag](https://app.codecov.io/gh/getmoto/moto/pull/7134/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | |
|---|---|---|
| [servertests](https://app.codecov.io/gh/getmoto/moto/pull/7134/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `35.79% <30.76%> (-0.01%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/getmoto/moto/pull/7134/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `95.82% <76.92%> (-0.01%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#carryforward-flags-in-the-pull-request-comment) to find out more.


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/getmoto/moto/pull/7134?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto).


Patch:
diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py
index acadb8816..f1ccff666 100644
--- a/moto/ec2/responses/instances.py
+++ b/moto/ec2/responses/instances.py
@@ -850,7 +850,7 @@ EC2_DESCRIBE_INSTANCE_TYPES = """<?xml version="1.0" encoding="UTF-8"?>
                 <defaultNetworkCardIndex>{{ instance_type.get('NetworkInfo', {}).get('DefaultNetworkCardIndex', 0) | int }}</defaultNetworkCardIndex>
                 <efaSupported>{{ instance_type.get('NetworkInfo', {}).get('EfaSupported', False) }}</efaSupported>
                 <enaSrdSupported>{{ instance_type.get('NetworkInfo', {}).get('EnaSrdSupported', False) }}</enaSrdSupported>
-                <enaSupport>{{ instance_type.get('NetworkInfo', {}).get('EnaSupported', False) }}</enaSupport>
+                <enaSupport>{{ instance_type.get('NetworkInfo', {}).get('EnaSupport', 'unsupported') }}</enaSupport>
                 <encryptionInTransitSupported>{{ instance_type.get('NetworkInfo', {}).get('EncryptionInTransitSupported', False) }}</encryptionInTransitSupported>
                 <ipv4AddressesPerInterface>{{ instance_type.get('NetworkInfo', {}).get('Ipv4AddressesPerInterface', 0) | int }}</ipv4AddressesPerInterface>
                 <ipv6AddressesPerInterface>{{ instance_type.get('NetworkInfo', {}).get('Ipv6AddressesPerInterface', 0) | int }}</ipv6AddressesPerInterface>


Test patch:
diff --git a/tests/test_ec2/test_instance_types.py b/tests/test_ec2/test_instance_types.py
index 18215cdc3..d4c8d5508 100644
--- a/tests/test_ec2/test_instance_types.py
+++ b/tests/test_ec2/test_instance_types.py
@@ -14,6 +14,11 @@ def test_describe_instance_types():
     assert "InstanceType" in instance_types["InstanceTypes"][0]
     assert "SizeInMiB" in instance_types["InstanceTypes"][0]["MemoryInfo"]
 
+    ena_support = set(
+        t["NetworkInfo"]["EnaSupport"] for t in instance_types["InstanceTypes"]
+    )
+    assert ena_support == {"required", "unsupported", "supported"}
+
 
 @mock_ec2
 def test_describe_instance_types_filter_by_type():