From 3ce57644cdda3aacc06aab0c9188fbf9c8d8a1bb Mon Sep 17 00:00:00 2001 From: grahamlyons Date: Fri, 26 Jan 2018 11:12:50 +0000 Subject: [PATCH] Change `'image'` for `'volume'` when getting tags The AWS docs say that: "Currently, the resource types that support tagging on creation are instance and volume." Calling `create_volume` and passing `image` as the resource type in tag specifications causes an `InvalidParameterValue` error. --- moto/ec2/responses/elastic_block_store.py | 2 +- tests/test_ec2/test_tags.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/moto/ec2/responses/elastic_block_store.py b/moto/ec2/responses/elastic_block_store.py index 333642247..31831c18b 100644 --- a/moto/ec2/responses/elastic_block_store.py +++ b/moto/ec2/responses/elastic_block_store.py @@ -33,7 +33,7 @@ class ElasticBlockStore(BaseResponse): zone = self._get_param('AvailabilityZone') snapshot_id = self._get_param('SnapshotId') tags = self._parse_tag_specification("TagSpecification") - volume_tags = tags.get('image', {}) + volume_tags = tags.get('volume', {}) encrypted = self._get_param('Encrypted', if_none=False) if self.is_not_dryrun('CreateVolume'): volume = self.ec2_backend.create_volume( diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py index 8f52da6f3..d78fe24c3 100644 --- a/tests/test_ec2/test_tags.py +++ b/tests/test_ec2/test_tags.py @@ -397,7 +397,7 @@ def test_create_volume_with_tags(): Size=40, TagSpecifications=[ { - 'ResourceType': 'image', + 'ResourceType': 'volume', 'Tags': [ { 'Key': 'TEST_TAG',