Difference between revisions of "AWS/CLI"
From Christoph's Personal Wiki
(Created page with "This article will contain a (random) collection of '''Amazon Web Services - Command Line Interface''' ('''AWS CLI''') tips-and-tricks. It will also have examples using <code>b...") |
|||
| Line 30: | Line 30: | ||
AND tags.key NOT LIKE 'owner' | AND tags.key NOT LIKE 'owner' | ||
</pre> | </pre> | ||
| + | |||
| + | ==External links== | ||
| + | * [https://docs.aws.amazon.com/ARG/latest/userguide/find-resources-to-tag.html Find resources to tag] | ||
| + | * [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html List and filter your resources] | ||
[[Category:AWS]] | [[Category:AWS]] | ||
Revision as of 22:34, 26 February 2021
This article will contain a (random) collection of Amazon Web Services - Command Line Interface (AWS CLI) tips-and-tricks. It will also have examples using boto and other miscellaneous tips-and-tricks.
- Find all AWS resources that do not have a tag with a key of "
project" assigned to them:
$ aws resourcegroupstaggingapi get-resources --tags-per-page 100 --output json |\
jq '.ResourceTagMappingList[] | select(contains({Tags: [{Key: "project"} ]}) | not)'
{
"ResourceARN": "arn:aws:ec2:us-west-2:0000000:security-group/sg-1aaaaaaa",
"Tags": [
{
"Value": "xtof-aws-dev-sg",
"Key": "Name"
}
]
}
- If you have AWS Config setup, you can do advanced SQL-like queries:
SELECT resourceId, resourceType, configuration.instanceType, configuration.placement.tenancy, configuration.imageId, tags, availabilityZone WHERE resourceType = 'AWS::EC2::Instance' AND tags.key NOT LIKE 'owner'