3.7 IAM Access Analyzer: Finding Unintended Resource Exposure
Right, so you’ve built this beautiful, intricate Rube Goldberg machine of an AWS environment. It has all the moving parts: S3 buckets, SQS queues, KMS keys. But here’s the uncomfortable question: did you, in your haste to just get the darn thing working, accidentally leave a door wide open to the entire internet? It happens to the best of us. IAM Access Analyzer is the brilliant, slightly paranoid friend who walks around your house checking all the windows and doors you forgot about. It doesn’t just look at your IAM policies; it analyzes the resource-based policies on over 20 types of AWS resources to find ones that grant access to a principal outside of your trusted zone.
Think of it this way: your AWS account has a “trust boundary.” Inside that boundary are your accounts, your users, your roles. Anything outside of that—another AWS account, an IAM user from another account, the anonymous public (a.k.a. the whole internet)—is an “external principal.” Granting access to an external principal is a huge deal, and it should always be intentional. Access Analyzer’s entire job is to find the unintentional ones.
How It Actually Works: The Magic of Zones
The core of Access Analyzer is the concept of a zone of trust. You define what “trusted” means. For a single account, your zone of trust is just that account. For an AWS Organization, it’s every account within that organization. When you fire it up, it scours every supported resource in its scope (all resources in the account, or across all accounts in the Org) and examines their resource-based policies. For every policy statement, it asks: “Does this grant access to a principal outside my defined zone of trust?”
If the answer is yes, it generates a finding. This is the critical bit. A finding doesn’t mean “this is bad.” It means “this is potentially unintended, and you should look at it.” You might have a public S3 bucket for your company’s logos. That’s a valid finding, and you can mark it as “not a risk” by archiving it. The power is in sifting through the findings to find the truly horrifying mistakes, like that one SQS queue you configured at 3 AM that grants "Principal": "*" (yes, I’ve done it).
Enabling It and Seeing the Horror (or Lack Thereof)
Enabling it is a one-liner via the CLI. You specify an analyzer name and the type of zone of trust (ACCOUNT or ORGANIZATION). Do this right now. I’ll wait.
aws accessanalyzer create-analyzer --analyzer-name "MyAccountAnalyzer" --type ACCOUNT
Once it’s enabled (it takes a few minutes to do its first sweep), you can list the findings. Be prepared for a potential facepalm moment.
aws accessanalyzer list-findings --analyzer-arn arn:aws:access-analyzer:us-east-1:123456789012:analyzer/MyAccountAnalyzer
The output will be a list of finding ARNs. To get the juicy, terrifying details of a specific finding, use the get-finding command.
aws accessanalyzer get-finding --analyzer-arn arn:aws:access-analyzer:us-east-1:123456789012:analyzer/MyAccountAnalyzer --id 123e4567-e89b-12d3-a456-426614174000
This returns a glorious JSON blob that tells you exactly which resource is exposed (resource), what the offending policy is (resourceType and resourceOwnerAccount), and the specific statement in the policy that’s causing the issue (condition and action). This is your roadmap to fixing the problem.
The Most Common Culprits: S3 and KMS
Nine times out of ten, your findings will be S3 buckets or KMS keys. AWS designed S3 permissions to be flexible, which is a polite way of saying it’s incredibly easy to shoot yourself in the foot. A "Principal": "*" without a "Condition": {"Bool": {"aws:SecureTransport": "false"}} is a classic. This is Access Analyzer’s bread and butter.
KMS keys are another big one. You grant another account access to use a key for encryption, but then you delete that account. The policy statement granting access to that foreign account’s ARN remains, creating a dormant but very real finding. If that account number ever gets reused by someone else… well, you get the picture. Access Analyzer catches these “zombie grants.”
Proactive Guardrails: Using Access Analyzer with CI/CD
Here’s where you go from reactive to brilliant. You can integrate Access Analyzer directly into your CI/CD pipeline or Terraform/CDK workflows using policy validation. This means before you even deploy a resource with a sketchy policy, Access Analyzer can flag it and break the build.
You write an IAM policy that defines your organization’s security standards (e.g., “no S3 buckets can be publicly readable”), and then configure Access Analyzer to use it as a validation rule. Any CloudFormation template or Terraform plan that includes a policy violating this rule will fail. This shifts security left, and it’s the single best way to prevent these problems from ever reaching your production environment. It’s like having that paranoid friend looking over your shoulder while you code, which is exactly what you need.