Invoking the first Lambda function via AWS Console or AWS Console to send a custom event to the EventBridge Bus. The next Lambda function 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.
- Go to Lambda → Lambda Function → Test tab
- Update the Event JSON textarea field (see sample payload)
- 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 '{"reference_id": "sample_reference_id", "type": "payment"}' \ --cli-binary-format raw-in-base64-out \ response.json
-
Payment Transaction
{ "reference_id": "sample_reference_id", "type": "payment" }
-
Cancel Transaction
{ "reference_id": "sample_reference_id", "type": "cancel" }
-
Payment Transaction
{ "log_code": "PaymentEvent", "log_msg": "Transaction Payment Event", "log_level": "INFO", "log_keys": { "event": { "version": "0", "id": "1b23456d-78ff-b91f-0111-21c3e1415161", "detail-type": "transaction", "source": "transaction:payment", "account": "123456789010", "time": "2023-05-05T04:20:48Z", "region": "us-east-1", "resources": [], "detail": { "reference_id": "sample_reference_id", "type": "payment", "timestamp": "2023-05-05 04:20:48" } } }, "log_timestamp": "2023-05-05 04:20:49" }
-
Cancel Transaction
{ "log_code": "CancelEvent", "log_msg": "Transaction Cancel Event", "log_level": "INFO", "log_keys": { "event": { "version": "0", "id": "1b23456d-78ff-b91f-0111-21c3e1415161", "detail-type": "transaction", "source": "transaction:cancel", "account": "123456789010", "time": "2023-05-05T04:21:28Z", "region": "us-east-1", "resources": [], "detail": { "reference_id": "sample_reference_id", "type": "cancel", "timestamp": "2023-05-05 04:21:28" } } }, "log_timestamp": "2023-05-05 04:21:29" }
- 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-bus-lambda$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-bus-lambda$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-bus-lambda$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/event-bridge/event-bridge-bus-lambda$ make deploy profile=[profile_name]