Is it possible to add a tag when invoking the create_snapshot() method in boto3? When I run the following code:
client = boto3.client('ec2')
root_snap_resp = client.create_snapshot(
Description='My snapshot description',
VolumeId='vol-123456',
Tags=[{'Key': 'Test_Key', 'Value': 'Test_Value'}]
)
I get the following error:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "Tags", must be one of: DryRun, VolumeId, Description
Is the only way to add a tag after the fact using the create_tags() method?
In April, 2018, the original answer (and the question itself) were made obsolete...
You can now specify tags for EBS snapshots as part of the API call that creates the resource or via the Amazon EC2 Console when creating an EBS snapshot.
https://aws.amazon.com/blogs/compute/tag-amazon-ebs-snapshots-on-creation-and-implement-stronger-security-policies/
...unless you are using an older version of an SDK that does not implement the feature.
The same announcement extended resource-level permissions to snapshots.
The underlying CreateSnapshot
action in the EC2 API doesn't have any provision for adding tags simultaneously with the creation of the snapshot. You have to go back and tag it after creating it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With