EC2 provider: fixing snapshot tagging

This commit is contained in:
Marcin Kulisz 2017-01-21 22:44:16 +00:00
parent d92123c9dd
commit 673260ec63

View file

@ -29,9 +29,10 @@ class Snapshot(Task):
def run(cls, info):
info._ec2['snapshot'] = info.volume.snapshot()
# # Setting up tags on the snapshot
# if 'tags' in info.manifest.data:
# raw_tags = info.manifest.data['tags']
# tags = {k: v.format(**info.manifest_vars) for k, v in raw_tags.items()}
# info._ec2['connection'](Resources=[info._ec2['snapshot']],
# Tags=[tags])
# Setting up tags on the snapshot
if 'tags' in info.manifest.data:
raw_tags = info.manifest.data['tags']
formatted_tags = {k: v.format(**info.manifest_vars) for k, v in raw_tags.items()}
tags = [{'Key': k, 'Value': v} for k, v in formatted_tags.items()]
info._ec2['connection'].create_tags(Resources=[info._ec2['snapshot']],
Tags=tags)