We close the IAM chapter with a practical list of best practices: the things you should always do to keep your AWS account secure. Consider it your security checklist. Many of these we have already seen throughout the chapter; here we bring them together and organize them so you can apply them from day one.

  1. Protect and do not use the root user

The root user (the email you used to create the account) has absolute power. It is your most sensitive asset.

  • Enable MFA on the root immediately (subchapter 7.4).
  • Do not generate access keys for the root. If it has them, delete them.
  • Do not use it for day-to-day tasks. Create an IAM administrator user for your work.
  • Store its credentials in a very secure place and use it only for the few tasks that strictly require it (such as closing the account or changing the support plan).

This is the number one practice. A compromised root account is a completely lost account.

  1. Enable MFA everywhere

  • MFA on the root (mandatory).
  • MFA on all users with relevant permissions, especially administrators.
  • For companies, consider enforcing MFA by policy (so nothing sensitive can be done without it).

  1. Apply least privilege (always)

The principle from subchapter 7.2, in concrete actions:

  • Grant only the necessary permissions, not AdministratorAccess for convenience.
  • Be specific with actions and resources.
  • Review periodically and remove permissions that are no longer used.
  • Use IAM Access Analyzer (a free AWS tool) to detect excessive permissions or unintended external access.

  1. Use groups to manage people’s permissions

  • Do not attach policies user by user. Create groups by function (Developers, Administrators, Support…) and assign permissions to the group.
  • Adding or removing someone is as simple as putting them in or taking them out of the group.
  • Easier to maintain and less prone to errors.

  1. Use roles for services and applications

  • Never embed access keys inside an EC2 instance, a Lambda, or your application code.
  • Assign a role with just the right permissions (subchapters 7.1 and 7.4). The service obtains temporary credentials automatically, with no keys to steal.
  • This also applies to your CI/CD pipeline and tools like Terraform.

  1. Avoid permanent access keys

  • Prefer temporary credentials (STS / roles) whenever possible.
  • If you need permanent keys for a person, rotate them regularly (change them every so often).
  • Never upload keys to a Git repository. Use a secrets manager (Chapter 23) and tools that detect keys in code before uploading.
  • Deactivate keys that are not used.

Reminder of the real danger: bots scan GitHub looking for leaked keys and exploit them in seconds. A leaked permanent key with many permissions can cost you thousands of euros. Treat keys like passwords: secret, rotated, and minimal.

  1. Use strong passwords and a password policy

  • Define a password policy in your account: minimum length, mix of characters, reasonable expiration, no reuse.
  • Encourage the use of password managers.

  1. Log and monitor activity (audit)

You can’t protect what you can’t see. Enable logging of who does what:

  • AWS CloudTrail: logs all actions performed in your account (who, what, when). It’s your “security camera.” Essential and you should enable it from the start.
  • CloudWatch (Chapter 24) for alarms on suspicious activity.
  • GuardDuty (Chapter 23) for automatic threat detection.

We’ll see these tools in Part VI; for now, remember that auditing is part of security.

  1. Centralize identity if you have a team

  • For multiple people or multiple accounts, use AWS IAM Identity Center (formerly AWS SSO): centralized access, with temporary credentials and MFA, without creating IAM users one by one.
  • In large environments, combine with AWS Organizations and Service Control Policies (Chapters 23 and 30) to set limits at the organization level.

The summarized checklist

Your minimum IAM security list from day one:

[ ] MFA enabled on the root user
[ ] Root user without access keys and stored securely
[ ] IAM administrator user for daily work (with MFA)
[ ] Least privilege permissions (no admin "just in case")
[ ] Groups to manage people’s permissions
[ ] Roles (not keys) for EC2, Lambda, and other services
[ ] No permanent keys in code or in Git
[ ] Password policy configured
[ ] CloudTrail enabled to audit activity

Tip: Set this up when creating the account, before you start building anything. It’s much easier to start from a secure base than to “fix security later.”

What you should remember

  • Protect the root (MFA, no keys, don’t use it daily): it’s the number one priority.
  • MFA everywhere and least privilege always.
  • Groups for people, roles for services; avoid permanent keys and never upload them to Git.
  • Audit with CloudTrail from the start: visibility is part of security.
  • For teams and multi-account, centralize with IAM Identity Center and Organizations.
  • Apply the checklist when creating the account, not after.

With this, you finish Chapter 7 and master identity and access. In Chapter 8, the last of the essential services, we’ll look at AWS’s managed databases.

Cloud, AWS & Terraform — From Zero to Expert

Chapter 1 · What is cloud computing

Chapter 2 · The cloud market and major providers

Chapter 3 · Regions, availability zones and edge

Chapter 4 · Compute: EC2

Chapter 5 · Storage: S3

Chapter 6 · Networking: VPC

Chapter 7 · Identity and access: IAM

Chapter 8 · Managed databases

Chapter 9 · Why Infrastructure as Code

Chapter 10 · HCL: the Terraform language

Chapter 11 · Providers and state

Chapter 12 · Your first real infrastructure in Terraform

Chapter 13 · Load balancing and auto scaling

Chapter 14 · Serverless with Lambda

Chapter 15 · Messaging and events

Chapter 16 · Content delivery and DNS

Chapter 17 · Containers on AWS

Chapter 18 · Modules: reuse and composition

Chapter 19 · Workspaces and environment management

Chapter 20 · Remote backends and locking

Chapter 21 · Infrastructure testing

Chapter 22 · Terraform in CI/CD

Chapter 23 · Defense in depth

Chapter 24 · Observability: logs, metrics and traces

Chapter 25 · Cost optimization

Chapter 26 · High availability and disaster recovery

Chapter 27 · AWS Well-Architected Framework

Chapter 28 · Serverless architectures at scale

Chapter 29 · Data platforms on AWS

Chapter 30 · Multi-account and landing zones

Chapter 31 · Platform Engineering and Internal Developer Platform

Chapter 32 · Relevant AWS certifications

Chapter 33 · Projects to consolidate what you've learned

Chapter 34 · Resources and community

© Copyright 2024. All rights reserved