Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IAM Policy isn't allowing EC2 access

I have a policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1429817158000",
            "Effect": "Allow",
            "Action": [
                "ec2:*"
            ],
            "Resource": [
                "arn:aws:ec2:*"
            ]
        }
    ]
}

That is attached to a group. That group has one user. When I log in to myloginthing.signin.aws.amazon.com with that user's credentials I can't do anything related to EC2. It gives me messages such as "You are not authorized to describe Running Instances" for every action on the page.

the IAM Policy Simulator tells me any action is denied because

Implicitly denied (no matching statements found).

What am I missing?

like image 274
Philip Avatar asked Apr 23 '15 22:04

Philip


2 Answers

This actually took me a while to figure out.

It turns out that you have to match each action (in your example, ec2:*) with a set of allowable resources (in your example, arn:aws:ec2:*).

The problem is that not every action has the same set of allowable resources - so while you can use a number of different resources for RunInstances, DescribeInstances ONLY supports *.

The whole list is available here

(Note: Link is posted because a) the list is very large, and b) it will probably change significantly over time.

like image 158
chris Avatar answered Oct 07 '22 22:10

chris


It's actually fine to use ec2:* as Allow Action, but "arn:aws:ec2:*" is an invalid Amazon Resource Name.

Replace "arn:aws:ec2:*" with "arn:aws:ec2:::*" or just "*" should work.

See Amazon Resource Names (ARNs) and AWS Service Namespaces

like image 2
number5 Avatar answered Oct 07 '22 21:10

number5