SkillSprout
Chapter 3 · Lesson 5
Intermediate
8 min read

Best Practices

Overview

IAM is the front door to your AWS environment, so most real-world breaches come from leaked keys, over-permissive policies and missing MFA rather than clever hacking. AWS publishes a set of IAM security best practices that reduce that risk dramatically, and the SAA-C03 exam expects you to apply them when choosing between several "working" designs.

The headline ideas are simple: protect the root user, require MFA, use temporary credentials (roles and federation) rather than long-term keys, grant least privilege, use groups and guardrails, and monitor and review continuously.

This lesson turns those principles into a practical checklist, with the tools that help you do it: Access Analyzer, credential reports, CloudTrail, Config, Security Hub and AWS Organizations SCPs.

Key Concepts

  • Secure the root user: MFA, no access keys, unique email/mailbox, use only for tasks that require root.
  • Require MFA for all human users, especially privileged ones; prefer phishing-resistant FIDO2 passkeys / security keys.
  • Use temporary credentials (roles, Identity Center, federation) instead of long-term access keys.
  • Apply least privilege: start minimal, add as needed, and use Access Analyzer to refine.
  • Use groups for permissions and customer managed policies for reuse; avoid attaching policies to individual users.
  • Rotate and remove unused credentials; review with the credential report and Access Advisor.
  • Add guardrails: SCPs, permissions boundaries and conditions (MFA, Region, source VPC/IP).
  • Monitor: CloudTrail in all Regions, GuardDuty, Config rules, IAM Access Analyzer and alerts on root usage.
  • Multi-account strategy with AWS Organizations separates workloads and limits the blast radius.

Detailed Notes

The checklist (and the reasoning)

#PracticeWhy it mattersAWS feature
1Lock down the root userUnrestricted power; no policy can limit it in a standalone accountMFA, delete root keys, alarm on root sign-in
2Require MFAStolen passwords alone become uselessVirtual/FIDO2 MFA, aws:MultiFactorAuthPresent condition
3Use roles/temporary credentialsNothing long-lived to leakSTS, instance profiles, Identity Center, OIDC federation
4Least privilegeLimits blast radius of a compromised identityAccess Analyzer policy generation, Policy Simulator
5Use groups / permission setsConsistent, auditable permissionsIAM groups, Identity Center permission sets
6Remove unused identities and permissionsDormant credentials are prime targetsCredential report, Access Advisor, unused-access findings
7Rotate keysReduces exposure windowSecrets Manager rotation, 90-day key rotation
8Use conditionsContext-aware accessaws:SourceIp, aws:SourceVpce, aws:RequestedRegion, tags
9Guardrails across accountsPrevent dangerous actions even by adminsOrganizations SCPs, permissions boundaries
10Monitor and auditDetect misuse quicklyCloudTrail, GuardDuty, Config, Security Hub, CloudWatch alarms

Protecting the root user in detail

  • Use a dedicated, monitored email distribution list and a strong, unique password stored in a vault.
  • Register MFA (hardware key or passkey), ideally more than one device (up to 8).
  • Never create access keys for root; delete any existing.
  • Alert on every root sign-in with an EventBridge rule on the ConsoleLogin event for the root identity, forwarded to SNS.
  • In an Organization, use centralised root access management to remove root credentials from member accounts.

Prefer temporary credentials

ScenarioDo thisNot this
EC2 app calls S3Instance profile roleAccess keys in a config file
Lambda writes to DynamoDBExecution roleKeys in environment variables
GitHub Actions deploys stacksOIDC trust to a roleStored access key secrets
Engineers use CLIIAM Identity Center aws sso loginShared IAM users
Partner needs accessCross-account role + External IDCreating IAM users for them

Least privilege workflow

  1. Begin with AWS managed job-function policies to get going.
  2. Run workloads and collect CloudTrail activity.
  3. Use IAM Access Analyzer policy generation to produce a tight policy.
  4. Check Access Advisor for services never accessed and remove them.
  5. Add conditions and resource-level scoping.
  6. Test with the Policy Simulator; deploy via IaC with peer review.

Detecting and enforcing

bash
# Who has no MFA? Generate and read the credential report
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 -d > report.csv

# Policies that allow wildcard admin: list users/roles with AdministratorAccess
aws iam list-entities-for-policy \
  --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
yaml
# AWS Config managed rules that enforce IAM hygiene (CloudFormation excerpt)
RootMfaRule:
  Type: AWS::Config::ConfigRule
  Properties:
    ConfigRuleName: root-account-mfa-enabled
    Source: { Owner: AWS, SourceIdentifier: ROOT_ACCOUNT_MFA_ENABLED }
AccessKeyRotationRule:
  Type: AWS::Config::ConfigRule
  Properties:
    ConfigRuleName: access-keys-rotated
    InputParameters: { maxAccessKeyAge: "90" }
    Source: { Owner: AWS, SourceIdentifier: ACCESS_KEYS_ROTATED }

Force MFA with a policy

json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "DenyAllExceptMfaSetupWhenNoMfa",
    "Effect": "Deny",
    "NotAction": [
      "iam:CreateVirtualMFADevice", "iam:EnableMFADevice",
      "iam:ListMFADevices", "iam:ListVirtualMFADevices",
      "iam:ResyncMFADevice", "iam:ChangePassword", "sts:GetSessionToken"
    ],
    "Resource": "*",
    "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } }
  }]
}

Multi-account guardrails

Use AWS Organizations and Control Tower to separate environments (prod, dev, security, log archive). Apply SCPs to deny risky actions (leaving the Organization, disabling CloudTrail/GuardDuty, creating IAM users, using unapproved Regions). Centralise logs in a dedicated account, and use delegated administrators for security services.

Key numbers to remember

ItemRecommendation / limit
Access key rotationAt least every 90 days (or eliminate keys)
Access keys per userMax 2
Role session default1 h (max 12 h; chaining 1 h)
MFA devices per userUp to 8
Users / groups per account5,000 / 300
Password policyMin length up to 128; reuse prevention up to 24

Real World Example

Scenario — a start-up cleans up after a leaked key incident.

A fintech start-up discovered that an engineer's long-lived access key, committed to a public repository, had been used to launch cryptocurrency miners in unused Regions, producing a surprise five-figure bill.

After the incident the team rebuilt its IAM posture using best practices. The root user now has a hardware MFA key stored in a safe, no access keys, and an EventBridge alarm on any root sign-in. Engineers log in with IAM Identity Center + MFA and receive 8-hour temporary credentials; IAM users were deleted except one tightly scoped break-glass account. Workloads use roles: EC2 instance profiles, Lambda execution roles and GitHub OIDC for deployments, so no key exists to leak.

An SCP denies every Region except the two approved ones and blocks disabling CloudTrail. Access Analyzer and Config rules run continuously, and GuardDuty raises an alert for unusual API behaviour. A quarterly review uses the credential report and Access Advisor to prune permissions. The next simulated leak attempt fails: no keys, no unapproved Regions and an alert within minutes.

Architecture Diagram

Layered IAM security controls
Architecture
AWS Cloud
WorkforceSSO + MFA
Workloadsinstance roles
Member account
Organizations SCPsguardrails
Least-privilege rolesboundaries + conditions

Monitoring

CloudTrail
GuardDuty
AWS Config

Federated users and workload roles obtain temporary credentials, guardrails limit what is possible, and monitoring detects misuse.

  1. 1People sign in through the identity provider or IAM Identity Center with MFA; workloads use attached roles.
  2. 2STS issues short-lived credentials, so there are no permanent keys to steal.
  3. 3SCPs and permissions boundaries cap what the roles can ever do, even if a policy is too broad.
  4. 4CloudTrail, GuardDuty and Config record activity and raise alerts for risky behaviour or drift.

Best Practices

  • ✓Protect the root user with hardware/FIDO MFA, no access keys, a shared mailbox and alerting on any usage.
  • ✓Eliminate long-term access keys wherever possible: use roles, Identity Center, OIDC and IAM Roles Anywhere.
  • ✓Enforce MFA with policy conditions and prefer phishing-resistant authenticators.
  • ✓Grant least privilege and iterate using Access Analyzer policy generation and Access Advisor.
  • ✓Use SCPs and permission boundaries as non-bypassable guardrails (approved Regions, protect CloudTrail, deny leaving the organisation).
  • ✓Rotate and delete credentials: keys older than 90 days, unused users, stale passwords; automate with Config rules.
  • ✓Enable CloudTrail (organisation trail, all Regions), GuardDuty and Security Hub; alert on root activity and policy changes.
  • ✓Use separate AWS accounts per environment/workload with Organizations and Control Tower.

Common Interview Questions

Exam Tips

SAA-C03 focus

  • "Most secure way for an application to access AWS" -> IAM role (temporary credentials), never access keys.
  • "Principle of least privilege" -> grant only what is needed; scope resources and conditions. Avoid *:*.
  • Root user: enable MFA, don't create access keys, don't use daily. Tasks requiring root: close account, change support plan, change root details.
  • "Restrict what all accounts in an organisation can do" -> SCP. "Limit a developer-created role's power" -> permissions boundary.
  • "Which users have no MFA / old keys?" -> IAM credential report. "Which services are unused?" -> Access Advisor.
  • "Identify resources shared with external entities" -> IAM Access Analyzer.
  • "Audit who made an API call" -> CloudTrail; "detect compromised credentials / unusual behaviour" -> GuardDuty.
  • "Rotate credentials automatically" -> Secrets Manager rotation; prefer IAM roles which rotate automatically.

Chapter quiz

Identity and Access Management · 5 questions

  1. 1.An application runs on Amazon EC2 instances and must read objects from an Amazon S3 bucket. What is the MOST secure way to provide the required permissions?

  2. 2.A company has 100 developers who all need the same permissions. New developers join and leave frequently. Which approach minimises administrative effort and keeps permissions consistent?

  3. 3.An AWS account has an IAM user whose group policy allows s3:DeleteObject on a bucket. The user also has an attached policy that explicitly denies s3:DeleteObject on the same bucket. What is the result when the user tries to delete an object?

  4. 4.A company wants a third-party auditing vendor to read configuration data in the company's AWS account without sharing long-term credentials and while protecting against the confused deputy problem. What should a solutions architect do?

  5. 5.A security team wants to guarantee that no principal in any member account of an AWS Organization can launch resources outside two approved Regions, even if an administrator in the account grants broader IAM permissions. Which feature should be used?

0 of 5 answered

Finished this lesson?

0 of 64 lessons done · 0% of the course