Amazon Elastic Compute Cloud
API Reference (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

DeleteTags

Description

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.

Request Parameters

ResourceId.n

The ID of the resource. For example, ami-1a2b3c4d. You can specify more than one resource ID.

Type: String

Default: None

Required: Yes

Tag.n.Key

The tag's key. You can specify more than one tag to delete.

Type: String

Default: None

Required: Yes

Tag.n.Value

The 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

Response Elements

The following elements are returned in a DeleteTagsResponse element.

requestId

The ID of the request.

Type: xsd:string

return

Returns true if the request succeeds. Otherwise, returns an error.

Type: xsd:boolean

Examples

Example Request

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>

Example Request

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

Example Request

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

Example Request

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

Example Request

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