AWS EC2 instances have a unique identifier (Instance ID). But as this is a random combination of alphanumeric characters, it's impossible to immediately know what this instance is for.
This is why tags can be created. In the following example a tag with the key "Name" was added to the selected EC2 instance. We gave this instance the name "onl-radoaie25-p".
However using these tags on the aws command line is somewhat unclear. The man page (aws ec2 describe-instances help) mentions --filters that can be applied on tags:
At the bottom of the filters list, the following options show up:
tag:<key> - The key/value combination of a tag assigned to the re-
source. Use the tag key in the filter name and the tag value as
the filter value. For example, to find all resources that have a
tag with the key Owner and the value TeamA , specify tag:Owner for
the filter name and TeamA for the filter value.
tag-key - The key of a tag assigned to the resource. Use this fil-
ter to find all resources that have a tag with a specific key, re-
gardless of the tag value.
The description leaves you rather baffled than with more knowledge how to use the "Name" tag in the filter.
Finally GitHub user garnaat gave the best example how to correctly use a Name tag with the --filter option:
aws ec2 describe-instances --filter Name=tag:Name,Values=ADS-prod-ads
In this example, a tag "Name" with a value of "ADS-prod-ads" is used. In our situation we have the Name value "onl-radoaie25-p", so let's use this:
ck@mintp ~ $ aws ec2 describe-instances --filter Name=tag:Name,Values=onl-radoaie25-p
And finally only this particular EC2 instance is showing up in the response.
No comments yet.