Skip to content

Get email notifications when access to your AWS accounts changes

7 minute read
Content level: Intermediate
1

This article explains how to get a readable email the moment access changes on the AWS accounts you choose to monitor, covering both IAM Identity Center and local IAM. The solution fills the gap left by the lack of a native, account-aware notification for access changes, and it enriches each event so the alert is actionable rather than raw.

Introduction

In a multi-account AWS organization, access changes constantly: account assignments in IAM Identity Center, group memberships, permission set policy changes, and local IAM identities created on member accounts. Each of these changes who can do what, and none of them notifies anyone on its own. CloudTrail records them, but reviewing CloudTrail after the fact means reading history rather than reacting to it.

This need came up while working with a customer running a large multi-account organization that had recently completed a security audit. They wanted to know, the same day, when access to a monitored account changed, and who changed it.

To address this, we built a small serverless solution and published it on the AWS Samples GitHub repository for immediate use. It emails you when access changes on the accounts you monitor, it is built entirely from managed AWS services, and there is nothing to run or patch.

It is worth being clear about where this fits. It does not replace IAM Access Analyzer or AWS Security Hub, which answer "who has access to what". It answers a different, complementary question, "what just changed, and on which account", in near real time.

This is sample code, for non-production usage. You should work with your security and legal teams to meet your organizational security, regulatory and compliance requirements before deployment.

Why use the Access Change Notifier?

  • Account-aware: it notifies you only when a change affects one of your monitored accounts, so you are not flooded with events from accounts you do not care about.
  • Readable alerts: it resolves IDs to names (permission set, group, user) and identifies the real user behind an assumed role, so the email names the person and the account, not a set of UUIDs.
  • Impact analysis: for events that do not name an account, such as a policy attached to a shared permission set, it works out which of your monitored accounts the change actually touches.
  • Fail open by design: if it cannot fully analyze an event, it still sends the alert and marks it for review, so a change is never silently missed.
  • Least privilege: the Lambda role can only read Identity Center and Identity Store to resolve names, and publish to its own SNS topic. It cannot modify access and has no inbound endpoint.
  • Serverless and low cost: it runs only when an access change happens, so there is nothing idle to pay for.

How it works

Enter image description here

  1. CloudTrail records the access-change API call and forwards it to EventBridge.
  2. An EventBridge rule matches only the events that change access.
  3. A Lambda function reads the event, resolves IDs to readable names, and works out which of your monitored accounts are affected.
  4. If a monitored account is involved, the function publishes a short message to an SNS topic, which delivers it by email.

The value is in the Lambda. A raw CloudTrail access event is hard to act on and often does not name an account. "A managed policy was attached to permission set ps-abc123" tells you nothing until you check which accounts use that permission set. The function does that lookup for you, resolves the permission set, group, and user to their names, finds the real user behind an assumed role, and stays quiet when none of your monitored accounts are affected.

What it detects

  • IAM Identity Center: account assignments, group membership changes, permission set policy changes, and permission set provisioning.
  • Local IAM (optional): creation of users, roles, access keys, login profiles, and policy attachments on monitored accounts.

The event lists in the template are a starting point. You can add any CloudTrail event name you care about and redeploy.

Prerequisites

Before deploying, ensure the following:

  • IAM Identity Center: enabled in your organization.
  • CloudTrail: a trail enabled, so the events are recorded.
  • Permissions: the ability to deploy from the account where Identity Center lives, usually the management or delegated administrator account.

Where to deploy

The most common mistake is deploying in the wrong Region. IAM Identity Center events reach EventBridge in the Region where the Identity Center instance lives, which is where the administrative action happens, so deploy the Identity Center part there. Global IAM events always reach EventBridge in us-east-1, so deploy the optional local IAM part there.

If you deploy in the wrong Region, the stack comes up clean and the SNS subscription confirms, but no alert ever arrives. If your Identity Center instance is already in us-east-1, deploy a single stack with both rules enabled rather than two, because the two stacks share Region-based resource names and would otherwise collide.

Deploy it

1. Identity Center monitoring. Run this in the Region where your Identity Center instance lives:

aws cloudformation deploy \
  --template-file templates/sample-access-change-notifier.yaml \
  --stack-name sample-access-change-notifier \
  --capabilities CAPABILITY_NAMED_IAM \
  --parameter-overrides \
      NotificationEmail=security-alerts@example.com \
      MonitoredAccountIds=123456789012,123456789013 \
      IdentityCenterInstanceArn=arn:aws:sso:::instance/ssoins-1234567890abcdef0 \
      EnableIdentityCenterRule=true \
      EnableIAMLocalRule=false

Find your Identity Center instance ARN with:

aws sso-admin list-instances --query "Instances[0].InstanceArn" --output text

2. Local IAM monitoring (optional). Global IAM events always land in us-east-1, so deploy this part there:

aws cloudformation deploy \
  --region us-east-1 \
  --template-file templates/sample-access-change-notifier.yaml \
  --stack-name sample-access-change-notifier-iam \
  --capabilities CAPABILITY_NAMED_IAM \
  --parameter-overrides \
      NotificationEmail=security-alerts@example.com \
      MonitoredAccountIds=123456789012,123456789013 \
      EnableIdentityCenterRule=false \
      EnableIAMLocalRule=true

3. Confirm the subscription. AWS sends a confirmation email to the address you set. Click "Confirm subscription", or no notifications are delivered.

Example output

Make a harmless change, for example assign a test group to one of your monitored accounts in the Identity Center console. Within a minute or two you receive an email like this:

ACCESS CHANGE DETECTED

NEW ACCESS GRANTED - principal assigned to account

Event:              CreateAccountAssignment
Impacted Accounts:  123456789013

WHO PERFORMED THIS ACTION
Username:   jdoe (via role: Admin)

WHAT WAS CHANGED
Account:        123456789013
Principal:      Developers (GROUP)
Permission Set: PowerUserAccess

Make the same change against an account that is not in your list and nothing arrives, because the function filtered it out.

Customizing

  • Change which accounts you watch: update the stack with a new MonitoredAccountIds value. Use ALL to watch every account.
  • Send it somewhere other than email: the sample creates a standard SNS topic. Add an SQS, HTTPS, or Lambda subscription to it. For Slack, subscribe an AWS Chatbot channel or a small forwarding Lambda.
  • Watch more event types: add event names to the EventBridge rule in the template and redeploy.

Troubleshooting

  • No email at all: confirm the SNS subscription. AWS sends the confirmation email once, and nothing is delivered until you click the link.
  • The change happens but no email arrives: check the Region. Identity Center events only appear in the Region of the Identity Center instance, and local IAM events only in us-east-1.
  • Names show as IDs: make sure IdentityCenterInstanceArn is set and the Lambda role still has the Identity Center read permissions.

Clean up

aws cloudformation delete-stack --stack-name sample-access-change-notifier
aws cloudformation delete-stack --stack-name sample-access-change-notifier-iam --region us-east-1

Conclusion

The Access Change Notifier gives you a near real-time, readable heads-up when access changes on the accounts you care about, across both IAM Identity Center and local IAM. By enriching each event and filtering to your monitored accounts, it turns raw CloudTrail activity into an alert a person can act on, while staying least privilege and failing open so a change is never missed.

You can download and start using the solution directly from the GitHub repository here: https://github.com/aws-samples/sample-access-change-notifier

It is licensed under MIT-0. Treat it as reference code that demonstrates the pattern, not as a managed product, and keep CloudTrail and a log archive as your durable, tamper-evident record. For more detail, refer to the official IAM Identity Center and Amazon EventBridge documentation.

Your feedback is invaluable, please feel free to share any thoughts or suggestions in the comments below or in the GitHub repository!