Assignments
25 hands-on assignments in three levels: 10 ๐ข Beginner, 10 ๐ก Intermediate, 5 ๐ด Advanced. Do them in a sandbox account, tag everything, and delete what you create.
How to use these
Use the AWS CLI for every task, even where the console is easier; the CLI is what you will script and automate. Set a billing budget before you begin, work in one Region (ap-south-1 in our examples), and tag every resource with Project, Environment and Owner so cleanup is a single query. Hints are collapsed so you can try first.
๐ข Beginner
Assignment 1. Secure a new account ๐ข
Objective: Put the basic guardrails on a fresh AWS account before building anything.
Tasks
- Enable MFA on the root user and stop using root for daily work.
- Create an admin identity through IAM Identity Center, or an IAM user with MFA if Identity Center is unavailable.
- Configure the CLI with a named profile and confirm with
aws sts get-caller-identity. - Create a monthly cost budget of 10 USD that emails you at 80 percent.
Expected outcome: Root has MFA and no access keys, you work as a non-root identity, and a budget exists.
Hints
aws configure sso sets up an SSO profile. aws iam list-access-keys for root is checked in the console security credentials page. aws budgets create-budget takes a --budget JSON and --notifications-with-subscribers.
Bonus: Turn on a multi-Region CloudTrail trail delivering to an S3 bucket.
Assignment 2. Build a VPC by hand ๐ข
Objective: Understand what makes a subnet public or private.
Tasks
- Create a VPC
10.20.0.0/16with two public and two private subnets across two AZs. - Attach an internet gateway and create a public route table with a default route to it.
- Associate only the public subnets with that route table.
- Enable auto-assign public IP on the public subnets only.
Expected outcome: describe-route-tables shows exactly the two public subnets routed to igw-, and the private subnets have only the local route.
Hints
aws ec2 create-vpc, create-subnet --availability-zone, create-internet-gateway, attach-internet-gateway, create-route --destination-cidr-block 0.0.0.0/0, modify-subnet-attribute --map-public-ip-on-launch.
Bonus: Add a NAT gateway and a private route table, then explain its hourly cost.
Assignment 3. EC2 without SSH ๐ข
Objective: Manage an instance with Session Manager and an instance profile instead of key pairs.
Tasks
- Create an IAM role trusted by
ec2.amazonaws.comwithAmazonSSMManagedInstanceCoreattached, and an instance profile. - Launch a
t3.microAmazon Linux 2023 instance with that profile and no key pair, with IMDSv2 required. - Open a session with
aws ssm start-session. - From inside the instance, query metadata using IMDSv2 and print the instance ID.
Expected outcome: A working shell with no inbound ports open and no key pair on the instance.
Hints
Get the AMI from the SSM parameter /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64. The instance needs an outbound path (public IP or NAT) or VPC endpoints to register. IMDSv2 requires a PUT to /latest/api/token first. Use --metadata-options HttpTokens=required.
Bonus: Add a CloudWatch Logs session log destination in Session Manager preferences.
Assignment 4. Chained security groups ๐ข
Objective: Build tier isolation with security group references.
Tasks
- Create
web-sg(80 from anywhere),app-sg(8080 fromweb-sg) anddb-sg(5432 fromapp-sg). - Launch one instance in each of web and app tiers.
- Prove web can reach app on 8080 and that the internet cannot.
- Prove web cannot reach the database port directly.
Expected outcome: Reachability matches the diagram and you can show it with curl or nc -zv from the right places.
Hints
Use --ip-permissions "IpProtocol=tcp,FromPort=8080,ToPort=8080,UserIdGroupPairs=[{GroupId=sg-xxxx}]". Start a test listener with python3 -m http.server 8080.
Bonus: Explain why a stateless NACL would need extra ephemeral port rules for the same design.
Assignment 5. A properly locked-down S3 bucket ๐ข
Objective: Create a private, versioned, encrypted bucket with a lifecycle policy.
Tasks
- Create a bucket with a globally unique name and turn on all four Block Public Access settings.
- Enable versioning and default encryption.
- Add a lifecycle rule moving objects to Standard-IA after 30 days and expiring noncurrent versions after 90 days.
- Upload a file twice with different content and list both versions.
Expected outcome: get-public-access-block, get-bucket-versioning and get-bucket-lifecycle-configuration show the expected settings, and list-object-versions shows two versions.
Hints
aws s3api put-bucket-versioning --versioning-configuration Status=Enabled. Lifecycle JSON uses Transitions with StorageClass: STANDARD_IA and NoncurrentVersionExpiration with NoncurrentDays. A bucket outside us-east-1 needs --create-bucket-configuration LocationConstraint=<region>.
Bonus: Add a bucket policy that denies any request not using TLS (aws:SecureTransport is false).
Assignment 6. Static site on S3 and CloudFront ๐ข
Objective: Serve a private bucket through CloudFront with Origin Access Control.
Tasks
- Upload an
index.htmlto a private bucket. - Create an OAC and a distribution with
DefaultRootObjectset toindex.html. - Add a bucket policy that allows only your distribution's ARN to
s3:GetObject. - Confirm the CloudFront URL returns 200 and the direct S3 URL returns 403.
Expected outcome: Content is reachable only through CloudFront over HTTPS.
Hints
The policy principal is {"Service":"cloudfront.amazonaws.com"} with a condition StringEquals on AWS:SourceArn. Use aws cloudfront create-distribution --distribution-config file://.... Distribution deployment takes several minutes.
Bonus: Update the file, observe the stale cache, and fix it with aws cloudfront create-invalidation --paths "/index.html".
Assignment 7. Least-privilege S3 policy ๐ข
Objective: Write a policy that grants one action on one prefix and prove it.
Tasks
- Create an IAM role that can
s3:GetObjectonly onarn:aws:s3:::<bucket>/reports/*ands3:ListBucketonly with prefixreports/. - Use
aws iam simulate-principal-policyto test allowed and denied actions. - Assume the role and try to read an object outside the prefix.
- Record the exact
AccessDeniedmessage.
Expected outcome: Reads under reports/ succeed, everything else is denied.
Hints
s3:ListBucket applies to the bucket ARN and needs a Condition with StringLike on s3:prefix. GetObject applies to the object ARN with /*. Use aws sts assume-role and export the three temporary credential variables.
Bonus: Generate a policy from CloudTrail activity with IAM Access Analyzer policy generation.
Assignment 8. CPU alarm with SNS ๐ข
Objective: Get notified when an instance is hot.
Tasks
- Create an SNS topic and subscribe your email, then confirm the subscription.
- Create a CloudWatch alarm on
CPUUtilizationfor one instance, threshold 70 percent for 2 of 3 periods of 60 seconds. - Generate load with
stress-ngoryes > /dev/null. - Receive the email and clear the alarm by stopping the load.
Expected outcome: An ALARM email followed by an OK email.
Hints
aws cloudwatch put-metric-alarm --datapoints-to-alarm 2 --evaluation-periods 3. Basic monitoring is 5 minute resolution, so enable detailed monitoring with aws ec2 monitor-instances for 1 minute data. Test the path without load using set-alarm-state.
Bonus: Add an EC2 recover action for status check failures: arn:aws:automate:<region>:ec2:recover.
Assignment 9. ALB in front of two instances ๐ข
Objective: Load balance across AZs and watch health checks work.
Tasks
- Launch two instances in different AZs running nginx that prints their hostname.
- Create an ALB, a target group with a
/healthcheck, and an HTTP listener. - Register both instances and loop
curlto see responses alternate. - Stop nginx on one instance and watch it leave rotation.
Expected outcome: Traffic alternates, then goes only to the healthy instance, and describe-target-health shows the failure reason.
Hints
aws elbv2 create-target-group, register-targets, create-listener. The ALB needs two subnets in two AZs. The instance SG must allow port 80 from the ALB SG. Health transitions follow interval times threshold.
Bonus: Add a path-based rule that sends /api/* to a second target group.
Assignment 10. Tagging audit ๐ข
Objective: Define a tag standard and find what violates it.
Tasks
- Define required tags:
Project,Environment,Owner,CostCenter. - Create five resources of different types with and without the tags.
- Use the Resource Groups Tagging API to list resources missing a required tag.
- Write a short script that prints each untagged resource ARN.
Expected outcome: A repeatable command or script that lists noncompliant resources.
Hints
aws resourcegroupstaggingapi get-resources returns tags per resource; filter with --query or jq for entries lacking a key. The API only returns resources that have, or once had, tags, so completely untagged resources can be missed; cross-check with service calls such as aws ec2 describe-instances.
Bonus: Create an AWS Config managed rule required-tags to flag violations automatically.
๐ก Intermediate
Assignment 11. Auto Scaling with load test ๐ก
Objective: Watch a target tracking policy scale out and in.
Tasks
- Create a launch template with user data that installs nginx.
- Create an ASG (min 1, max 4) across two subnets behind an ALB.
- Add target tracking on
ALBRequestCountPerTargetwith a target of 50. - Drive load with
hey -z 5m -c 50 http://<alb>/and record scaling activities.
Expected outcome: Instance count rises under load, then falls after the cooldown, with timestamps captured from describe-scaling-activities.
Hints
For ALBRequestCountPerTarget the PredefinedMetricSpecification needs a ResourceLabel of the form app/<alb-name>/<id>/targetgroup/<tg-name>/<id>. Scale-in is deliberately slower than scale-out.
Bonus: Add a scheduled action that raises the minimum to 3 during business hours.
Assignment 12. Private RDS with a tunnel ๐ก
Objective: Reach a private database without a public IP or a bastion host.
Tasks
- Create an RDS PostgreSQL instance in private subnets with
--no-publicly-accessibleand a managed master password. - Launch an SSM-managed instance in the app subnet.
- Open a port-forward from your laptop with
AWS-StartPortForwardingSessionToRemoteHost. - Connect with
psqltolocalhostand run a query.
Expected outcome: A working local psql session through the tunnel and no inbound SG rule from the internet.
Hints
aws ssm start-session --target i-... --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"host":["<rds-endpoint>"],"portNumber":["5432"],"localPortNumber":["5433"]}'. Retrieve the password from the secret ARN shown in describe-db-instances.
Bonus: Enforce rds.force_ssl through a custom parameter group and prove non-TLS connections are rejected.
Assignment 13. Multi-AZ failover drill ๐ก
Objective: Measure what a failover does to a client.
Tasks
- Use a Multi-AZ instance from Assignment 12.
- Run a loop that executes
select 1every second and logs success or failure with timestamps. - Trigger
reboot-db-instance --force-failover. - Compute downtime from the log and compare the primary AZ before and after.
Expected outcome: A downtime figure (typically 60 to 120 seconds), a swapped AZ, and a note on what your client should do.
Hints
Use psql -c inside while true with date -u prefixed output. The endpoint hostname does not change; the DNS record behind it does. Set short connection timeouts such as connect_timeout=3.
Bonus: Repeat with Aurora and compare failover time.
Assignment 14. Cross-account role assumption ๐ก
Objective: Grant access across accounts without sharing keys.
Tasks
- In account B, create a role with a trust policy for account A's principal and an
sts:ExternalIdcondition. - In account A, allow a role or user to call
sts:AssumeRoleon it. - Assume it with the CLI and verify with
get-caller-identity. - Add
aws:MultiFactorAuthPresentto the trust policy and observe the failure without MFA.
Expected outcome: Role assumption succeeds only with the correct external ID and, for step 4, MFA.
Hints
aws sts assume-role --role-arn ... --role-session-name lab --external-id .... A named profile with role_arn, source_profile and external_id automates it. Both sides must allow it: trust policy in B and identity policy in A.
Bonus: Restrict the trust to your AWS Organization with aws:PrincipalOrgID.
Assignment 15. VPC endpoints instead of NAT ๐ก
Objective: Remove internet dependence for AWS API traffic.
Tasks
- Start with private instances that reach S3 and SSM through a NAT gateway.
- Add an S3 gateway endpoint and attach it to the private route table.
- Add interface endpoints for
ssm,ssmmessagesandec2messages. - Delete the NAT default route and confirm Session Manager and S3 still work.
Expected outcome: Private instances operate with no internet path, and you can explain the cost of interface endpoints per AZ per hour against NAT.
Hints
Interface endpoints need --private-dns-enabled and a security group allowing 443 from the instances. Gateway endpoints add a prefix-list route to the route table. aws ec2 describe-vpc-endpoints shows state.
Bonus: Add an endpoint policy that restricts the S3 endpoint to your own buckets.
Assignment 16. Route 53 failover routing ๐ก
Objective: Fail DNS over to a backup when the primary is unhealthy.
Tasks
- Create a health check against your primary endpoint
/health. - Create PRIMARY and SECONDARY failover records, the secondary pointing to a static S3 maintenance site or a second ALB.
- Break the primary and watch DNS answers change.
- Restore the primary and confirm it fails back.
Expected outcome: dig returns the secondary after the health check fails, with the TTL you chose bounding recovery time.
Hints
aws route53 create-health-check --caller-reference ... --health-check-config Type=HTTP,FullyQualifiedDomainName=...,ResourcePath=/health,RequestInterval=10,FailureThreshold=2. Records take Failover=PRIMARY, SetIdentifier and HealthCheckId. Use a low TTL for the lab.
Bonus: Replace failover with weighted records and do a 90/10 canary.
Assignment 17. HTTPS with ACM ๐ก
Objective: Terminate TLS on the ALB and redirect HTTP.
Tasks
- Request an ACM certificate for your domain with DNS validation.
- Create the validation CNAME in Route 53 and wait for
ISSUED. - Add an HTTPS listener on 443 with
ELBSecurityPolicy-TLS13-1-2-2021-06. - Change the port 80 listener to a permanent redirect to 443.
Expected outcome: curl -I http://domain returns 301 to HTTPS and the HTTPS site serves with a valid certificate.
Hints
aws acm request-certificate --domain-name ... --validation-method DNS, then describe-certificate for the validation record. Redirect action: Type=redirect,RedirectConfig={Protocol=HTTPS,Port=443,StatusCode=HTTP_301}. CloudFront certificates must be in us-east-1; ALB certificates must be in the ALB's Region.
Bonus: Add an ALB rule that returns a fixed 403 for requests missing a secret header, and have CloudFront add it.
Assignment 18. Investigate with CloudTrail ๐ก
Objective: Answer "who did this and when" from audit logs.
Tasks
- Ensure a trail logs management events to S3.
- Delete a security group rule or a tagged resource on purpose.
- Find the event with
aws cloudtrail lookup-eventsand extract user, source IP and request parameters. - Create an EventBridge rule that notifies SNS on
DeleteSecurityGroup.
Expected outcome: You can name the principal, time and parameters of the change, and a new deletion triggers a notification.
Hints
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=RevokeSecurityGroupIngress. Lookup covers 90 days of management events. EventBridge pattern: {"source":["aws.ec2"],"detail-type":["AWS API Call via CloudTrail"],"detail":{"eventName":["DeleteSecurityGroup"]}}.
Bonus: Query the S3 trail logs with Athena for all ConsoleLogin events without MFA.
Assignment 19. Logs to metrics to alarm ๐ก
Objective: Turn application log lines into an actionable alert.
Tasks
- Install the CloudWatch agent on an instance and ship
/var/log/nginx/access.loganderror.logto log groups with 14-day retention. - Create a metric filter that counts
5xxresponses. - Create an alarm on that metric that publishes to SNS.
- Generate 500s and receive the alert.
Expected outcome: Logs in CloudWatch, a custom metric on a graph, and an email when errors spike.
Hints
dnf install -y amazon-cloudwatch-agent, then amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:<parameter-name> -s. The instance role needs CloudWatchAgentServerPolicy. Metric filter pattern for a combined access log can use [ip, id, user, ts, req, status=5*, size]. aws logs put-retention-policy sets retention.
Bonus: Query the same logs with CloudWatch Logs Insights for the top 10 failing URLs.
Assignment 20. Secrets without baking them into the image ๐ก
Objective: Deliver configuration and secrets to instances securely.
Tasks
- Store a non-secret setting in SSM Parameter Store and a secret in Secrets Manager.
- Give an instance role access to only those two ARNs.
- Read both at boot in user data or a systemd unit.
- Rotate the secret and show the app picking up the new value without a redeploy.
Expected outcome: No secret in the AMI, user data or environment files at rest, and a documented rotation procedure.
Hints
aws ssm get-parameter --name /app/prod/log-level --with-decryption, aws secretsmanager get-secret-value --secret-id. Anything in user data is visible through describe-instance-attribute, so never place secrets there. For rotation use aws secretsmanager rotate-secret with a rotation Lambda, or put-secret-value manually for the lab.
Bonus: Compare monthly cost and features of Parameter Store SecureString and Secrets Manager.
๐ด Advanced
Assignment 21. Rebuild the lab as Terraform ๐ด
Objective: Express the whole HA stack as code with safe state handling.
Tasks
- Recreate the VPC, ALB, ASG, RDS Multi-AZ, S3, CloudFront and IAM from the lab in Terraform modules.
- Use an S3 backend with state locking and encryption.
- Introduce drift by changing a security group rule in the console, then detect it with
terraform plan. - Add a CI job that runs
fmt,validate,planon pull requests andapplyon merge after approval.
Expected outcome: terraform apply builds the stack from zero, plan is clean afterwards, and drift is caught.
Hints
Use default_tags in the AWS provider for cost tags. Use use_lockfile = true in the S3 backend on current Terraform versions, or a DynamoDB table on older ones. Use manage_master_user_password = true on aws_db_instance. Put lifecycle { create_before_destroy = true } on launch-template driven resources.
Bonus: Add checkov or tfsec to the pipeline and fix the findings.
Assignment 22. Multi-Region pilot light ๐ด
Objective: Build and test a disaster recovery plan with a measured RTO and RPO.
Tasks
- Replicate the assets bucket to a second Region with Cross-Region Replication.
- Create a cross-Region RDS read replica.
- Keep the secondary stack scaled to zero (ASG desired 0, launch template ready).
- Script the failover: promote the replica, scale the ASG, flip Route 53 failover records.
- Run the drill, record the time for each phase and the replication lag at cutover.
Expected outcome: A runbook with measured RTO and RPO, and evidence it works.
Hints
CRR needs versioning on both buckets and a replication role. aws rds create-db-instance-read-replica --source-db-instance-identifier <arn> --region <dr-region> (encrypted sources need --kms-key-id in the target Region). aws rds promote-read-replica is irreversible. AMIs must be copied with aws ec2 copy-image. Watch ReplicaLag in CloudWatch.
Bonus: Automate the failover with a Step Functions workflow triggered by a manual approval.
Assignment 23. Blue/green with automatic rollback ๐ด
Objective: Shift traffic between two versions with an alarm as the safety net.
Tasks
- Create two target groups (blue and green) with separate ASGs.
- Use a listener rule with weighted forwarding to move traffic 10, 50, 100 percent.
- Watch the 5xx and latency alarms between each step.
- Write a script that rolls back to 100 percent blue if any alarm enters
ALARM.
Expected outcome: A promotion that completes cleanly for a good build and rolls back automatically for a bad one.
Hints
aws elbv2 modify-listener --default-actions with ForwardConfig and TargetGroups=[{TargetGroupArn=...,Weight=...}]. Use aws cloudwatch describe-alarms --state-value ALARM --alarm-names ... in the loop. Enable target group stickiness only if you need it, as it skews weights.
Bonus: Implement the same flow with AWS CodeDeploy and its automatic rollback on alarms.
Assignment 24. Organization guardrails ๐ด
Objective: Enforce security rules that cannot be bypassed from inside a member account.
Tasks
- Create an Organizational Unit and a member account (or use a sandbox OU).
- Write an SCP that denies actions outside two approved Regions, except for global services.
- Write an SCP that denies disabling CloudTrail and deleting the S3 Block Public Access settings.
- Apply a permission boundary to a developer role so it cannot create IAM roles with more rights than itself.
- Prove each control by attempting the forbidden action as an administrator in the member account.
Expected outcome: Admin users in the member account receive explicit denies, with the exact error messages recorded.
Hints
SCPs never grant permissions, they cap them, and they do not affect the management account. Region denial uses aws:RequestedRegion with NotAction for global services such as iam:*, sts:*, cloudfront:*, route53:*, support:*. For privilege escalation protection, require iam:PermissionsBoundary on iam:CreateRole and iam:PutRolePermissionsBoundary. Test with aws iam simulate-principal-policy where possible.
Bonus: Turn on IAM Access Analyzer for the organization and review the external access findings.
Assignment 25. Cost optimization sprint ๐ด
Objective: Find savings in a running workload and prove them with numbers.
Tasks
- Run the lab stack for a day with a synthetic load, then pull cost by service and by tag with
aws ce get-cost-and-usage --group-by. - Identify the top three cost drivers and a cheaper design for each (NAT per AZ versus endpoints, Graviton, gp3, right-sized RDS, scheduled scaling).
- Apply at least three changes and measure again.
- Evaluate Savings Plans or Reserved Instances for the steady portion and compute the break-even.
- Write a one-page summary: before, after, percentage saved, risks.
Expected outcome: A documented reduction of at least 30 percent on the workload with the reasoning for each change.
Hints
aws ce get-cost-and-usage --time-period Start=...,End=... --granularity DAILY --metrics UnblendedCost --group-by Type=TAG,Key=Project. Graviton means t4g or m7g instances with an arm64 AMI. Compute Optimizer gives rightsizing recommendations via aws compute-optimizer get-ec2-instance-recommendations. Cost Explorer API calls are billed per request, so keep queries small.
Bonus: Create an anomaly monitor with aws ce create-anomaly-monitor and an alert subscription.