Invoking the first Lambda function via AWS Console or AWS Console to send a custom event to the EventBridge Bus. The API destination will be triggered with an EventBridge Rule that receives an event from an EventBridge Event Bus. You can create a custom event bus to receive events from your custom applications, or it can receive events from applications and services created by AWS SaaS partners.
NOTE: Update the events Connection and Destination configuration on the event-bridge-api-destination-stack.ts
file.
- Go to Lambda → Lambda Function → Test tab
- Update the Event JSON textarea field to
{}
- Click on the Test button in the upper right corner
- Use the following command and replace the placeholder
lambda_function_name
with the actual Lambda function nameaws lambda invoke \ --function-name lambda_function_name \ --payload '{}' \ response.json
{
"version": "0",
"id": "123d4567-b891-0e11-b1ed-c2b13141516f",
"detail-type": "alarm",
"source": "trigger:alarm",
"account": "123456789010",
"time": "2023-05-08T03:51:54Z",
"region": "us-east-1",
"resources": [],
"detail": {
"request_id": "123d4567-e8ed-9d1d-a011-f121f31415b1",
"source": "arn:aws:lambda:us-east-1:123456789010:function:lambdaFn",
"message": "This is a sample alarm message",
"timestamp": "2023-05-08 03:51:54"
}
}
- API destinations
- Using EventBridge
- What is Amazon EventBridge
- Amazon EventBridge event buses
- Creating an Amazon EventBridge event bus
- Sending and receiving Amazon EventBridge events between event buses in the same account and Region
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-api-destination$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-api-destination$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-api-destination$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-api-destination$ make deploy profile=[profile_name]