AWS Fundamentals

Lesson 6 of 7

IAM Roles, Billing, and the Well-Architected Basics

Two last practical topics that matter on every real AWS project: giving your compute the right permissions without hardcoding credentials, and not getting an unpleasant billing surprise.

IAM roles for services, not just people

The single most important AWS security habit: an EC2 instance or Lambda function should be given an IAM role, not a hardcoded access key, to call other AWS services.

Lambda function → assumes an IAM Role → temporary credentials → calls S3, DynamoDB, etc.

The role is attached to the Lambda function (or EC2 instance) itself, AWS automatically provides temporary, auto-rotating credentials to your code, your application code never sees or stores a long-lived secret at all.

{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:PutObject"],
  "Resource": "arn:aws:s3:::my-app-uploads/*"
}

Attach this policy to the Lambda's execution role, and the function can read/write that one bucket, and nothing else, without a single access key in its code or environment variables.

Budgets and cost alerts

AWS bills for exactly what you use, which is powerful but means an unexpected spike (a runaway loop calling an expensive API, a forgotten large instance) shows up on your bill, not before it happens. AWS Budgets lets you set a threshold and get alerted (or even trigger an action) before costs run away:

Budget: $50/month
Alert at: 80% ($40) and 100% ($50)

Setting at least one budget alert on any real account, even a generous one, is a cheap insurance policy against a costly surprise.

The Well-Architected Framework, briefly

AWS's Well-Architected Framework organizes best practices into six pillars:

PillarCares about
Operational ExcellenceRunning and monitoring systems, learning from operations
SecurityProtecting data, systems, and assets
ReliabilityRecovering from failure, meeting demand
Performance EfficiencyUsing resources efficiently as demand changes
Cost OptimizationAvoiding unnecessary spend
SustainabilityMinimizing environmental impact

You don't need to memorize the framework in depth this early, but recognizing the six pillars helps you understand why AWS documentation and architecture reviews keep bringing up the same handful of concerns.

NOTE

Everything in this course so far, IAM roles over hardcoded keys, private subnets for databases, budgets, multi-AZ deployments, is really just the Security, Reliability, and Cost Optimization pillars in practice.

📝 IAM Roles & Billing Quiz

Passing score: 70%
  1. 1.What should an EC2 instance or Lambda function use to call other AWS services, instead of a hardcoded access key?

  2. 2.Credentials provided to a service through an IAM role are temporary and auto-rotating.

  3. 3.AWS ____ lets you set a spending threshold and get alerted before costs run away.

  4. 4.How many pillars does the AWS Well-Architected Framework have?

  5. 5.AWS bills a fixed amount regardless of how many resources you actually use.

  6. 6.Protecting data, systems, and assets is the concern of the ____ pillar in the Well-Architected Framework.