Repository: getmoto/moto
Pull request #7004 (2023-11-09 08:10:50)

EC2: Fix VPC endpoint default policy
This PR fixes a bad key in default policy for VPC endpoints.


Patch:
diff --git a/moto/ec2/models/vpcs.py b/moto/ec2/models/vpcs.py
index 73ae96e8b..f0da5bc27 100644
--- a/moto/ec2/models/vpcs.py
+++ b/moto/ec2/models/vpcs.py
@@ -43,7 +43,7 @@ class VPCEndPoint(TaggedEC2Resource, CloudFormationModel):
 
     DEFAULT_POLICY = {
         "Version": "2008-10-17",
-        "Statement ": [
+        "Statement": [
             {"Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*"}
         ],
     }
diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py
index 4bded43bb..9af62bab8 100644
--- a/moto/ec2/responses/instances.py
+++ b/moto/ec2/responses/instances.py
@@ -823,16 +823,94 @@ EC2_INSTANCE_STATUS = """<?xml version="1.0" encoding="UTF-8"?>
 </DescribeInstanceStatusResponse>"""
 
 EC2_DESCRIBE_INSTANCE_TYPES = """<?xml version="1.0" encoding="UTF-8"?>
-<DescribeInstanceTypesResponse xmlns="http://api.outscale.com/wsdl/fcuext/2014-04-15/">
+<DescribeInstanceTypesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
     <requestId>f8b86168-d034-4e65-b48d-3b84c78e64af</requestId>
     <instanceTypeSet>
     {% for instance_type in instance_types %}
         <item>
+            <autoRecoverySupported>{{ instance_type.AutoRecoverySupported }}</autoRecoverySupported>
+            <bareMetal>{{ instance_type.BareMetal }}</bareMetal>
+            <burstablePerformanceSupported>{{ instance_type.BurstablePerformanceSupported }}</burstablePerformanceSupported>
+            <currentGeneration>{{ instance_type.CurrentGeneration }}</currentGeneration>
+            <dedicatedHostsSupported>{{ instance_type.DedicatedHostsSupported }}</dedicatedHostsSupported>
+            <ebsInfo>
+                <ebsOptimizedInfo>
+                    <baselineBandwidthInMbps>{{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineBandwidthInMbps', 0) | int }}</baselineBandwidthInMbps>
+                    <baselineIops>{{  instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineIops', 0) | int }}</baselineIops>
+                    <baselineThroughputInMBps>{{  instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineThroughputInMBps', 0.0) | float }}</baselineThroughputInMBps>
+                    <maximumBandwidthInMbps>{{  instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumBandwidthInMbps', 0) | int }}</maximumBandwidthInMbps>
+                    <maximumIops>{{  instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumIops', 0) | int }}</maximumIops>
+                    <maximumThroughputInMBps>{{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumThroughputInMBps', 0.0) | float }}</maximumThroughputInMBps>
+                </ebsOptimizedInfo>
+                <ebsOptimizedSupport>{{ instance_type.get('EbsInfo', {}).get('EbsOptimizedSupport', 'default') }}</ebsOptimizedSupport>
+                <encryptionSupport>{{ instance_type.get('EbsInfo', {}).get('EncryptionSupport', 'supported') }}</encryptionSupport>
+                <nvmeSupport>{{ instance_type.get('EbsInfo', {}).get('NvmeSupport', 'required') }}</nvmeSupport>
+            </ebsInfo>
+            <networkInfo>
+                <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>
+                <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>
+                <ipv6Supported>{{ instance_type.get('NetworkInfo', {}).get('Ipv6Supported', False) }}</ipv6Supported>
+                <maximumNetworkCards>{{ instance_type.get('NetworkInfo', {}).get('MaximumNetworkCards', 0) | int }}</maximumNetworkCards>
+                <maximumNetworkInterfaces>{{ instance_type.get('NetworkInfo', {}).get('MaximumNetworkInterfaces', 0) | int }}</maximumNetworkInterfaces>
+                <networkCards>
+                  {% for network_card in instance_type.get('NetworkInfo', {}).get('NetworkCards', []) %}
+                    <item>
+                        <baselineBandwidthInGbps>{{ network_card.get('BaselineBandwidthInGbps', 0.0) | float }}</baselineBandwidthInGbps>
+                        <maximumNetworkInterfaces>{{ network_card.get('MaximumNetworkInterfaces', 0) | int }}</maximumNetworkInterfaces>
+                        <networkCardIndex>{{ network_card.get('NetworkCardIndex', 0) | int }}</networkCardIndex>
+                        <networkPerformance>{{ network_card.get('NetworkPerformance', 'Up to 25 Schmeckles') }}</networkPerformance>
+                        <peakBandwidthInGbps>{{ network_card.get('PeakBandwidthInGbps', 0.0) | float }}</peakBandwidthInGbps>
+                    </item>
+                  {% endfor %}
+                </networkCards>
+                <networkPerformance>{{ instance_type.get('NetworkInfo', {}).get('NetworkPerformance', 'Up to 25 Schmeckles') }}</networkPerformance>
+            </networkInfo>
+            <freeTierEligible>{{ instance_type.FreeTierEligible }}</freeTierEligible>
+            <hibernationSupported>{{ instance_type.HibernationSupported }}</hibernationSupported>
+            <hypervisor>{{ instance_type.get('Hypervisor', 'motovisor') }}</hypervisor>
+            <instanceStorageSupported>{{ instance_type.InstanceStorageSupported }}</instanceStorageSupported>
+            <placementGroupInfo>
+                <supportedStrategies>
+                  {% for strategy in instance_type.get('PlacementGroupInfo', {}).get('SupportedStrategies', []) %}
+                    <item>{{ strategy }}</item>
+                  {% endfor %}
+                </supportedStrategies>
+            </placementGroupInfo>
+            <supportedRootDeviceTypes>
+              {% for dev_type in instance_type.get('SupportedRootDeviceTypes', []) %}
+                <item>{{ dev_type }}</item>
+              {% endfor %}
+            </supportedRootDeviceTypes>
+            <supportedUsageClasses>
+              {% for usage_class in instance_type.get('SupportedUsageClasses', []) %}
+                <item>{{ usage_class }}</item>
+              {% endfor %}
+            </supportedUsageClasses>
+            <supportedVirtualizationTypes>
+              {% for supported_vtype in instance_type.get('SupportedVirtualizationTypes', []) %}
+                <item>{{ supported_vtype }}</item>
+              {% endfor %}
+            </supportedVirtualizationTypes>
             <instanceType>{{ instance_type.InstanceType }}</instanceType>
             <vCpuInfo>
                 <defaultVCpus>{{ instance_type.get('VCpuInfo', {}).get('DefaultVCpus', 0)|int }}</defaultVCpus>
                 <defaultCores>{{ instance_type.get('VCpuInfo', {}).get('DefaultCores', 0)|int }}</defaultCores>
                 <defaultThreadsPerCore>{{ instance_type.get('VCpuInfo').get('DefaultThreadsPerCore', 0)|int }}</defaultThreadsPerCore>
+                <validCores>
+                  {% for valid_core in instance_type.get("VCpuInfo", {}).get('ValidCores', []) %}
+                    <item>{{ valid_core }}</item>
+                  {% endfor %}
+                </validCores>
+                <validThreadsPerCore>
+                  {% for threads_per_core in instance_type.get("VCpuInfo", {}).get('ValidThreadsPerCore', []) %}
+                    <item>{{ threads_per_core }}</item>
+                  {% endfor %}
+                </validThreadsPerCore>
             </vCpuInfo>
             <memoryInfo>
                 <sizeInMiB>{{ instance_type.get('MemoryInfo', {}).get('SizeInMiB', 0)|int }}</sizeInMiB>
@@ -848,6 +926,7 @@ EC2_DESCRIBE_INSTANCE_TYPES = """<?xml version="1.0" encoding="UTF-8"?>
                     </item>
                     {% endfor %}
                 </supportedArchitectures>
+                <sustainedClockSpeedInGhz>{{ instance_type.get('ProcessorInfo', {}).get('SustainedClockSpeedInGhz', 0.0) | float }}</sustainedClockSpeedInGhz>
             </processorInfo>
             {% if instance_type.get('GpuInfo', {})|length > 0 %}
             <gpuInfo>


Test patch:
diff --git a/tests/test_ec2/test_vpcs.py b/tests/test_ec2/test_vpcs.py
index 0849359f3..bb6c320a8 100644
--- a/tests/test_ec2/test_vpcs.py
+++ b/tests/test_ec2/test_vpcs.py
@@ -993,7 +993,7 @@ def test_create_vpc_endpoint__policy():
     # create without policy --> verify the default policy is created
     default_policy = {
         "Version": "2008-10-17",
-        "Statement ": [
+        "Statement": [
             {"Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*"}
         ],
     }