ListTagsForResource - AWS Systems Manager

ListTagsForResource

Returns a list of the tags assigned to the specified resource.

For information about the ID format for each supported resource type, see AddTagsToResource.

Request Syntax

{ "ResourceId": "string", "ResourceType": "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.

ResourceId

The resource ID for which you want to see a list of tags.

Type: String

Required: Yes

ResourceType

Returns a list of tags for a specific resource type.

Type: String

Valid Values: Document | ManagedInstance | MaintenanceWindow | Parameter | PatchBaseline | OpsItem | OpsMetadata | Automation | Association

Required: Yes

Response Syntax

{ "TagList": [ { "Key": "string", "Value": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

TagList

A list of tags.

Type: Array of Tag objects

Array Members: Maximum number of 1000 items.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerError

An error occurred on the server side.

HTTP Status Code: 500

InvalidResourceId

The resource ID isn't valid. Verify that you entered the correct ID and try again.

HTTP Status Code: 400

InvalidResourceType

The resource type isn't valid. For example, if you are attempting to tag an EC2 instance, the instance must be a registered managed node.

HTTP Status Code: 400

Examples

Example

This example illustrates one usage of ListTagsForResource.

Sample Request

POST / HTTP/1.1 Host: ssm.us-east-2.amazonaws.com Accept-Encoding: identity X-Amz-Target: AmazonSSM.ListTagsForResource Content-Type: application/x-amz-json-1.1 User-Agent: aws-cli/2.0.0 Python/3.7.5 Windows/10 botocore/2.0.0dev4 X-Amz-Date: 20240221T003710Z Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20240221/us-east-2/ssm/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=39c3b3042cd2aEXAMPLE Content-Length: 71 { "ResourceType": "PatchBaseline", "ResourceId": "pb-0c10e65780EXAMPLE" }

Sample Response

{ "TagList": [ { "Key": "Platform", "Value": "Windows Server" }, { "Key": "Environment", "Value": "Production" }, { "Key": "Region", "Value": "EMEA" } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: