Modify Tags

Create or delete tags for EC2 resources.

Source codePermissions

Supported EC2 resources

If a tag key already exists, the tag value is replaced with the new value.

dynamic_tags mode will make an API call per resource.

Usage

Input

Parameter Description Type Required Default Value
resource_ids List of EC2 resource IDs to apply tags to list(string) Yes None
tags Tags to create or delete
Key=Value or Key
list(string) Yes None
create Create tags bool If not delete False
delete Delete tags bool If not create False
dynamic_tags Dynamically add the resource ID to the tag key or value where {resource_id} placeholder is found bool No False
region Region for operation. Leave blank for session default string No Session Default
debug Increase log verbosity bool No False
silent Decrease log verbosity bool No False
output Output format
table
string No None
session Established session object No None

Output

Returns a list of resources that failed the modification:

['vol-1234567890abcdef0', 'i-abcdef1234567890']

Examples

Create tags for resources:

aaws ec2 modify_tags --resource_ids vol-1234567890abcdef0 i-abcdef1234567890 --tags Name=example "Owner=Foo + Bar" --create

Delete tags for resources:

aaws ec2 modify_tags --resource_ids vol-1234567890abcdef0 i-abcdef1234567890 --tags Name Owner --delete

Create dynamic tags for resources:

aaws ec2 modify_tags --resource_ids vol-1234567890abcdef0 i-abcdef1234567890 --tags Foo={resource_id} "Bar={resource_id}-foo" --create --dynamic_tags