- Newest
- Most votes
- Most comments
Your EventBridge rule is close, but needs some modifications to work as intended:
-
Adjust the event pattern to specifically capture resource creation and deletion events:
- Include both "ConfigurationItemChangeNotification" and "OversizedConfigurationItemChangeNotification" in the messageType.
- Add "ResourceDeleted" and "ResourceDiscovered" to the changeType.
-
Ensure your SNS topic is properly set up and has the necessary permissions to receive messages from EventBridge.
-
Consider adding a condition to filter for specific resource states (e.g., "running" for EC2 instances).
Here's an updated version of your CloudFormation template with these changes:
AWSTemplateFormatVersion: '2010-09-09' Description: CloudFormation template for EventBridge RuleResourcesAddDeleteInventory Resources: Rule19196363: Type: AWS::Events::Rule Properties: Name: ResourcesAddDeleteInventory EventPattern: source: - aws.config detail-type: - Config Configuration Item Change detail: messageType: - ConfigurationItemChangeNotification - OversizedConfigurationItemChangeNotification changeType: - ResourceDeleted - ResourceDiscovered configurationItem: resourceType: - AWS::EC2::Instance - AWS::ElasticLoadBalancing::LoadBalancer - AWS::ElasticLoadBalancingV2::LoadBalancer - AWS::ElasticLoadBalancingV2::Listener State: ENABLED EventBusName: default Targets: - Id: Id353b15f8-76a6-4ed5-bf70-490cf675fe6a Arn: Fn::Sub: arn:${AWS::Partition}:sns:${AWS::Region}:${AWS::AccountId}:AWSConfigChanges-SNS Parameters: {}
Make sure your AWS Config is set up correctly to record all supported resource types, including the ones you're interested in. Also, verify that your SNS topic (AWSConfigChanges-SNS) exists and has the proper access policy to allow EventBridge to publish messages to it.
If you're using AWS Config in aggregator mode to watch over all accounts in your organization, ensure that the aggregator is properly set up and that the necessary permissions are in place for cross-account access.
After making these changes, deploy the updated CloudFormation template. This should create an EventBridge rule that triggers SNS notifications when the specified resources are created or deleted across your AWS accounts.
Sources
Monitoring AWS Config with Amazon EventBridge - AWS Config
Configuring an EventBridge rule to send notifications about events in AWS Health - AWS Health
Relevant content
asked 2 years ago
asked 2 years ago
- AWS OFFICIALUpdated 9 months ago
