Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to programmatically list all of the available actions for an AWS service?

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:

{
    "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.

like image 639
Istvan Avatar asked Apr 06 '16 15:04

Istvan


3 Answers

I liked Trentium answer, but it will need maintenance.

I think I will use the AWS Policy Generator call for the policies.js file

like image 102
Adam Avatar answered Sep 19 '22 11:09

Adam


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:

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
like image 22
zellio Avatar answered Sep 18 '22 11:09

zellio


If you have node installed on your machine, simply type npx get-aws-actions in your terminal. No need to install anything. This npx command fetches the actions from the AWS policy generator file https://awspolicygen.s3.amazonaws.com/js/policies.js and support text search to pinpoint the actions for specific AWS services (e.g., search for s3: to list all the S3 actions).

like image 32
Nicolas Dao Avatar answered Sep 20 '22 11:09

Nicolas Dao