From 693bf9e3fde4dc83f2b8d0f5fc7bdbf6a6168436 Mon Sep 17 00:00:00 2001 From: Viren Nadkarni Date: Thu, 9 Nov 2023 20:56:56 +0530 Subject: [PATCH] EC2: Improve DescribeInstanceTypes response (#7003) --- moto/ec2/responses/instances.py | 81 ++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index 4bded43bb434..9af62bab8b07 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -823,16 +823,94 @@ def _convert_to_bool(bool_str: Any) -> bool: # type: ignore[misc] """ EC2_DESCRIBE_INSTANCE_TYPES = """ - + f8b86168-d034-4e65-b48d-3b84c78e64af {% for instance_type in instance_types %} + {{ instance_type.AutoRecoverySupported }} + {{ instance_type.BareMetal }} + {{ instance_type.BurstablePerformanceSupported }} + {{ instance_type.CurrentGeneration }} + {{ instance_type.DedicatedHostsSupported }} + + + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineBandwidthInMbps', 0) | int }} + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineIops', 0) | int }} + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('BaselineThroughputInMBps', 0.0) | float }} + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumBandwidthInMbps', 0) | int }} + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumIops', 0) | int }} + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedInfo', {}).get('MaximumThroughputInMBps', 0.0) | float }} + + {{ instance_type.get('EbsInfo', {}).get('EbsOptimizedSupport', 'default') }} + {{ instance_type.get('EbsInfo', {}).get('EncryptionSupport', 'supported') }} + {{ instance_type.get('EbsInfo', {}).get('NvmeSupport', 'required') }} + + + {{ instance_type.get('NetworkInfo', {}).get('DefaultNetworkCardIndex', 0) | int }} + {{ instance_type.get('NetworkInfo', {}).get('EfaSupported', False) }} + {{ instance_type.get('NetworkInfo', {}).get('EnaSrdSupported', False) }} + {{ instance_type.get('NetworkInfo', {}).get('EnaSupported', False) }} + {{ instance_type.get('NetworkInfo', {}).get('EncryptionInTransitSupported', False) }} + {{ instance_type.get('NetworkInfo', {}).get('Ipv4AddressesPerInterface', 0) | int }} + {{ instance_type.get('NetworkInfo', {}).get('Ipv6AddressesPerInterface', 0) | int }} + {{ instance_type.get('NetworkInfo', {}).get('Ipv6Supported', False) }} + {{ instance_type.get('NetworkInfo', {}).get('MaximumNetworkCards', 0) | int }} + {{ instance_type.get('NetworkInfo', {}).get('MaximumNetworkInterfaces', 0) | int }} + + {% for network_card in instance_type.get('NetworkInfo', {}).get('NetworkCards', []) %} + + {{ network_card.get('BaselineBandwidthInGbps', 0.0) | float }} + {{ network_card.get('MaximumNetworkInterfaces', 0) | int }} + {{ network_card.get('NetworkCardIndex', 0) | int }} + {{ network_card.get('NetworkPerformance', 'Up to 25 Schmeckles') }} + {{ network_card.get('PeakBandwidthInGbps', 0.0) | float }} + + {% endfor %} + + {{ instance_type.get('NetworkInfo', {}).get('NetworkPerformance', 'Up to 25 Schmeckles') }} + + {{ instance_type.FreeTierEligible }} + {{ instance_type.HibernationSupported }} + {{ instance_type.get('Hypervisor', 'motovisor') }} + {{ instance_type.InstanceStorageSupported }} + + + {% for strategy in instance_type.get('PlacementGroupInfo', {}).get('SupportedStrategies', []) %} + {{ strategy }} + {% endfor %} + + + + {% for dev_type in instance_type.get('SupportedRootDeviceTypes', []) %} + {{ dev_type }} + {% endfor %} + + + {% for usage_class in instance_type.get('SupportedUsageClasses', []) %} + {{ usage_class }} + {% endfor %} + + + {% for supported_vtype in instance_type.get('SupportedVirtualizationTypes', []) %} + {{ supported_vtype }} + {% endfor %} + {{ instance_type.InstanceType }} {{ instance_type.get('VCpuInfo', {}).get('DefaultVCpus', 0)|int }} {{ instance_type.get('VCpuInfo', {}).get('DefaultCores', 0)|int }} {{ instance_type.get('VCpuInfo').get('DefaultThreadsPerCore', 0)|int }} + + {% for valid_core in instance_type.get("VCpuInfo", {}).get('ValidCores', []) %} + {{ valid_core }} + {% endfor %} + + + {% for threads_per_core in instance_type.get("VCpuInfo", {}).get('ValidThreadsPerCore', []) %} + {{ threads_per_core }} + {% endfor %} + {{ instance_type.get('MemoryInfo', {}).get('SizeInMiB', 0)|int }} @@ -848,6 +926,7 @@ def _convert_to_bool(bool_str: Any) -> bool: # type: ignore[misc] {% endfor %} + {{ instance_type.get('ProcessorInfo', {}).get('SustainedClockSpeedInGhz', 0.0) | float }} {% if instance_type.get('GpuInfo', {})|length > 0 %}