aws ec2 describe-tags
Describes the specified tags for your EC2 resources. AWS CLI reference
5 examples 4 options Its page in the AWS CLI reference
Examples
Example 1: To describe all tags for a single resource
The following describe-tags example describes the tags for the specified instance.
aws ec2 describe-tags --filters "Name=resource-id,Values=i-1234567890abcdef8"Identify--filtersThe filters.Its output
{
"Tags": [
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Test",
"Key": "Stack"
},
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Beta Server",
"Key": "Name"
}
]
}For more information, see Tag your Amazon EC2 resources in the Amazon EC2 User Guide.
Example 2: To describe all tags for a resource type
The following describe-tags example describes the tags for your volumes.
aws ec2 describe-tags --filters "Name=resource-type,Values=volume"Identify--filtersThe filters.Its output
{
"Tags": [
{
"ResourceType": "volume",
"ResourceId": "vol-1234567890abcdef0",
"Value": "Project1",
"Key": "Purpose"
},
{
"ResourceType": "volume",
"ResourceId": "vol-049df61146c4d7901",
"Value": "Logs",
"Key": "Purpose"
}
]
}For more information, see Tag your Amazon EC2 resources in the Amazon EC2 User Guide.
Example 3: To describe all your tags
The following describe-tags example describes the tags for all your resources.
aws ec2 describe-tagsIdentifyIts output
{
"Tags": [
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Test",
"Key": "Stack"
},
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Beta Server",
"Key": "Name"
},
{
"ResourceType": "volume",
"ResourceId": "vol-049df61146c4d7901",
"Value": "Logs",
"Key": "Purpose"
}
]
}For more information, see Tag your Amazon EC2 resources in the Amazon EC2 User Guide.
Example 4: To describe the tags for your resources based on a tag key
The following describe-tags example describes the tags for your resources that have a tag with the key Stack.
aws ec2 describe-tags --filters Name=key,Values=StackIdentify--filtersThe filters.Its output
{
"Tags": [
{
"ResourceType": "volume",
"ResourceId": "vol-027552a73f021f3b",
"Value": "Production",
"Key": "Stack"
},
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Test",
"Key": "Stack"
}
]
}For more information, see Tag your Amazon EC2 resources in the Amazon EC2 User Guide.
Example 5: To describe the tags for your resources based on a tag key and tag value
The following describe-tags example describes the tags for your resources that have the tag Stack=Test.
aws ec2 describe-tags --filters Name=key,Values=Stack Name=value,Values=TestIdentify--filtersThe filters.Its output
{
"Tags": [
{
"ResourceType": "image",
"ResourceId": "ami-3ac336533f021f3bd",
"Value": "Test",
"Key": "Stack"
},
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef8",
"Value": "Test",
"Key": "Stack"
}
]
}The following describe-tags example uses alternate syntax to describe resources with the tag Stack=Test.
aws ec2 describe-tags --filters "Name=tag:Stack,Values=Test"Identify--filtersThe filters.The following describe-tags example describes the tags for all your instances that have a tag with the key Purpose and no value.
aws ec2 describe-tags --filters "Name=resource-type,Values=instance" "Name=key,Values=Purpose" "Name=value,Values="Identify--filtersThe filters.Its output
{
"Tags": [
{
"ResourceType": "instance",
"ResourceId": "i-1234567890abcdef5",
"Value": "",
"Key": "Purpose"
}
]
}For more information, see Tag your Amazon EC2 resources in the Amazon EC2 User Guide.
Options
--dry-runChecks whether you have the required permissions for the action, without actually making the request, and provides an error response.--filtersThe filters.--max-resultsThe maximum number of items to return for this request.--next-tokenThe token returned from a previous paginated request.