Question:
I am looking for a way to list all of the actions that can be used in a AWS IAM policy.
This is an example policy that uses IAM actions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1457442845000", "Effect": "Allow", "Action": [ "iam:CreatePolicy", "iam:CreatePolicyVersion", "iam:GetGroupPolicy", "iam:CreateGroup", "iam:GetPolicy", "iam:GetPolicyVersion", "iam:GetRolePolicy", "iam:ListAttachedGroupPolicies" ], "Resource": [ "*" ] } ] } |
I would like to search through actions from a file, and for that I would like to have all the available actions. I could not find a way yet to get that list. Any direction is appreciated.
Answer:
Amazon provides a policy generator which it self, knows all of the possible APIs and Actions at the current point in time.
One can generate a list of Actions from the AWS Policy Generator policies.js
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
curl --header 'Connection: keep-alive' \ --header 'Pragma: no-cache' \ --header 'Cache-Control: no-cache' \ --header 'Accept: */*' \ --header 'Referer: https://awspolicygen.s3.amazonaws.com/policygen.html' \ --header 'Accept-Language: en-US,en;q=0.9' \ --silent \ --compressed \ 'https://awspolicygen.s3.amazonaws.com/js/policies.js' | cut -d= -f2 | jq -r '.serviceMap[] | .StringPrefix as $prefix | .Actions[] | "\($prefix):\(.)"' | sort | uniq |