We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Inline Policies

Policies allow or deny actions on specific resources. They look something like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow", // <--- 1. Are we allowing or denying?
      "Action": [
        "ec2:Describe*" // <--- 2. Which API actions are affected?
      ],
      "Resource": "*" // <--- 3. Which targets are affected?
    }
  ]
}

A policy has three main parts:

  • Effect: Allow or Deny. Are we permitting or denying these actions?
  • Action: The action to allow or deny. There are thousands of these, like DescribeInstances, CreateBucket, or PutObject.
  • Resource: Which resources the action targets. For example, "all EC2 servers," or perhaps the ARN of just a specific one.

Assignment

Vincent Vega needs to see EC2 instances for a dashboard he's building, but make sure he can't break anything.

Add an inline read-only policy patientping-ec2-readonly (EC2 Describe only) to patientping-admin-vinny.

Cost check: Creating IAM policies is free; costs arise from service usage.

Let's add this policy the wrong way (inline) first, and we'll fix it in the next lesson.

  1. {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": ["ec2:Describe*"],
          "Resource": "*"
        }
      ]
    }
    

Run and submit the CLI tests.

Tip

Here's how to create an inline policy with the AWS CLI (assuming you've prepared a JSON file for the policy):

aws iam put-user-policy --user-name patientping-admin-vinny --policy-name patientping-ec2-readonly --policy-document file://POLICY-FILE.json