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...

CreateTags

Description

Adds or overwrites one or more tags for the specified EC2 resource or resources. Each resource can have a maximum of 10 tags. Each tag consists of a key and optional value. Tag keys must be unique per resource.

For more information about tags, see Using Tags in the Amazon Elastic Compute Cloud User Guide.

Request Parameters

ResourceId.n

The ID of a resource to tag. For example, ami-1a2b3c4d. You can specify multiple resources to assign the tags to.

Type: String

Default: None

Required: Yes

Tag.n.Key

The key for a tag.

Type: String

Default: None

Constraints: Tag keys are case sensitive and accept a maximum of 128 Unicode characters.

Required: Yes

Tag.n.Value

The value for a tag. If you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Type: String

Default: None

Constraints: Tag values are case sensitive and accept a maximum of 256 Unicode characters.

Required: Yes

Response Elements

The following elements are returned in a CreateTagsResponse 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 adds (or overwrites) two tags for an AMI and an instance. One of the tags is just a key (webserver), with no value (we set the value to an empty string). The other consists of a key (stack) and value (Production).

https://ec2.amazonaws.com/?Action=CreateTags
&ResourceId.1=ami-1a2b3c4d
&ResourceId.2=i-7f4d3a2b
&Tag.1.Key=webserver
&Tag.1.Value=
&Tag.2.Key=stack
&Tag.2.Value=Production
&AUTHPARAMS

Example Response

<CreateTagsResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
  <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
  <return>true</return>
</CreateTagsResponse>