IAM allowing a user to access everything for ec2 o

2019-06-25 06:32发布

问题:

I'm trying to allow one user to all actions on us-west-2, this is the policy I have.

{
   "Version": "2012-10-17",
   "Statement": [{
      "Effect": "Allow",
      "Action": ["ec2:*"],
      "Resource": "arn:aws:ec2:us-west-2:837625274593:*"
    }
   ]
}

I got the account number from "OWNER" parameter on an instance, not sure if is it.

回答1:

{
  "Statement": [
    {
      "Sid": "Stmt1375943389569",
      "Action": "ec2:*",
      "Effect": "Allow",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "ec2:Region": "us-west-2"
        }
      }
    }
  ]
}

That should enable the user to have all access to ec2 in only the us-west-2 region