Reputation: 5038
I am trying to use the PS AWS Cmdlet Get-EC2Subnet to get the resourceId:
Get-EC2Subnet -filter tag:Name,Value=Test-APP-Subnet-A
I am trying to filter based on the resource name. The documentation is not very helpful:
-Filter <Filter[]>
One or more filters.
...
tag:<key> - The key/value combination of a tag assigned to the resource. 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.
...
What is the correct syntax ?
Upvotes: 1
Views: 329
Reputation: 71
Playing with this as well. I found that the get-ec2Instance had a better example of using filters and adapted it to this.
#Returns all subnets with a tag called "Name" defined:
Get-EC2Subnet -Filter @{name="tag-key";values="Name"}
#Returns all subnets with a specific tag "Name" set:
Get-EC2Subnet -Filter @{name="tag:Name";values="Test-APP-Subnet-A"}
Upvotes: 1