Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Create a Basic AWS IAM Policy JSON
📖 Scenario: You are setting up permissions for a new AWS user who needs to read objects from a specific S3 bucket.
🎯 Goal: Build a valid AWS IAM policy in JSON format that allows read-only access to the example-bucket S3 bucket.
📋 What You'll Learn
Create a JSON policy with the correct version
Specify the S3 service in the policy
Allow the action s3:GetObject
Restrict access to the bucket named example-bucket
Use the correct resource ARN format for the bucket objects
💡 Why This Matters
🌍 Real World
IAM policies control who can do what in AWS. Creating correct policies is essential for security and access management.
💼 Career
Cloud engineers and administrators regularly write and manage IAM policies to secure AWS resources.
Progress0 / 4 steps
1
Create the basic IAM policy structure
Create a variable called policy and assign it a dictionary with the key Version set to the string "2012-10-17".
AWS
Hint
The Version key is required in every IAM policy and usually set to "2012-10-17".
2
Add the Statement list with one statement
Add a key Statement to the policy dictionary. Set it to a list containing one dictionary with the key Effect set to "Allow".
AWS
Hint
The Statement key holds a list of permission statements. Each statement needs an Effect key.
3
Specify the Action and Resource in the statement
Inside the statement dictionary in policy["Statement"], add the key Action with the value "s3:GetObject" and the key Resource with the value "arn:aws:s3:::example-bucket/*".
AWS
Hint
The Action specifies what is allowed. The Resource specifies which bucket objects are accessible.
4
Complete the IAM policy JSON structure
Ensure the policy dictionary is a complete valid IAM policy JSON with Version, Statement list containing one statement with Effect, Action, and Resource keys as specified.
AWS
Hint
Review the entire policy dictionary to confirm it matches the required structure.
Practice
(1/5)
1. What is the main purpose of an IAM policy in AWS?
easy
A. To create virtual machines
B. To define permissions for users and resources
C. To monitor network traffic
D. To store data in the cloud
Solution
Step 1: Understand IAM policy role
An IAM policy is a JSON document that specifies permissions for AWS users, groups, or roles.
Step 2: Identify main function
Its main function is to control what actions are allowed or denied on AWS resources.
Final Answer:
To define permissions for users and resources -> Option B
Quick Check:
IAM policy = permissions definition [OK]
Hint: IAM policies control access permissions in AWS [OK]
Common Mistakes:
Confusing IAM policies with data storage
Thinking IAM policies monitor network traffic
Assuming IAM policies create virtual machines
2. Which of the following is the correct JSON key to specify the effect of a statement in an IAM policy?
easy
A. "Permission"
B. "Action"
C. "Resource"
D. "Effect"
Solution
Step 1: Recall IAM policy statement keys
IAM policy statements include keys like Effect, Action, Resource, and optionally Condition.
Step 2: Identify key for permission type
The key that specifies whether to allow or deny is "Effect".
Final Answer:
"Effect" -> Option D
Quick Check:
Effect key = permission type [OK]
Hint: Effect key sets allow or deny in IAM policy [OK]
B. The Condition key should be inside the Action key
C. The policy is valid and has no errors
D. The Resource value "*" is not allowed for these actions
Solution
Step 1: Check Condition usage with EC2 actions
EC2 supports conditions like StringEquals on ec2:Region to restrict actions by region.
Step 2: Verify Resource and structure
Resource "*" is valid for EC2 start/stop actions because they apply to instances across resources.
Final Answer:
The policy is valid and has no errors -> Option C
Quick Check:
Condition on ec2:Region with Resource "*" is valid [OK]
Hint: Conditions can restrict actions by region or other keys [OK]
Common Mistakes:
Thinking Condition is invalid for EC2
Assuming Resource "*" is always wrong
Misplacing Condition inside Action
5. You want to create an IAM policy that allows a user to read objects only from a specific S3 bucket named "my-data-bucket" but denies deleting any objects. Which policy statement correctly achieves this?
hard
A. {
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::my-data-bucket/*"
}
B. {
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::my-data-bucket/*"
}
C. {
"Effect": "Deny",
"Action": "s3:DeleteObject",
"Resource": "arn:aws:s3:::my-data-bucket/*"
}
D. {
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-data-bucket"
}
Solution
Step 1: Identify required permissions
The user needs permission to read objects only, which is "s3:GetObject" on the bucket's objects.
Step 2: Check for delete denial
Not including "s3:DeleteObject" means no delete permission is granted. Explicit deny is not required if no allow exists.
Step 3: Validate resource ARN
The resource must include "/*" to specify objects inside the bucket, not the bucket itself.
Final Answer:
Allow s3:GetObject on objects in my-data-bucket only -> Option A