diff --git a/MANIFEST.in b/MANIFEST.in
index cd1f1e886..43e8120e4 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,6 @@
include README.md LICENSE AUTHORS.md
include requirements.txt requirements-dev.txt tox.ini
include moto/ec2/resources/instance_types.json
+include moto/ec2/resources/amis.json
recursive-include moto/templates *
recursive-include tests *
diff --git a/moto/cloudformation/responses.py b/moto/cloudformation/responses.py
index 423cf92c1..a5b251b89 100644
--- a/moto/cloudformation/responses.py
+++ b/moto/cloudformation/responses.py
@@ -19,10 +19,19 @@ class CloudFormationResponse(BaseResponse):
template_url_parts = urlparse(template_url)
if "localhost" in template_url:
bucket_name, key_name = template_url_parts.path.lstrip(
- "/").split("/")
+ "/").split("/", 1)
else:
- bucket_name = template_url_parts.netloc.split(".")[0]
- key_name = template_url_parts.path.lstrip("/")
+ if template_url_parts.netloc.endswith('amazonaws.com') \
+ and template_url_parts.netloc.startswith('s3'):
+ # Handle when S3 url uses amazon url with bucket in path
+ # Also handles getting region as technically s3 is region'd
+
+ # region = template_url.netloc.split('.')[1]
+ bucket_name, key_name = template_url_parts.path.lstrip(
+ "/").split("/", 1)
+ else:
+ bucket_name = template_url_parts.netloc.split(".")[0]
+ key_name = template_url_parts.path.lstrip("/")
key = s3_backend.get_key(bucket_name, key_name)
return key.value.decode("utf-8")
@@ -227,13 +236,13 @@ CREATE_STACK_RESPONSE_TEMPLATE = """
"""
-UPDATE_STACK_RESPONSE_TEMPLATE = """
+UPDATE_STACK_RESPONSE_TEMPLATE = """
{{ stack.stack_id }}
- b9b5b068-3a41-11e5-94eb-example
-
+ b9b4b068-3a41-11e5-94eb-example
+
"""
@@ -399,16 +408,6 @@ GET_TEMPLATE_RESPONSE_TEMPLATE = """
"""
-UPDATE_STACK_RESPONSE_TEMPLATE = """
-
- {{ stack.stack_id }}
-
-
- b9b4b068-3a41-11e5-94eb-example
-
-
-"""
-
DELETE_STACK_RESPONSE_TEMPLATE = """
5ccc7dcd-744c-11e5-be70-example
@@ -416,6 +415,7 @@ DELETE_STACK_RESPONSE_TEMPLATE = """
"""
+
LIST_EXPORTS_RESPONSE = """
diff --git a/moto/ec2/models.py b/moto/ec2/models.py
index 2c76df17b..dfc912ff0 100755
--- a/moto/ec2/models.py
+++ b/moto/ec2/models.py
@@ -6,6 +6,7 @@ import ipaddress
import json
import re
import six
+import warnings
from pkg_resources import resource_filename
import boto.ec2
@@ -45,7 +46,6 @@ from .exceptions import (
InvalidRouteTableIdError,
InvalidRouteError,
InvalidInstanceIdError,
- MalformedAMIIdError,
InvalidAMIIdError,
InvalidAMIAttributeItemValueError,
InvalidSnapshotIdError,
@@ -113,8 +113,12 @@ from .utils import (
tag_filter_matches,
)
-RES_FILE = resource_filename(__name__, 'resources/instance_types.json')
-INSTANCE_TYPES = json.load(open(RES_FILE, 'r'))
+INSTANCE_TYPES = json.load(
+ open(resource_filename(__name__, 'resources/instance_types.json'), 'r')
+)
+AMIS = json.load(
+ open(resource_filename(__name__, 'resources/amis.json'), 'r')
+)
def utc_date_and_time():
@@ -384,6 +388,11 @@ class Instance(TaggedEC2Resource, BotoInstance):
amis = self.ec2_backend.describe_images(filters={'image-id': image_id})
ami = amis[0] if amis else None
+ if ami is None:
+ warnings.warn('Could not find AMI with image-id:{0}, '
+ 'in the near future this will '
+ 'cause an error'.format(image_id),
+ PendingDeprecationWarning)
self.platform = ami.platform if ami else None
self.virtualization_type = ami.virtualization_type if ami else 'paravirtual'
@@ -1001,17 +1010,31 @@ class TagBackend(object):
class Ami(TaggedEC2Resource):
def __init__(self, ec2_backend, ami_id, instance=None, source_ami=None,
- name=None, description=None):
+ name=None, description=None, owner_id=None,
+
+ public=False, virtualization_type=None, architecture=None,
+ state='available', creation_date=None, platform=None,
+ image_type='machine', image_location=None, hypervisor=None,
+ root_device_type=None, root_device_name=None, sriov='simple',
+ region_name='us-east-1a'
+ ):
self.ec2_backend = ec2_backend
self.id = ami_id
- self.state = "available"
+ self.state = state
self.name = name
+ self.image_type = image_type
+ self.image_location = image_location
+ self.owner_id = owner_id
self.description = description
- self.virtualization_type = None
- self.architecture = None
+ self.virtualization_type = virtualization_type
+ self.architecture = architecture
self.kernel_id = None
- self.platform = None
- self.creation_date = utc_date_and_time()
+ self.platform = platform
+ self.hypervisor = hypervisor
+ self.root_device_name = root_device_name
+ self.root_device_type = root_device_type
+ self.sriov = sriov
+ self.creation_date = utc_date_and_time() if creation_date is None else creation_date
if instance:
self.instance = instance
@@ -1039,8 +1062,11 @@ class Ami(TaggedEC2Resource):
self.launch_permission_groups = set()
self.launch_permission_users = set()
+ if public:
+ self.launch_permission_groups.add('all')
+
# AWS auto-creates these, we should reflect the same.
- volume = self.ec2_backend.create_volume(15, "us-east-1a")
+ volume = self.ec2_backend.create_volume(15, region_name)
self.ebs_snapshot = self.ec2_backend.create_snapshot(
volume.id, "Auto-created snapshot for AMI %s" % self.id)
@@ -1067,6 +1093,8 @@ class Ami(TaggedEC2Resource):
return self.state
elif filter_name == 'name':
return self.name
+ elif filter_name == 'owner-id':
+ return self.owner_id
else:
return super(Ami, self).get_filter_value(
filter_name, 'DescribeImages')
@@ -1075,14 +1103,22 @@ class Ami(TaggedEC2Resource):
class AmiBackend(object):
def __init__(self):
self.amis = {}
+
+ self._load_amis()
+
super(AmiBackend, self).__init__()
- def create_image(self, instance_id, name=None, description=None):
+ def _load_amis(self):
+ for ami in AMIS:
+ ami_id = ami['ami_id']
+ self.amis[ami_id] = Ami(self, **ami)
+
+ def create_image(self, instance_id, name=None, description=None, owner_id=None):
# TODO: check that instance exists and pull info from it.
ami_id = random_ami_id()
instance = self.get_instance(instance_id)
ami = Ami(self, ami_id, instance=instance, source_ami=None,
- name=name, description=description)
+ name=name, description=description, owner_id=owner_id)
self.amis[ami_id] = ami
return ami
@@ -1095,30 +1131,29 @@ class AmiBackend(object):
self.amis[ami_id] = ami
return ami
- def describe_images(self, ami_ids=(), filters=None, exec_users=None):
- images = []
+ def describe_images(self, ami_ids=(), filters=None, exec_users=None, owners=None):
+ images = self.amis.values()
+
+ # Limit images by launch permissions
if exec_users:
- for ami_id in self.amis:
- found = False
+ tmp_images = []
+ for ami in images:
for user_id in exec_users:
- if user_id in self.amis[ami_id].launch_permission_users:
- found = True
- if found:
- images.append(self.amis[ami_id])
- if images == []:
- return images
+ if user_id in ami.launch_permission_users:
+ tmp_images.append(ami)
+ images = tmp_images
+
+ # Limit by owner ids
+ if owners:
+ images = [ami for ami in images if ami.owner_id in owners]
+
+ if ami_ids:
+ images = [ami for ami in images if ami.id in ami_ids]
+
+ # Generic filters
if filters:
- images = images or self.amis.values()
return generic_filter(filters, images)
- else:
- for ami_id in ami_ids:
- if ami_id in self.amis:
- images.append(self.amis[ami_id])
- elif not ami_id.startswith("ami-"):
- raise MalformedAMIIdError(ami_id)
- else:
- raise InvalidAMIIdError(ami_id)
- return images or self.amis.values()
+ return images
def deregister_image(self, ami_id):
if ami_id in self.amis:
@@ -3679,8 +3714,8 @@ class NatGatewayBackend(object):
return self.nat_gateways.pop(nat_gateway_id)
-class EC2Backend(BaseBackend, InstanceBackend, TagBackend, AmiBackend,
- RegionsAndZonesBackend, SecurityGroupBackend, EBSBackend,
+class EC2Backend(BaseBackend, InstanceBackend, TagBackend, EBSBackend,
+ RegionsAndZonesBackend, SecurityGroupBackend, AmiBackend,
VPCBackend, SubnetBackend, SubnetRouteTableAssociationBackend,
NetworkInterfaceBackend, VPNConnectionBackend,
VPCPeeringConnectionBackend,
diff --git a/moto/ec2/resources/amis.json b/moto/ec2/resources/amis.json
new file mode 100644
index 000000000..5cc3122f3
--- /dev/null
+++ b/moto/ec2/resources/amis.json
@@ -0,0 +1,546 @@
+[
+ {
+ "ami_id": "ami-03cf127a",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Nano Locale English AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Nano-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-12c6146b",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2008 R2 SP1 Datacenter 64-bit Locale English Base AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2008-R2_SP1-English-64Bit-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-1812c061",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Standard 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2016_SP1_Standard-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-1e749f67",
+ "state": "available",
+ "public": true,
+ "owner_id": "099720109477",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Canonical, Ubuntu, 14.04 LTS, amd64 trusty image build on 2017-07-27",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20170727",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-1ecc1e67",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-1f12c066",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Express 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2016_SP1_Express-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-24f3215d",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Web 2014 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2014_SP2_Web-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-35e92e4c",
+ "state": "available",
+ "public": true,
+ "owner_id": "013907871322",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "SUSE Linux Enterprise Server 12 SP3 (HVM, 64-bit, SSD-Backed)",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "suse-sles-12-sp3-v20170907-hvm-ssd-x86_64",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-3bf32142",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Express 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2016_SP1_Express-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-3df32144",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Enterprise 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2016_SP1_Enterprise-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-56ec3e2f",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Express 2017 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2017_Express-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-61db0918",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2003 R2 SP2 Datacenter 64-bit Locale English Base AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2003-R2_SP2-English-64Bit-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-6ef02217",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Web 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2016_SP1_Web-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-760aaa0f",
+ "state": "available",
+ "public": true,
+ "owner_id": "137112412989",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/xvda",
+ "description": "Amazon Linux AMI 2017.09.1.20171103 x86_64 HVM GP2",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "amzn-ami-hvm-2017.09.1.20171103-x86_64-gp2",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-77ed3f0e",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Full Locale English with SQL Enterprise 2016 SP1 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2016_SP1_Enterprise-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-785db401",
+ "state": "available",
+ "public": true,
+ "owner_id": "099720109477",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Canonical, Ubuntu, 16.04 LTS, amd64 xenial image build on 2017-07-21",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170721",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-8104a4f8",
+ "state": "available",
+ "public": true,
+ "owner_id": "137112412989",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Amazon Linux AMI 2017.09.1.20171103 x86_64 PV EBS",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "amzn-ami-pv-2017.09.1.20171103-x86_64-ebs",
+ "virtualization_type": "paravirtual",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-84ee3cfd",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Web 2017 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2017_Web-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-86ee3cff",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Standard 2017 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2017_Standard-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-999844e0",
+ "state": "available",
+ "public": true,
+ "owner_id": "898082745236",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/xvda",
+ "description": "Deep Learning on Amazon Linux with MXNet, Tensorflow, Caffe, Theano, Torch, CNTK and Keras",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "Deep Learning AMI Amazon Linux - 3.3_Oct2017",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-9b32e8e2",
+ "state": "available",
+ "public": true,
+ "owner_id": "898082745236",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "CUDA9 Classic Ubuntu DLAMI 1508914531",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "Ubuntu CUDA9 DLAMI with MXNet/TF/Caffe2",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-a9cc1ed0",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Standard 2014 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2014_SP2_Standard-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-afee3cd6",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Web 2016 SP1 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2016_SP1_Web-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-b7e93bce",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 with Desktop Experience Locale English AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-bb9a6bc2",
+ "state": "available",
+ "public": true,
+ "owner_id": "309956199498",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Provided by Red Hat, Inc.",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "RHEL-7.4_HVM_GA-20170808-x86_64-2-Hourly2-GP2",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-bceb39c5",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 with Containers Locale English AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-Containers-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-c2ff2dbb",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 RTM 64-bit Locale English Base AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-RTM-English-64Bit-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-c6f321bf",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Express 2014 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2014_SP2_Express-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-d1cb19a8",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2008 SP2 Datacenter 64-bit Locale English Base AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2008-SP2-English-64Bit-Base-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-dca37ea5",
+ "state": "available",
+ "public": true,
+ "owner_id": "898082745236",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Deep Learning on Ubuntu Linux with MXNet, Tensorflow, Caffe, Theano, Torch, CNTK and Keras",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "Deep Learning AMI Ubuntu Linux - 2.4_Oct2017",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-f0e83a89",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2016 Locale English with SQL Enterprise 2017 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2016-English-Full-SQL_2017_Enterprise-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-f4cf1d8d",
+ "state": "available",
+ "public": true,
+ "owner_id": "801119661308",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda1",
+ "description": "Microsoft Windows Server 2012 R2 RTM 64-bit Locale English with SQL Standard 2016 AMI provided by Amazon",
+ "image_type": "machine",
+ "platform": "windows",
+ "architecture": "x86_64",
+ "name": "Windows_Server-2012-R2_RTM-English-64Bit-SQL_2016_SP1_Standard-2017.10.13",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-f8e54081",
+ "state": "available",
+ "public": true,
+ "owner_id": "898082745236",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/xvda",
+ "description": "CUDA9 Classic Amazon Linux DLAMI 1508914924",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "CUDA9ClassicAmazonLinuxDLAMIwithMXNetTensorflowandCaffe2 ",
+ "virtualization_type": "hvm",
+ "hypervisor": "xen"
+ },
+ {
+ "ami_id": "ami-fa7cdd89",
+ "state": "available",
+ "public": true,
+ "owner_id": "013907871322",
+ "sriov": "simple",
+ "root_device_type": "ebs",
+ "root_device_name": "/dev/sda",
+ "description": "SUSE Linux Enterprise Server 11 Service Pack 4 ((PV, 64-bit, SSD-Backed)",
+ "image_type": "machine",
+ "platform": null,
+ "architecture": "x86_64",
+ "name": "suse-sles-11-sp4-v20151207-pv-ssd-x86_64",
+ "virtualization_type": "paravirtual",
+ "hypervisor": "xen"
+ }
+]
\ No newline at end of file
diff --git a/moto/ec2/responses/amis.py b/moto/ec2/responses/amis.py
index c92471093..19e6d31a1 100755
--- a/moto/ec2/responses/amis.py
+++ b/moto/ec2/responses/amis.py
@@ -36,9 +36,10 @@ class AmisResponse(BaseResponse):
def describe_images(self):
ami_ids = self._get_multi_param('ImageId')
filters = filters_from_querystring(self.querystring)
+ owners = self._get_multi_param('Owner')
exec_users = self._get_multi_param('ExecutableBy')
images = self.ec2_backend.describe_images(
- ami_ids=ami_ids, filters=filters, exec_users=exec_users)
+ ami_ids=ami_ids, filters=filters, exec_users=exec_users, owners=owners)
template = self.response_template(DESCRIBE_IMAGES_RESPONSE)
return template.render(images=images)
@@ -92,12 +93,12 @@ DESCRIBE_IMAGES_RESPONSE = """'})
snapshot.add_tags({'key': ''})
- dict(conn.get_all_snapshots()[0].tags).should.equal({'key': ''})
+ snaps = [snap for snap in conn.get_all_snapshots() if snap.id == snapshot.id]
+ dict(snaps[0].tags).should.equal({'key': ''})
diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py
index d4a2a6ff7..5cfe01618 100644
--- a/tests/test_ec2/test_instances.py
+++ b/tests/test_ec2/test_instances.py
@@ -217,7 +217,6 @@ def test_create_with_tags():
len(instances['Instances'][0]['Tags']).should.equal(3)
-
@mock_ec2_deprecated
def test_get_instances_filtering_by_state():
conn = boto.connect_ec2()
diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py
index bb3a8d36b..ccef5a288 100644
--- a/tests/test_ec2/test_tags.py
+++ b/tests/test_ec2/test_tags.py
@@ -356,7 +356,7 @@ def test_retrieved_snapshots_must_contain_their_tags():
# Fetch the snapshot again
all_snapshots = conn.get_all_snapshots()
- snapshot = all_snapshots[0]
+ snapshot = [item for item in all_snapshots if item.id == snapshot.id][0]
retrieved_tags = snapshot.tags
conn.delete_snapshot(snapshot.id)
diff --git a/tests/test_redshift/test_server.py b/tests/test_redshift/test_server.py
index 4e950fc74..c37e9cab7 100644
--- a/tests/test_redshift/test_server.py
+++ b/tests/test_redshift/test_server.py
@@ -19,4 +19,4 @@ def test_describe_clusters():
res = test_client.get('/?Action=DescribeClusters')
result = res.data.decode("utf-8")
- result.should.contain("")
diff --git a/tox.ini b/tox.ini
index 3fe5d0141..0f3f1466a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26, py27, py33, py34
+envlist = py27, py36
[testenv]
deps =