Hands-On Mini Lab

IAM Role and Temporary Credentials Lab

No AWS service charge for IAM or STS. Use a sandbox account.

Goal

Reinforce Trust policies, Permissions policies, STS temporary credentials, Least privilege through a small, inspectable activity. This is a learning exercise, not a production design: use a dedicated sandbox or test account, record what you observe, and do not copy the permissions or data-handling choices into production without review.

What you should be able to explain afterward: what AWS managed for you, what you configured, what evidence proves the result, and what could continue to cost money or expose data if you leave it behind.

Concepts Reinforced

  • Trust policies
  • Permissions policies
  • STS temporary credentials
  • Least privilege

Prerequisites

  • AWS CLI configured for a sandbox account
  • Permission to create and delete IAM roles

Before you start

  1. Choose one AWS Region and write it down; many resources and console views are Region-specific.
  2. Confirm that you are operating only in an authorized non-production account and that you can identify the account ID before creating anything.
  3. Open the AWS service documentation linked below if a console label or command option is unfamiliar. The lab is successful when you understand the observation, not when you click through it quickly.

Estimated Cost

Exact Steps

Read the entire sequence before beginning. Substitute your own test names for every placeholder, keep the Region consistent, and pause after each step to inspect the result. If a command returns an error, do not repeatedly retry it without reading the error: check Region, account, permissions, resource identifiers, and whether the preceding step actually completed.

  1. Create a role with a trust policy that allows your current principal to assume it.
  2. Attach a small permissions policy such as read-only access to one test bucket or no permissions beyond sts:GetCallerIdentity for inspection.
  3. Run aws sts assume-role with the role ARN and inspect the returned AccessKeyId, SecretAccessKey, SessionToken, and Expiration fields.
  4. Use the temporary credentials to run aws sts get-caller-identity and confirm the assumed-role ARN.
Runnable example after replacing placeholders
aws sts assume-role --role-arn arn:aws:iam::111122223333:role/DJamesStudyRole --role-session-name djames-study

Verification

Verification is the evidence that the concept worked. Capture the relevant ARN, status, identity, log entry, policy result, object version, or query output before cleanup. A successful command alone is not proof that the intended control behaved correctly.

  • The caller identity shows an assumed-role ARN.
  • The session expires and cannot be used indefinitely.
  • Actions outside the attached policy fail.

If the result is different

  • Confirm the selected Region and AWS account.
  • Check the exact resource identifier and current status.
  • Review the service event history, CloudTrail event, CloudWatch log, or command output when available.
  • Re-read the relevant IAM policy, trust policy, security rule, or service setting instead of assuming the service is at fault.

Cleanup Steps

Cleanup is part of the lab. Remove test resources in dependency order, delete temporary credentials or local files, and check the billing or resource console for anything that remains. Some services retain versions, snapshots, logs, or recovery artifacts even after the visible parent resource is deleted.

  • Delete attached policies created for the lab.
  • Delete the IAM role.

Sources and Review Metadata