New – Cross-Account Delivery of CloudWatch Events
CloudWatch Events allow you to track and respond to changes in your AWS resources. You get a near real-time stream of events that you can route to one or more targets (AWS Lambda functions, Amazon Kinesis streams, Amazon SNS topics, and more) using rules. The events that are generated depend on the particular AWS service. For example, here are the events generated for EC2 instances:
Or for S3 (CloudTrail must be enabled in order to create rules that use these events):
See the CloudWatch Event Types list to see which services and events are available.
New Cross-Account Event Delivery
Our customers have asked us to extend CloudWatch Events to handle some interesting & powerful use cases that span multiple AWS accounts, and we are happy to oblige. Today we are adding support for controlled, cross-account delivery of CloudWatch Events. As you will see, you can now arrange to route events from one AWS account to another. As is the case with the existing event delivery model, you can use CloudWatch Events rules to specify which events you would like to send to another account.
Here are some of the use cases that have been shared with us:
Separation of Concerns – Customers would like to handle and respond to events in a separate account in order to implement advanced security schemes.
Rollup – Customers are using AWS Organizations and would like to track certain types of events across the entire organization, across a multitude of AWS accounts.
Each AWS account uses a resource event bus to distribute events. This object dates back to the introduction of CloudWatch Events, but has never been formally called out as such. AWS services, the
PutEvents function, and other accounts can publish events to it.
The event bus (currently one per account, with plans to allow more in the future) now has an associated access policy. This policy specifies the set of AWS accounts that are allowed to send events to the bus. You can add one or more accounts, or you can specify that any account is allowed to send events.
You can create event distribution topologies that work on a fan-in or a fan-out basis. A fan-in model allows you to handle events from multiple accounts in one place. A fan-out model allows you to route different types of events to distinct locations and accounts.
In order to avoid the possibility of creating a loop, events that are sent from one account to another will not be sent to a third one. You should take this into account when you are planning your cross-account implementation.
Using Cross-Account Event Delivery
In order to test this new feature, I made use of my work and my personal AWS accounts. I log in to my personal account and went to the CloudWatch Console. Then I select Event Buses, clicked on Add Permission, and enter the Account ID of my work account:
I can see all of my buses (just one is allowed right now) and permissions in one place:
Next, I log in to my work account and create a rule that will send events to the event bus in my personal account. In this case my personal account is interested in changes of state for EC2 instances running in my work account:
Back in my personal account, I create a rule that will fire on any EC2 event, targeting it at an SNS topic that is configured to send email:
After testing this rule with an EC2 instance launched in my personal account, I launch an instance in my work account and wait for the email message:
The account and resources fields in the message are from the source (work) account.
Things to Know
This functionality is available in all AWS Regions where CloudWatch Events is available and you can start using it today. It is also accessible from the CloudWatch Events APIs and the AWS Command Line Interface (AWS CLI).
Events forwarded from one account to another are considered custom events. The sending account is charged $1 for every million events (see the CloudWatch Pricing page for more info).
PS – AWS CloudFormation support is in the works and coming soon!