Last active
October 22, 2019 01:57
-
-
Save aelsabbahy/157f38d3b867eed85ec0ddb1e0d1e923 to your computer and use it in GitHub Desktop.
Simple script to lookup IAM resource conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
REPO_DIR=~/.iam_lookup/complete-aws-iam-reference | |
REPO_URL=https://github.com/widdix/complete-aws-iam-reference | |
if [[ $1 == "update" ]];then | |
if [[ -e $REPO_DIR ]];then | |
(cd "$REPO_DIR" && git pull) | |
else | |
git clone "$REPO_URL" "$REPO_DIR" | |
fi | |
exit | |
fi | |
service=$(cut -d ':' -f1 <<<"$1") | |
action=$(cut -d ':' -f2 <<<"$1") | |
resource_filter=$2 | |
jq_filter=".[] | select(.service == \"$service\") | select(.action == \"$action\")" | |
[[ $resource_filter ]] && jq_filter="[$jq_filter | select(.resources[] | contains(\"$resource_filter\"))] | unique" | |
pushd "$REPO_DIR/tools" > /dev/null | |
node ./md2json.js | jq --color-output "$jq_filter" | less | |
popd > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iamlookup
Simple script that uses complete-aws-iam-reference repo to lookup iam resources on the command line.
Basically, it's a CLI version of https://iam.cloudonaut.io/
Requirements
To download/update the reference use
To lookup a action:
To lookup an action filtering by resource:
Example output: