From 597676c59c229819b3da1abaaeb48a3020374e13 Mon Sep 17 00:00:00 2001 From: dbfr3qs Date: Mon, 15 Jan 2018 21:52:32 +1300 Subject: [PATCH] add tags when creating ebs volume --- moto/ec2/responses/elastic_block_store.py | 13 ++++++++++++ tests/test_ec2/test_tags.py | 26 ++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/moto/ec2/responses/elastic_block_store.py b/moto/ec2/responses/elastic_block_store.py index 37b3e9a07..333642247 100644 --- a/moto/ec2/responses/elastic_block_store.py +++ b/moto/ec2/responses/elastic_block_store.py @@ -32,10 +32,13 @@ class ElasticBlockStore(BaseResponse): size = self._get_param('Size') zone = self._get_param('AvailabilityZone') snapshot_id = self._get_param('SnapshotId') + tags = self._parse_tag_specification("TagSpecification") + volume_tags = tags.get('image', {}) encrypted = self._get_param('Encrypted', if_none=False) if self.is_not_dryrun('CreateVolume'): volume = self.ec2_backend.create_volume( size, zone, snapshot_id, encrypted) + volume.add_tags(volume_tags) template = self.response_template(CREATE_VOLUME_RESPONSE) return template.render(volume=volume) @@ -139,6 +142,16 @@ CREATE_VOLUME_RESPONSE = """