- Newest
- Most votes
- Most comments
Yes, you can set up an Amazon SNS notification when a user makes a change in AWS, and there are ways to use AWS Lambda in conjunction with CloudTrail and SNS to achieve this. While there isn't a specific Lambda template mentioned in the provided sources for this exact use case, you can create a custom Lambda function to handle this scenario.
Here's a general approach you could take:
-
Use CloudTrail to log AWS account activity, including changes made in the console.
-
Set up a CloudWatch Events rule to trigger on specific CloudTrail events you're interested in monitoring.
-
Create a Lambda function that processes these events and sends notifications via SNS.
-
Configure the CloudWatch Events rule to invoke your Lambda function when the specified events occur.
-
Set up an SNS topic and subscribe the relevant people or endpoints to receive the notifications.
While there isn't a pre-made template specifically for this scenario, you can use AWS CloudFormation to automate the deployment of the required resources, including the Lambda function, IAM roles, and SNS topic.
To get started, you could create a CloudFormation template that defines:
- An IAM role for the Lambda function with necessary permissions to read CloudTrail logs and publish to SNS
- A Lambda function that processes CloudTrail events and sends notifications
- An SNS topic for sending notifications
- A CloudWatch Events rule to trigger the Lambda function
You can then customize this template to fit your specific requirements, such as filtering for particular types of changes or formatting the notification messages as needed.
Remember to test your setup thoroughly to ensure it captures the desired changes and notifies the correct individuals.
Sources
Deploy a Lambda function for AWS IoT Events using AWS CloudFormation - AWS IoT Events
Automating Amazon SNS message archiving with an AWS CloudFormation template - Amazon Simple Notification Service
Yes, you can set up an Amazon SNS notification when a user makes a change in AWS, and there are ways to use AWS Lambda in conjunction with CloudTrail and SNS to achieve this. While there isn't a specific Lambda template mentioned for this exact use case, you can create a custom Lambda function to handle this scenario.
Having said that while you can implement the custom logic your lambda using above approach. You may also consider the enabling SNS notification in Additional settings on the source CloudTrail. [1]
As per your request here's a general approach you could consider using the lambda function:
Use CloudTrail to log AWS account activity, including changes made in the console. [2]
Set up a CloudWatch Events rule to trigger on specific CloudTrail events you're interested in monitoring. [3]
- Go to the CloudWatch service in the AWS Management Console.
- Click on "Events" and then "Create Rule".
- Under "Event Source", choose "CloudTrail Event" as the service name and select the specific event types you want to monitor, such as "AWS API Call via CloudTrail".
- You can further customize the event pattern to target specific API calls, IAM users, or resources.
- Under "Targets", select "Lambda function" as the target type. In which the Lambda function will be created in the below step.
Set up an SNS topic and subscribe the relevant people or endpoints to receive the notifications. [4]
- Go to the SNS service in the AWS Management Console.
- Click on "Create topic" and provide a name for your topic, e.g., "CloudTrailNotifications".
- Take note of the Topic ARN, as you'll need it in the Lambda function.
- Create subscriptions to the SNS topic for the relevant people or endpoints (email, SMS, etc.) that should receive the notifications.
Create a Lambda function that processes these events and sends notifications via SNS. [5]
- Go to the Lambda service in the AWS Management Console.
- Click on "Create function" and choose "Author from scratch".
- Provide a name for your function, e.g., "CloudTrailEventProcessor".
- Define the custom function code that will process the CloudTrail events and send notifications via SNS. Where the code extracts the event details from the Eventbridge and parse the same and then publish notification to SNS topic.
Remember to test your setup thoroughly to ensure it captures the desired changes and notifies the correct individuals.
References
[2] https://docs.aws.amazon.com/awscloudtrail/latest/userguide/tutorial-trail.html
[3] https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cwe-now-eb.html
[4] https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html
[5] https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html
While both answers are accurate. You are going to be inundated with alerts when changes occur.
Relevant content
- AWS OFFICIALUpdated 2 years ago