This AWS SAM application demonstrates a serverless pipeline that integrates the following AWS services:
- EventBridge: Captures events and forwards them to an SNS topic.
- SNS: Publishes the event to an SQS queue.
- SQS: Queues the events for processing by a Lambda function.
- Lambda: Processes the events and logs the output to CloudWatch Logs.
EventBridge -> SNS -> SQS -> Lambda -> CloudWatch Logs
- AWS CLI installed and configured.
- AWS SAM CLI installed.
- Python 3.13 installed.
- An AWS account with sufficient permissions to deploy serverless applications.
git clone https://github.com/your-repo/eventbridge-sns-sqs-lambda.git
cd eventbridge-sns-sqs-lambda
sam build
Run the following command and follow the guided prompts to provide required stack details:
sam deploy --guided
This command will:
- Package the application.
- Deploy the stack to your AWS account.
- Generate the necessary resources.
-
Manually Trigger an Event: Use the AWS CLI to send a custom event to EventBridge:
aws events put-events --entries '[ { "Source": "custom.source", "DetailType": "TestEvent", "Detail": "{\"message\": \"Hello from EventBridge!\"}" } ]'
-
Manually Trigger a Failed Event: Use the AWS CLI to send a custom event to EventBridge:
aws events put-events --entries '[ { "Source": "custom.source", "DetailType": "TestEvent", "Detail": "{\"simulatedError\": \"true\"}" } ]'
-
Verify Logs:
- Open the CloudWatch Logs console in AWS.
- Navigate to the log group created by the Lambda function.
- Confirm that the message is logged.
- EventBridge Rule: Captures custom events with the source
custom.source
. - SNS Topic: Publishes messages received from EventBridge.
- SQS Queue: Subscribes to the SNS Topic and queues messages.
- Lambda Function: Processes messages from the SQS Queue and logs them to CloudWatch Logs.
Upon deployment, the following outputs are available:
- EventBridgeRuleArn: The ARN of the EventBridge Rule.
- SNSTopicArn: The ARN of the SNS Topic.
- SQSQueueUrl: The URL of the SQS Queue.
- LambdaFunctionName: The name of the Lambda Function.
To delete the resources created by this application:
sam delete
- The Lambda function logs all received events to CloudWatch Logs for debugging and monitoring.
- Modify the
EventPattern
in the EventBridge rule to capture different events as needed. - Ensure IAM policies are correctly configured for your environment to avoid permission issues.
N/A