Module 1 · Identity and Storage · Lesson 2 of 9

IAM reasoning and a least-privilege role

Read policies like the evaluator does, tell bucket ARNs from object ARNs, and build a role that reads one object and nothing else.

In this lesson · about 28 minutes

  • Explain how AWS evaluates identity policies, resource policies, explicit denies and SCPs
  • Write a policy scoped to a single object ARN
  • Test both success and denial using the intended role, not an admin

IAM (Identity and Access Management) decides whether a principal (a user or role) may perform an action (like s3:GetObject) on a resource (identified by an ARN).

How a decision is made (simplified)

  1. Everything starts denied by default.
  2. An explicit deny in any applicable policy wins. Always.
  3. Service control policies (SCPs) from AWS Organizations set the outer limit for an account. They don't grant anything; they only constrain.
  4. An allow from an identity policy (attached to the user or role) or a resource policy (like a bucket policy) grants access, within those limits.

A role also has a trust policy that controls who can assume it. Permissions and trust are separate questions.

Bucket ARN versus object ARN

ARNUsed for
arn:aws:s3:::noviq-lab-bucketBucket-level actions like s3:ListBucket
arn:aws:s3:::noviq-lab-bucket/reports/q3.txtObject-level actions like s3:GetObject, s3:PutObject

A common mistake is granting s3:GetObject on the bucket ARN: it matches nothing, because objects live under bucket/key.

The role for challenge 01

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::noviq-lab-bucket/reports/q3.txt"
  }]
}

It reads exactly one object. No upload, no delete, no listing. Add s3:ListBucket on the bucket ARN only if listing is actually required.

Performance-based question (PBQ)

Allow or deny?

The role lab-reader has only the policy above. The account's SCP allows all S3 actions. There's no bucket policy except where noted.

Decide the result of each request made as lab-reader.

  • GetObject noviq-lab-bucket/reports/q3.txt
  • GetObject noviq-lab-bucket/reports/payroll.txt
  • PutObject noviq-lab-bucket/reports/q3.txt
  • ListBucket noviq-lab-bucket
  • GetObject q3.txt, after a bucket policy adds Deny s3:* for lab-reader
  • GetObject q3.txt, after the SCP changes to deny all S3
0 of 6 answered

Hands-on lab (simulated terminal)

Practice challenge 01: test as the role

A simulated AWS CLI in a sandbox account (111122223333). The profile lab-reader assumes the role above. Bucket and data are dummies.

Step 1 of 4. Type each command and press Enter. Nothing runs on your computer.

Practice challenge 01: test as the role

1. Confirm who you are with the lab-reader profile.

learner@sandbox:~$

Check your understanding0 of 4 correct

Question 1

1.Does an SCP grant a user permission?

Question 2

2.Why is testing as an administrator misleading?

Question 3

3.A policy grants s3:GetObject on arn:aws:s3:::noviq-lab-bucket. Reads fail. Why?

Question 4

4.What does a role's trust policy control?

Quiz score: 0 of 4

Tip: answer every quiz question correctly first.

Noviq Academy is free and for learning. The AWS command line and console in this course are simulated with a made-up account and dummy data. If you practise in a real AWS account, use a dedicated sandbox, enable MFA and budget notifications, and delete everything when you finish: you are responsible for any charges. AWS and Amazon S3 are trademarks of Amazon.com, Inc.; this course is independent of AWS.