Sub topic 1
What IAM Access Analyzer does and why it matters
IAM Access Analyzer is an AWS service that examines your IAM policies and resource configuration and reports access you probably did not intend. It looks for two kinds of risk: resources that outsiders can reach, and permissions or credentials that nobody uses. This chapter explains the working model. Later chapters cover each part in detail.
Prerequisites
This chapter assumes you already know the following:
- Basic IAM concepts: users, roles, identity-based policies and resource-based policies.
- How to read a JSON policy document, including Effect, Principal, Action, Resource and Condition.
- How to use the AWS CLI or the AWS console.
- What an AWS account is, and roughly what AWS Organizations does.
The problem it solves
Access in AWS grows over time. A developer adds s3:* to get past an error. A bucket policy is opened for a test. A role is created for a project that later ends. Each change was reasonable when made. Together they leave you with two risks:
- External exposure. A resource such as an S3 bucket, IAM role or KMS key can be used by a principal outside your account or organization.
- Excess access. An identity holds permissions, credentials or whole roles that it never uses. If the identity is compromised, an attacker gets all of that access.
Reading every policy by hand does not scale. Access Analyzer automates the review and reports what it finds as findings.
How it works
You create an analyzer, which is an AWS resource that scans a defined scope. The scope is either a single account or an organization. An analyzer produces findings. A finding is a record that names a resource or identity, describes the access or the unused item, and carries a status.
Access Analyzer uses two different methods:
- External access analysis uses automated reasoning to evaluate resource-based policies and related settings. It does not send test requests. It works out which principals outside your zone of trust could gain access, and it reports the resource, the external principal, the allowed actions and any conditions.
- Unused access analysis reviews IAM activity for roles and users. It reports roles that have not been used, access keys and passwords that have not been used, and permissions that have been granted but not exercised, all measured against a tracking period you choose.
The zone of trust is the boundary your analyzer treats as trusted: the account or the organization. Access from inside the zone is not reported as external. Access from outside it is.
A worked example
This bucket policy lets any principal read objects:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowEveryoneRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-bucket/*"
}
]
}An external access analyzer reports a public access finding for example-bucket, because "Principal": "*" reaches outside any zone of trust. If the bucket is a public website, you archive the finding. If it is not, you fix the policy.
To start, create one analyzer of each main kind:
# External access analyzer for the current account
aws accessanalyzer create-analyzer \
--analyzer-name account-external \
--type ACCOUNT
# Unused access analyzer that flags access unused for 90 days
aws accessanalyzer create-analyzer \
--analyzer-name account-unused \
--type ACCOUNT_UNUSED_ACCESS \
--configuration '{"unusedAccess":{"unusedAccessAge":90}}'The unusedAccessAge value is the number of days without use before Access Analyzer reports an item. Analyzers are regional, so create them in each Region you use.
Common mistakes
- Treating every finding as a problem. Some sharing is intended, such as a public website bucket or a partner account. Archive rules, covered later, handle this.
- Treating "unused" as "safe to remove." A role used only once a year, for example for quarterly reporting, can look unused in a 90-day window.
- Creating an analyzer in one Region and assuming it covers the others.
Exercise
A bucket policy has "Principal": "*" and allows s3:GetObject. Which analyzer type reports it, and what are two valid responses to the finding?
Show answer
An external access analyzer reports it. You can either archive the finding if the public access is intended, or edit the bucket policy to remove or restrict the principal if it is not.
Exercise
Your unused access analyzer is set to 90 days. A role that runs a yearly audit job appears as unused. What should you check before removing it?
Show answer
Check whether the role is still needed outside the tracking window, for example by asking its owner or reviewing CloudTrail history. A short window can flag roles with legitimate infrequent use.