From a69bad57efe2bd670fa6e8ac0e1fcd983e67e6ba Mon Sep 17 00:00:00 2001 From: Nuwan Goonasekera <2070605+nuwang@users.noreply.github.com> Date: Mon, 23 Nov 2020 15:25:23 +0530 Subject: [PATCH] Added instance type offer filters --- moto/ec2/models.py | 50 + .../resources/instance_type_offerings.json | 2130 +++++++++++++++++ moto/ec2/responses/instances.py | 23 + .../test_ec2/test_instance_type_offerings.py | 58 + 4 files changed, 2261 insertions(+) create mode 100644 moto/ec2/resources/instance_type_offerings.json create mode 100644 tests/test_ec2/test_instance_type_offerings.py diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 9b5e692a7..fbd112101 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -169,6 +169,10 @@ INSTANCE_TYPES = _load_resource( resource_filename(__name__, "resources/instance_types.json") ) +INSTANCE_TYPE_OFFERINGS = _load_resource( + resource_filename(__name__, "resources/instance_type_offerings.json") +) + AMIS = _load_resource( os.environ.get("MOTO_AMIS_PATH") or resource_filename(__name__, "resources/amis.json"), @@ -1122,6 +1126,50 @@ class InstanceBackend(object): return reservations +<<<<<<< HEAD +======= +class InstanceTypeBackend(object): + def __init__(self): + super(InstanceTypeBackend, self).__init__() + + def describe_instance_types(self, instance_types=None): + matches = INSTANCE_TYPES.values() + if instance_types: + matches = [t for t in matches if t.get('apiname') in instance_types] + if len(instance_types) > len(matches): + unknown_ids = set(instance_types) - set(matches) + raise InvalidInstanceTypeError(unknown_ids) + return matches + + +class InstanceTypeOfferingBackend(object): + def __init__(self): + super(InstanceTypeOfferingBackend, self).__init__() + + def describe_instance_type_offerings(self, location_type=None, filters=None): + matches = INSTANCE_TYPE_OFFERINGS + location_type = location_type or "region" + + def matches_filters(offering, filters): + for key, values in filters.items(): + if key == "location": + if location_type in ("availability-zone", "availability-zone-id"): + return offering.get('location') in values + elif location_type == "region": + return any(v for v in values + if offering.get('location').startswith(v)) + else: + return False + elif key == "instance-type": + return offering.get('instance_type') in values + else: + return False + return True + + matches = [o for o in matches if matches_filters(o, filters)] + return matches + + class KeyPair(object): def __init__(self, name, fingerprint, material): self.name = name @@ -6010,6 +6058,8 @@ class IamInstanceProfileAssociationBackend(object): class EC2Backend( BaseBackend, InstanceBackend, + InstanceTypeBackend, + InstanceTypeOfferingBackend, TagBackend, EBSBackend, RegionsAndZonesBackend, diff --git a/moto/ec2/resources/instance_type_offerings.json b/moto/ec2/resources/instance_type_offerings.json new file mode 100644 index 000000000..2048be5f7 --- /dev/null +++ b/moto/ec2/resources/instance_type_offerings.json @@ -0,0 +1,2130 @@ +[ + { + "instance_type": "a1.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "a1.2xlarge", + "location": "us-east-1c" + }, + { + "instance_type": "a1.4xlarge", + "location": "us-west-1a" + }, + { + "instance_type": "a1.4xlarge", + "location": "us-west-1a" + }, + { + "instance_type": "a1.large", + "location": "us-east-1a" + }, + { + "instance_type": "a1.large", + "location": "us-east-1b" + }, + { + "instance_type": "a1.medium", + "location": "us-east-1a" + }, + { + "instance_type": "a1.medium", + "location": "us-east-1b" + }, + { + "instance_type": "a1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "a1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "a1.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "a1.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c1.medium", + "location": "us-east-1a" + }, + { + "instance_type": "c1.medium", + "location": "us-east-1b" + }, + { + "instance_type": "c1.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c1.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c3.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c3.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c3.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c3.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c3.large", + "location": "us-east-1a" + }, + { + "instance_type": "c3.large", + "location": "us-east-1b" + }, + { + "instance_type": "c3.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c3.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c4.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c4.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c4.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c4.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c4.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c4.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c4.large", + "location": "us-east-1a" + }, + { + "instance_type": "c4.large", + "location": "us-east-1b" + }, + { + "instance_type": "c4.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c4.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.18xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.18xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.9xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.9xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5.large", + "location": "us-east-1a" + }, + { + "instance_type": "c5.large", + "location": "us-east-1b" + }, + { + "instance_type": "c5.metal", + "location": "us-east-1a" + }, + { + "instance_type": "c5.metal", + "location": "us-east-1b" + }, + { + "instance_type": "c5.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.18xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.18xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.9xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.9xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.large", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.large", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.metal", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.metal", + "location": "us-east-1b" + }, + { + "instance_type": "c5d.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5d.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.18xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.18xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.9xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.9xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.large", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.large", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.metal", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.metal", + "location": "us-east-1b" + }, + { + "instance_type": "c5n.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "c5n.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "cc2.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "cc2.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "cr1.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "cr1.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "d2.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "d2.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "d2.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "d2.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "d2.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "d2.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "d2.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "d2.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "f1.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "f1.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "f1.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "f1.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "f1.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "f1.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g2.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g2.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g2.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g2.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g3.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g3.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g3.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g3.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g3.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g3.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g3s.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g3s.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.metal", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.metal", + "location": "us-east-1b" + }, + { + "instance_type": "g4dn.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "g4dn.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "h1.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "h1.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "h1.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "h1.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "h1.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "h1.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "h1.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "h1.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "hs1.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "hs1.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i2.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i2.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i2.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i2.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i2.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i2.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i2.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i2.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3.large", + "location": "us-east-1a" + }, + { + "instance_type": "i3.large", + "location": "us-east-1b" + }, + { + "instance_type": "i3.metal", + "location": "us-east-1a" + }, + { + "instance_type": "i3.metal", + "location": "us-east-1b" + }, + { + "instance_type": "i3.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.3xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.3xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.6xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.6xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.large", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.large", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.metal", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.metal", + "location": "us-east-1b" + }, + { + "instance_type": "i3en.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "i3en.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m1.large", + "location": "us-east-1a" + }, + { + "instance_type": "m1.large", + "location": "us-east-1b" + }, + { + "instance_type": "m1.medium", + "location": "us-east-1a" + }, + { + "instance_type": "m1.medium", + "location": "us-east-1b" + }, + { + "instance_type": "m1.small", + "location": "us-east-1a" + }, + { + "instance_type": "m1.small", + "location": "us-east-1b" + }, + { + "instance_type": "m1.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m1.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m2.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m2.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m2.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m2.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m2.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m2.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m3.large", + "location": "us-east-1a" + }, + { + "instance_type": "m3.large", + "location": "us-east-1b" + }, + { + "instance_type": "m3.medium", + "location": "us-east-1a" + }, + { + "instance_type": "m3.medium", + "location": "us-east-1b" + }, + { + "instance_type": "m3.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m3.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m4.10xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m4.10xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m4.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m4.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m4.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m4.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m4.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m4.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m4.large", + "location": "us-east-1a" + }, + { + "instance_type": "m4.large", + "location": "us-east-1b" + }, + { + "instance_type": "m4.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m4.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5.metal", + "location": "us-east-1a" + }, + { + "instance_type": "m5.metal", + "location": "us-east-1b" + }, + { + "instance_type": "m5.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5a.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5a.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5ad.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5ad.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.metal", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.metal", + "location": "us-east-1b" + }, + { + "instance_type": "m5d.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5d.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.metal", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.metal", + "location": "us-east-1b" + }, + { + "instance_type": "m5dn.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5dn.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.large", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.large", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.metal", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.metal", + "location": "us-east-1b" + }, + { + "instance_type": "m5n.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "m5n.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p2.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p2.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p2.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p2.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p2.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p2.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p3.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p3.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p3.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p3.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "p3dn.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "p3dn.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r3.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r3.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r3.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r3.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r3.large", + "location": "us-east-1a" + }, + { + "instance_type": "r3.large", + "location": "us-east-1b" + }, + { + "instance_type": "r3.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r3.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r4.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r4.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r4.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r4.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r4.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r4.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r4.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r4.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r4.large", + "location": "us-east-1a" + }, + { + "instance_type": "r4.large", + "location": "us-east-1b" + }, + { + "instance_type": "r4.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r4.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5.metal", + "location": "us-east-1a" + }, + { + "instance_type": "r5.metal", + "location": "us-east-1b" + }, + { + "instance_type": "r5.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5a.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5a.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5ad.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5ad.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.metal", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.metal", + "location": "us-east-1b" + }, + { + "instance_type": "r5d.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5d.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.metal", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.metal", + "location": "us-east-1b" + }, + { + "instance_type": "r5dn.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5dn.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.24xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.24xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.large", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.large", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.metal", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.metal", + "location": "us-east-1b" + }, + { + "instance_type": "r5n.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "r5n.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t1.micro", + "location": "us-east-1a" + }, + { + "instance_type": "t1.micro", + "location": "us-east-1b" + }, + { + "instance_type": "t2.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t2.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t2.large", + "location": "us-east-1a" + }, + { + "instance_type": "t2.large", + "location": "us-east-1b" + }, + { + "instance_type": "t2.medium", + "location": "us-east-1a" + }, + { + "instance_type": "t2.medium", + "location": "us-east-1b" + }, + { + "instance_type": "t2.micro", + "location": "us-east-1a" + }, + { + "instance_type": "t2.micro", + "location": "us-east-1b" + }, + { + "instance_type": "t2.nano", + "location": "us-east-1a" + }, + { + "instance_type": "t2.nano", + "location": "us-east-1b" + }, + { + "instance_type": "t2.small", + "location": "us-east-1a" + }, + { + "instance_type": "t2.small", + "location": "us-east-1b" + }, + { + "instance_type": "t2.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t2.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t3.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t3.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t3.large", + "location": "us-east-1a" + }, + { + "instance_type": "t3.large", + "location": "us-east-1b" + }, + { + "instance_type": "t3.medium", + "location": "us-east-1a" + }, + { + "instance_type": "t3.medium", + "location": "us-east-1b" + }, + { + "instance_type": "t3.micro", + "location": "us-east-1a" + }, + { + "instance_type": "t3.micro", + "location": "us-east-1b" + }, + { + "instance_type": "t3.nano", + "location": "us-east-1a" + }, + { + "instance_type": "t3.nano", + "location": "us-east-1b" + }, + { + "instance_type": "t3.small", + "location": "us-east-1a" + }, + { + "instance_type": "t3.small", + "location": "us-east-1b" + }, + { + "instance_type": "t3.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t3.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.large", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.large", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.medium", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.medium", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.micro", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.micro", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.nano", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.nano", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.small", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.small", + "location": "us-east-1b" + }, + { + "instance_type": "t3a.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "t3a.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "u-12tb1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "u-12tb1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "u-18tb1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "u-18tb1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "u-24tb1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "u-24tb1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "u-6tb1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "u-6tb1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "u-9tb1.metal", + "location": "us-east-1a" + }, + { + "instance_type": "u-9tb1.metal", + "location": "us-east-1b" + }, + { + "instance_type": "x1.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1.32xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1.32xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.16xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.16xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.32xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.32xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.4xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.4xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.8xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.8xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "x1e.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "x1e.xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.12xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.12xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.2xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.2xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.3xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.3xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.6xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.6xlarge", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.large", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.large", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.metal", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.metal", + "location": "us-east-1b" + }, + { + "instance_type": "z1d.xlarge", + "location": "us-east-1a" + }, + { + "instance_type": "z1d.xlarge", + "location": "us-east-1b" + } +] \ No newline at end of file diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index e9843399f..ef45ee47a 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -150,6 +150,14 @@ class InstanceResponse(BaseResponse): template = self.response_template(EC2_DESCRIBE_INSTANCE_TYPES) return template.render(instance_types=instance_types) + def describe_instance_type_offerings(self): + location_type_filters = self._get_multi_param("LocationType") + filter_dict = filters_from_querystring(self.querystring) + offerings = self.ec2_backend.describe_instance_type_offerings( + location_type_filters, filter_dict) + template = self.response_template(EC2_DESCRIBE_INSTANCE_TYPE_OFFERINGS) + return template.render(instance_type_offerings=offerings) + def describe_instance_attribute(self): # TODO this and modify below should raise IncorrectInstanceState if # instance not in stopped state @@ -841,3 +849,18 @@ EC2_DESCRIBE_INSTANCE_TYPES = """ {% endfor %} """ + + +EC2_DESCRIBE_INSTANCE_TYPE_OFFERINGS = """ + + f8b86168-d034-4e65-b48d-3b84c78e64af + + {% for offering in instance_type_offerings %} + + {{ offering.instance_type }} + {{ offering.location }} + {{ offering.location_type }} + + {% endfor %} + +""" \ No newline at end of file diff --git a/tests/test_ec2/test_instance_type_offerings.py b/tests/test_ec2/test_instance_type_offerings.py new file mode 100644 index 000000000..2b33f55df --- /dev/null +++ b/tests/test_ec2/test_instance_type_offerings.py @@ -0,0 +1,58 @@ +from __future__ import unicode_literals + +import boto3 +import sure # noqa + +from moto import mock_ec2 + + +@mock_ec2 +def test_describe_instance_type_offerings(): + client = boto3.client("ec2", "us-east-1") + offerings = client.describe_instance_type_offerings() + + offerings.should.have.key("InstanceTypeOfferings") + offerings["InstanceTypeOfferings"].should_not.be.empty + offerings["InstanceTypeOfferings"][0].should.have.key("InstanceType") + offerings["InstanceTypeOfferings"][0].should.have.key("Location") + offerings["InstanceTypeOfferings"][0].should.have.key("LocationType") + + +@mock_ec2 +def test_describe_instance_type_offering_filter_by_type(): + client = boto3.client("ec2", "us-east-1") + offerings = client.describe_instance_type_offerings( + Filters=[{"Name": "instance-type", "Values": ["t2.nano"]}]) + + offerings.should.have.key("InstanceTypeOfferings") + offerings["InstanceTypeOfferings"].should_not.be.empty + offerings["InstanceTypeOfferings"].should.have.length_of(2) + offerings["InstanceTypeOfferings"][0]['InstanceType'].should.equal('t2.nano') + offerings["InstanceTypeOfferings"][-1]['InstanceType'].should.equal('t2.nano') + offerings["InstanceTypeOfferings"][0]['Location'].should.equal('us-east-1a') + + +@mock_ec2 +def test_describe_instance_type_offering_filter_by_zone(): + client = boto3.client("ec2", "us-east-1") + offerings = client.describe_instance_type_offerings( + Filters=[{"Name": "location", "Values": ["us-east-1c"]}]) + + offerings.should.have.key("InstanceTypeOfferings") + offerings["InstanceTypeOfferings"].should_not.be.empty + offerings["InstanceTypeOfferings"].should.have.length_of(1) + offerings["InstanceTypeOfferings"][0]['InstanceType'].should.equal('a1.2xlarge') + offerings["InstanceTypeOfferings"][0]['Location'].should.equal('us-east-1c') + + +@mock_ec2 +def test_describe_instance_type_offering_filter_by_region(): + client = boto3.client("ec2", "us-east-1") + offerings = client.describe_instance_type_offerings( + LocationType="region", Filters=[{"Name": "location", "Values": ["us-west-1"]}]) + + offerings.should.have.key("InstanceTypeOfferings") + offerings["InstanceTypeOfferings"].should_not.be.empty + offerings["InstanceTypeOfferings"].should.have.length_of(2) + offerings["InstanceTypeOfferings"][0]['InstanceType'].should.equal('a1.4xlarge') + offerings["InstanceTypeOfferings"][0]['Location'].should.equal('us-west-1a')