Skip to content

Instantly share code, notes, and snippets.

@packetchef
Last active January 2, 2020 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packetchef/94d14e6f3e62d530aeee7d3051efe8d6 to your computer and use it in GitHub Desktop.
Save packetchef/94d14e6f3e62d530aeee7d3051efe8d6 to your computer and use it in GitHub Desktop.
Demo of AWS CLI query capability, searching by a field and renaming fields for a table
# Equality match:
$ aws securityhub list-members --query "Members[?MemberStatus=='Associated'].{AccountId:AccountId,MasterId:MasterId,MemberStatus:MemberStatus,UpdatedAt:UpdatedAt}" --output table
------------------------------------------------------------------------------
| ListMembers |
+--------------+---------------+---------------+-----------------------------+
| AccountId | MasterId | MemberStatus | UpdatedAt |
+--------------+---------------+---------------+-----------------------------+
| 112233445566| 101010101010 | Associated | 2019-11-11T13:07:04.185Z |
| 667788990011| 101010101010 | Associated | 2019-11-22T17:04:41.795Z |
+--------------+---------------+---------------+-----------------------------+
# Partial match:
$ aws securityhub list-members --query "Members[?contains(MemberStatus,`Associat`)==`true`].{AccountId:AccountId,MasterId:MasterId,MemberStatus:MemberStatus,UpdatedAt:UpdatedAt}" --output table
------------------------------------------------------------------------------
| ListMembers |
+--------------+---------------+---------------+-----------------------------+
| AccountId | MasterId | MemberStatus | UpdatedAt |
+--------------+---------------+---------------+-----------------------------+
| 112233445566| 101010101010 | Associated | 2019-11-11T13:07:04.185Z |
| 667788990011| 101010101010 | Associated | 2019-11-22T17:04:41.795Z |
+--------------+---------------+---------------+-----------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment