TagResource
Adds one or more tags to the specified resource.
Request Syntax
{
"ResourceARN": "string
",
"Tags": [
{
"Key": "string
",
"Value": "string
"
}
]
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- ResourceARN
-
The Amazon Resource Name (ARN) of the resource that you want to retrieve tags for.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1011.
Required: Yes
- Tags
-
The tags to add to the specified resource. Specifying the tag key is required. You can set the value of a tag to an empty string, but you can't set the value of a tag to null.
Type: Array of Tag objects
Array Members: Minimum number of 0 items. Maximum number of 200 items.
Required: Yes
Response Elements
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Errors
For information about the errors that are common to all actions, see Common Errors.
- InvalidInput
-
One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.
HTTP Status Code: 400
- ResourceNotFoundException
-
The operation can't be completed because the resource was not found.
HTTP Status Code: 400
- TooManyTagsException
-
The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.
HTTP Status Code: 400
Examples
TagResource Example
This example illustrates one usage of TagResource.
Sample Request
POST / HTTP/1.1
Host: servicediscovery.us-east-1.amazonaws.com
Accept-Encoding: identity
X-Amz-Target: Route53AutoNaming_v20170314.TagResource
Content-Type: application/x-amz-json-1.1
X-Amz-Date: 20200521T192626Z
X-Amz-Security-Token: [security-token]
Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20200521/us-east-1/servicediscovery/aws4_request,
SignedHeaders=content-type;host;x-amz-date;x-amz-security-token;x-amz-target,
Signature=[calculated-signature]
Content-Length: [number of characters in the JSON string]
{
"ResourceARN": "arn:aws:servicediscovery:us-east-1:123456789012:namespace/ns-ylexjili4cdxy3xm",
"Tags": [{
"Key": "Department",
"Value": "Engineering"
}, {
"Key": "Project",
"Value": "Zeta"
}]
}
Sample Response
HTTP/1.1 200
Content-Type: application/x-amz-json-1.1
Date: Thu, 21 May 2020 19:26:29 GMT
x-amzn-RequestId: [request-id]
Content-Length: 2
Connection: keep-alive
{}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: