Skip to main content

TagResource

Adds or edits tags on a KMS key.

Description

Adds one or more tags to a KMS key. Each tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.

You cannot use the same tag key more than once per KMS key. If you specify a tag key that is already associated with the KMS key, TagResource updates the tag value of that tag.

Request Syntax

Headers

NameDescriptionRequiredType
Content-TypeMust be "application/x-amz-json-1.1"Yesstring
X-Amz-TargetMust be "TrentService.TagResource"Yesstring

Request Body

NameDescriptionRequiredType
KeyIdIdentifies the KMS key you are tagging. Specify the key ID or key ARN of the KMS key.Yesstring
TagsOne or more tags. Each tag consists of a tag key and a tag value. Consists of TagKey and TagValue pairs.YesArray of Tags
POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.TagResource
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "Tags": [ { "TagKey": "Purpose", "TagValue": "Test" }, { "TagKey": "Environment", "TagValue": "Production" } ] }
Values in italics indicate user input and should be replaced with actual values.

Response Elements

This operation has no response elements.

Special Errors

Error CodeDescription
InvalidArnExceptionThe request was rejected because a specified ARN, or an ARN in a key policy, is not valid.
KMSInvalidStateExceptionThe request was rejected because the state of the specified resource is not valid for this request.
KMSNotFoundExceptionThe request was rejected because the specified entity or resource could not be found.
TagExceptionThe request was rejected because one or more tags are not valid.
TooManyTagsExceptionThe request was rejected because the number of tags on the KMS key exceeds the limit.

Permissions

To use the TagResource operation, you must have the following permissions:

  • kms:TagResource on the KMS key

Try It Out

Test TagResource

Add or edit tags on a KMS key.

Coming Soon

This feature is currently under development and will be available soon.