From d8f6f77a0f5dff2263cc6f2a6db89baa9efe8302 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Tue, 5 Dec 2017 10:22:13 +0100 Subject: [PATCH] Fix prebuilt images usability. (#1375) - add a better error message when user uses an unknown ami - add image_location in the default fake images Fixes #1372 --- moto/ec2/models.py | 4 +++- moto/ec2/resources/amis.json | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 502122969..e6a1d0be3 100755 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -392,7 +392,9 @@ class Instance(TaggedEC2Resource, BotoInstance): 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), + 'cause an error.\n' + 'Use ec2_backend.describe_images() to' + 'find suitable image for your test'.format(image_id), PendingDeprecationWarning) self.platform = ami.platform if ami else None diff --git a/moto/ec2/resources/amis.json b/moto/ec2/resources/amis.json index 5cc3122f3..6e4794e22 100644 --- a/moto/ec2/resources/amis.json +++ b/moto/ec2/resources/amis.json @@ -4,6 +4,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -20,6 +21,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -36,6 +38,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -52,6 +55,7 @@ "state": "available", "public": true, "owner_id": "099720109477", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -68,6 +72,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -84,6 +89,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -100,6 +106,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -116,6 +123,7 @@ "state": "available", "public": true, "owner_id": "013907871322", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -132,6 +140,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -148,6 +157,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -163,6 +173,7 @@ "ami_id": "ami-56ec3e2f", "state": "available", "public": true, + "image_location": "amazon/getting-started", "owner_id": "801119661308", "sriov": "simple", "root_device_type": "ebs", @@ -180,6 +191,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -196,6 +208,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -212,6 +225,7 @@ "state": "available", "public": true, "owner_id": "137112412989", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/xvda", @@ -228,6 +242,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -244,6 +259,7 @@ "state": "available", "public": true, "owner_id": "099720109477", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -260,6 +276,7 @@ "state": "available", "public": true, "owner_id": "137112412989", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -276,6 +293,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -292,6 +310,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -308,6 +327,7 @@ "state": "available", "public": true, "owner_id": "898082745236", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/xvda", @@ -324,6 +344,7 @@ "state": "available", "public": true, "owner_id": "898082745236", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -340,6 +361,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -356,6 +378,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -372,6 +395,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -388,6 +412,7 @@ "state": "available", "public": true, "owner_id": "309956199498", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -404,6 +429,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -420,6 +446,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -436,6 +463,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -452,6 +480,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -468,6 +497,7 @@ "state": "available", "public": true, "owner_id": "898082745236", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -484,6 +514,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -500,6 +531,7 @@ "state": "available", "public": true, "owner_id": "801119661308", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda1", @@ -516,6 +548,7 @@ "state": "available", "public": true, "owner_id": "898082745236", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/xvda", @@ -532,6 +565,7 @@ "state": "available", "public": true, "owner_id": "013907871322", + "image_location": "amazon/getting-started", "sriov": "simple", "root_device_type": "ebs", "root_device_name": "/dev/sda",