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
Recall & Review
beginner
What is the main purpose of assuming a role in AWS?
Assuming a role allows a user or service to temporarily gain permissions defined by that role, enabling secure and controlled access without sharing long-term credentials.
Click to reveal answer
beginner
What AWS service is commonly used to assume roles for temporary credentials?
AWS Security Token Service (STS) is used to assume roles and provide temporary security credentials.
Click to reveal answer
intermediate
What is the maximum duration for temporary credentials when assuming a role using AWS STS?
The maximum duration is 12 hours by default, but it can be shorter or longer (up to 12 hours) depending on the role's session duration setting.
Click to reveal answer
intermediate
How does assuming a role improve security compared to using long-term IAM user credentials?
It reduces risk by limiting the time credentials are valid and avoids sharing permanent access keys, making it easier to manage and revoke access.
Click to reveal answer
beginner
What is a trust policy in the context of AWS roles?
A trust policy defines which entities (users, services, accounts) are allowed to assume the role.
Click to reveal answer
Which AWS service provides temporary credentials when assuming a role?
AAmazon S3
BAWS Identity and Access Management (IAM)
CAWS CloudTrail
DAWS Security Token Service (STS)
✗ Incorrect
AWS STS issues temporary credentials when you assume a role.
What is the maximum default session duration for an assumed role?
A12 hours
B1 hour
C24 hours
D7 days
✗ Incorrect
The maximum session duration for an assumed role is 12 hours by default.
What does a trust policy specify in an IAM role?
AWhich entities can assume the role
BWhich actions the role can perform
CThe password policy for users
DThe billing details for the account
✗ Incorrect
A trust policy defines who can assume the role.
Why is assuming roles preferred over sharing long-term IAM user credentials?
A. A JSON with temporary security credentials including AccessKeyId, SecretAccessKey, and SessionToken.
B. An error saying 'role not found' because the ARN is invalid.
C. A list of all IAM users in the account.
D. A confirmation message that the role was created.
Solution
Step 1: Understand the command output
The aws sts assume-role command returns temporary credentials in JSON format.
Step 2: Analyze options
Only 'A JSON with temporary security credentials including AccessKeyId, SecretAccessKey, and SessionToken.' correctly describes the expected JSON output with temporary keys. Others describe errors or unrelated outputs.
Final Answer:
A JSON with temporary security credentials including AccessKeyId, SecretAccessKey, and SessionToken. -> Option A
Hint: AccessDenied usually means missing assume-role permission [OK]
Common Mistakes:
Assuming CLI installation causes AccessDenied
Ignoring required role session name
Blaming account suspension without checking permissions
5. You want to allow an EC2 instance to assume a role temporarily to access S3 buckets. Which combination is correct?
hard
A. Manually run aws sts assume-role on the EC2 instance without any IAM role attached.
B. Create an IAM user with S3 permissions and store its permanent keys on the EC2 instance.
C. Attach an IAM role with S3 permissions to the EC2 instance and use the instance profile to assume the role automatically.
D. Attach a security group to the EC2 instance that allows S3 access.
Solution
Step 1: Understand EC2 role usage
Attaching an IAM role to EC2 via instance profile allows automatic temporary credentials for S3 access.
Step 2: Evaluate other options
Manually running aws sts assume-role without an attached IAM role fails due to lack of initial credentials. Using permanent IAM user keys is less secure. Security groups control network access, not IAM permissions.
Final Answer:
Attach an IAM role with S3 permissions to the EC2 instance and use the instance profile to assume the role automatically. -> Option C
Quick Check:
EC2 uses instance profile role for temporary access [OK]
Hint: Use instance profile roles for EC2 temporary access [OK]