| « PreviousNext » | |
![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Deletes a specific set of tags from a specific set of resources. This call is
designed to follow a DescribeTags call. You first determine
what tags a resource has, and then you call DeleteTags with the
resource ID and the specific tags you want to delete.
For more information about tags, see Using Tags in the Amazon Elastic Compute Cloud User Guide.
ResourceId.nThe ID of the resource. For example, ami-1a2b3c4d. You can specify
more than one resource ID.
Type: String
Default: None
Required: Yes
Tag.n.KeyThe tag's key. You can specify more than one tag to delete.
Type: String
Default: None
Required: Yes
Tag.n.ValueThe tag's value.
Type: String
Default: If you omit this parameter, we delete the tag regardless of its value. If you specify this parameter with an empty string as the value, we delete the key only if its value is an empty string.
Required: No
The following elements are returned in a
DeleteTagsResponse element.
requestIdThe ID of the request.
Type: xsd:string
returnReturns true if the request succeeds. Otherwise, returns an error.
Type: xsd:boolean
This example deletes the tags for the AMI with ID ami-1a2b3c4d. You first get a list of the tags.
https://ec2.amazonaws.com/?Action=DescribeTags &ResourceId.1=ami-1a2b3c4d &AUTHPARAMS
Sample response:
<DescribeTagsResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<tagSet>
<item>
<resourceId>ami-1a2b3c4d</resourceId>
<resourceType>image</resourceType>
<key>webserver</key>
<value/>
</item>
<item>
<resourceId>ami-1a2b3c4d</resourceId>
<resourceType>image</resourceType>
<key>stack</key>
<value>Production</value>
</item>
</tagSet>
</DescribeTagsResponse>Then you delete the tags. Specifying the value for the stack tag is optional.
https://ec2.amazonaws.com/?Action=DeleteTags &ResourceId.1=ami-1a2b3c4d &Tag.1.Key=webserver &Tag.2.Key=stack &AUTHPARAMS
Sample response:
<DeleteTagsResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId> <return>true</return> </DeleteTagsResponse>
This example deletes the stack tag from two particular instances.
https://ec2.amazonaws.com/?Action=DeleteTags &ResourceId.1=i-5f4e3d2a &Tag.1.Key=stack &ResourceId.2=i-12345678 &Tag.2.Key=stack &AUTHPARAMS
This example deletes the stack and webserver tags for one particular instance.
https://ec2.amazonaws.com/?Action=DeleteTags &ResourceId.1=i-5f4e3d2a &Tag.1.Key=stack &ResourceId.2=i-5f4e3d2a &Tag.2.Key=webserver &AUTHPARAMS
You can specify a tag key without a corresponding tag value if you want to delete the tag regardless of its value. This example deletes all tags whose key=Purpose, regardless of the tag value.
https://ec2.amazonaws.com/?Action=DeleteTags &ResourceId.1=i-5f4e3d2a &Tag.1.Key=Purpose &AUTHPARAMS
When you create a tag, you can set the tag value to the empty string. Correspondingly, you can delete only tags that have a specific key and whose value is the empty string. This example deletes all tags for the specified instance where key=Purpose and the tag value is the empty string.
https://ec2.amazonaws.com/?Action=DeleteTags &ResourceId.1=i-5f4e3d2a &Tag.1.Key=Purpose &Tag.2.Value= &AUTHPARAMS