From 346bf08b09d35199b78d7fd418aa53cb313f6517 Mon Sep 17 00:00:00 2001 From: Tomasz Czubocha Date: Wed, 25 Nov 2026 23:48:26 +0000 Subject: [PATCH] feat(compose-eventbridge-custom-bus): bring the example to the standard with a live test --- compose-eventbridge-custom-bus/README.md | 256 ++++++++------- compose-eventbridge-custom-bus/example.json | 29 ++ .../producer/package-lock.json | 304 +++++++++--------- .../producer/package.json | 2 +- compose-eventbridge-custom-bus/test/smoke.mjs | 105 ++++++ 5 files changed, 430 insertions(+), 266 deletions(-) create mode 100644 compose-eventbridge-custom-bus/example.json create mode 100644 compose-eventbridge-custom-bus/test/smoke.mjs diff --git a/compose-eventbridge-custom-bus/README.md b/compose-eventbridge-custom-bus/README.md index d7de5c061..33b7eec25 100644 --- a/compose-eventbridge-custom-bus/README.md +++ b/compose-eventbridge-custom-bus/README.md @@ -1,6 +1,6 @@ -# Serverless Framework Compose: EventBridge Custom Event Bus Subscribers +# Subscribe functions to an EventBridge Custom Event Bus with Serverless Compose -The EventBridge [Custom Event Bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-custom-bus.html) -routes events to subscribers and keeps every event for a retention period of 1 -to 365 days. Consumers attach their own subscribers to a bus that another stack -owns, and each subscriber filters the events and delivers the matching ones to -one target. When the `eventBus` of an `eventBridge` function event is a Custom -Event Bus, the Serverless Framework creates an `AWS::EventsV2::Subscriber` for -the function instead of a rule. +[![Verified](https://raw.githubusercontent.com/serverless/examples/verified/badges/compose-eventbridge-custom-bus.svg)](https://github.com/serverless/examples/blob/verified/results.json) -This example composes three services: - -- **`events`**: a stateful, resource-only service that owns the bus and outputs - its ARN. Deploy it once per environment. -- **`orders`**: two consumers of the bus. - - `fulfil` receives one `OrderPlaced` event per invocation, in publish order - within each event group (`ordering: fifo`, `batchSize: 1`). - - `audit` keeps the Custom Event Bus defaults: it receives an array of - events, and undeliverable events go to a dead-letter queue. -- **`producer`**: a function that publishes order events with - `@aws-sdk/client-eventbridgev2`. +The EventBridge [Custom Event Bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-custom-bus.html) routes events to subscribers and keeps every event for a retention period of 1 to 365 days. Consumers attach their own subscribers to a bus that another stack owns, and each subscriber filters the events and delivers the matching ones to one target. When the `eventBus` of an [`eventBridge` event](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#custom-event-bus) is a Custom Event Bus, the Serverless Framework creates an `AWS::EventsV2::Subscriber` for the function instead of a rule. This example owns the bus in one service and subscribes two functions from another service to it, wired together with [Serverless Compose](https://www.serverless.com/framework/docs/guides/compose): one function receives orders one at a time in publish order, the other in batches. ```text ┌──────────────┐ PutEvents ┌──────────────────────┐ subscribers ┌──────────────────────┐ @@ -42,24 +26,118 @@ This example composes three services: └──────────── ${service:events.OrdersBusArn} (Compose params) ─────────┘ ``` -## When to use a Custom Event Bus +## What it deploys -AWS recommends the Custom Event Bus for new applications. It fits when several -teams or services consume the same events, when a consumer needs events in -order, or when events must be kept on the bus for later delivery. AWS service -events and SaaS partner events arrive on the default bus or a partner bus, and -reach a Custom Event Bus only through an event source; schedules stay on Classic -rules or EventBridge Scheduler. The -[Choosing a bus](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#choosing-a-bus) -section of the EventBridge event docs compares the two, including pricing, -Regions and quotas. +Three services, which Compose deploys in this order: -The Custom Event Bus is available in a subset of AWS Regions, and a subscriber -is created in its bus's Region. This example deploys to `us-east-1`, the -Framework's default Region; pass `--region` to deploy all three services to -another Region that offers the Custom Event Bus. +- **`events`**: a stateful, resource-only service with the Custom Event Bus `orders-`, which keeps events for 7 days, and a stack output with its ARN. Deploy it once per environment. +- **`orders`**: two consumers of the bus. + - `fulfil` receives one `OrderPlaced` event per invocation, in publish order within each event group (`ordering: fifo`, `batchSize: 1`). + - `audit` keeps the Custom Event Bus defaults: it receives an array of events, and events it can't take go to an SQS dead-letter queue, `AuditDlq`. + - A subscriber on the bus for each function, and one IAM delivery role that EventBridge assumes to invoke them. +- **`producer`**: a function, `publish`, that publishes order events with `@aws-sdk/client-eventbridgev2`. + +Each function gets an IAM execution role and a CloudWatch Logs log group. + +## Prerequisites + +- The Serverless Framework CLI: `npm i -g serverless`, which needs [Node.js](https://nodejs.org/). See [Getting started](https://www.serverless.com/framework/docs/getting-started). +- An AWS account, with credentials configured on your machine. See [AWS credentials](https://www.serverless.com/framework/docs/providers/aws/guide/credentials). +- A Serverless account, or a license key in `SERVERLESS_LICENSE_KEY`. The CLI asks you to sign in the first time you run it. +- An AWS Region that offers the Custom Event Bus. It launched in a subset of Regions; [AWS Capabilities by Region](https://builder.aws.com/build/capabilities) lists where it is available. The default quota is 5 Custom Event Buses per account and Region, so the account needs one free. +- The deploying identity needs `iam:PassRole` on the delivery role; see [The delivery role](#the-delivery-role). + +## Deploy + +Install the producer's dependencies, then deploy all three services from this directory: + +```bash +cd producer && npm ci && cd .. +serverless deploy +``` + +Without options, the deploy uses the stage `dev` and the Region `us-east-1`. To change them, pass `--stage` or `--region`, and pass the same options to every later command, including `serverless remove`. Compose deploys `events` first, then `orders` and `producer`. + +You should see output like this: -## How the services are wired +```text +Serverless ϟ Compose + +✔ events + OrdersBusArn: arn:aws:events:us-east-1:123456789012:event-busv2/orders-dev/buy4dk6nb4f40wofzbygbi3fm + ServerlessDeploymentBucketName: serverless-framework-deployments-us-east-1-xxxxxxxx-xxxx + +✔ producer + PublishLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:123456789012:function:compose-eventbus-producer-dev-publish:1 + ServerlessDeploymentBucketName: serverless-framework-deployments-us-east-1-xxxxxxxx-xxxx + +✔ orders + AuditLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:123456789012:function:compose-eventbus-orders-dev-audit:1 + FulfilLambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:123456789012:function:compose-eventbus-orders-dev-fulfil:1 + ServerlessDeploymentBucketName: serverless-framework-deployments-us-east-1-xxxxxxxx-xxxx + +Results: 3 services succeeded, 0 failed, 0 skipped, 3 total Time: 1m 59s +``` + +## Try it + +Invoke the producer. It publishes `count` `OrderPlaced` events (1 to 10, default 3) for one customer, one after another, and returns their sequence numbers: + +```bash +serverless producer invoke --function publish --data '{"count":5}' +``` + +```json +{ + "customerId": "customer-c86f74c2", + "published": [ + { + "sequence": 1, + "orderId": "df3fb693-4d15-4bd3-b55b-a7de18c2e3b0", + "eventId": "6a8f5c0a-93da-4cc3-890d-059d289f693b" + }, + ... + { + "sequence": 5, + "orderId": "aa25fe11-dff6-4cce-a3fe-ac1559ea4a12", + "eventId": "4e03564d-d9b4-4b56-be83-142dc119899e" + } + ] +} +``` + +Read `fulfil`'s log. It logs one event per invocation, with `sequence` in publish order: + +```bash +serverless orders logs --function fulfil +``` + +Among Lambda's own `START`, `END` and `REPORT` lines, the handler's lines are: + +```text +INFO {"handler":"fulfil","orderId":"df3fb693-4d15-4bd3-b55b-a7de18c2e3b0","sequence":1,"id":"462b26d6-186a-41d1-b709-eeeac8ced30e"} +INFO {"handler":"fulfil","orderId":"ff8529b0-cb2a-4ffa-8322-d5c6366d3024","sequence":2,"id":"cfe935e4-ebb9-40aa-8c10-fe602a353274"} +INFO {"handler":"fulfil","orderId":"3286fe6f-0de1-4082-90ec-bd6f30d1a480","sequence":3,"id":"d2e63ed3-62d8-48e0-95f6-45a099595c63"} +INFO {"handler":"fulfil","orderId":"fed2742b-5e5d-4f0d-a205-0bb998d298b6","sequence":4,"id":"d231158a-6609-49d5-a145-71165a3a2140"} +INFO {"handler":"fulfil","orderId":"aa25fe11-dff6-4cce-a3fe-ac1559ea4a12","sequence":5,"id":"1937d9e1-22b0-4475-804c-ea9a65fd30d3"} +``` + +Read `audit`'s log. It logs the size of each array it receives; how the five events are split into batches, and in what order, varies from run to run: + +```bash +serverless orders logs --function audit +``` + +```text +INFO {"handler":"audit","received":4,"orders":["ff8529b0-cb2a-4ffa-8322-d5c6366d3024","fed2742b-5e5d-4f0d-a205-0bb998d298b6","aa25fe11-dff6-4cce-a3fe-ac1559ea4a12","3286fe6f-0de1-4082-90ec-bd6f30d1a480"]} +INFO {"handler":"audit","received":1,"orders":["df3fb693-4d15-4bd3-b55b-a7de18c2e3b0"]} +``` + +If a command prints `No existing streams for the function`, or not all lines are there yet, wait a few seconds and run it again. + +## How it works + +### How the services are wired The bus lives in its own service, so the consumers and the producer can be deployed, changed and removed without touching it: @@ -102,7 +180,7 @@ The Framework recognizes a Custom Event Bus from its ARN, which contains `:event-busv2/`. A Framework variable such as `${param:ordersBusArn}` resolves before packaging, so each `eventBridge` event below creates a subscriber. -## The consumers +### The consumers ```yaml # orders/serverless.yml @@ -134,7 +212,7 @@ functions: `pattern` becomes the subscriber's filter, in the same syntax as a rule's event pattern. -### `fulfil`: one event at a time, in order +#### `fulfil`: one event at a time, in order With `ordering: fifo`, EventBridge delivers the events of each event group in the order they were published. The producer sets the event group with @@ -154,7 +232,7 @@ For a FIFO subscriber, use an SQS FIFO queue as its dead-letter queue. `fulfil` has none, so an event that is still undeliverable after the retry policy is dropped. -### `audit`: the Custom Event Bus defaults +#### `audit`: the Custom Event Bus defaults `audit` sets no delivery options, so it gets the Custom Event Bus defaults: @@ -181,7 +259,7 @@ for moving a consumer from a Classic bus, and [Settings on a Custom Event Bus](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#settings-on-a-custom-event-bus) for every key, including `maximumBatchingWindow`. -## The delivery role +### The delivery role A subscriber invokes its function through an IAM role, not a Lambda permission. For `orders`, the Framework creates one delivery role, @@ -209,7 +287,7 @@ EventBridge: To use a role you manage instead, set `role` on the `eventBridge` event. See [The delivery role](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#the-delivery-role). -## The producer +### The producer The producer publishes with `PutEventsCommand` from `@aws-sdk/client-eventbridgev2`, and its execution role allows @@ -245,64 +323,22 @@ build: - '!@aws-sdk/client-eventbridgev2' ``` -## Usage - -Install the producer's dependencies: - -```bash -cd producer && npm install && cd .. -``` - -### Deploy - -Deploy all three services. Compose deploys `events` first, then `orders` and -`producer`: - -```bash -serverless deploy -``` - -### Publish events - -Invoke the producer. It publishes `count` `OrderPlaced` events (1 to 10, -default 3) for one customer, one after another, and returns their sequence -numbers: - -```bash -serverless producer invoke --function publish --data '{"count":5}' -``` - -### Check the consumers - -`fulfil` logs one event per invocation, with `sequence` in publish order. The -excerpts below show only the handlers' JSON lines; `serverless logs` also -prints each line's timestamp and request id, and the START, END and REPORT -lines. - -```bash -serverless orders logs --function fulfil -``` - -```text -{"handler":"fulfil","orderId":"46bcf29d-…","sequence":1,…} -{"handler":"fulfil","orderId":"3fc7291c-…","sequence":2,…} -{"handler":"fulfil","orderId":"c0ec4506-…","sequence":3,…} -{"handler":"fulfil","orderId":"2a18361d-…","sequence":4,…} -{"handler":"fulfil","orderId":"ae0265ec-…","sequence":5,…} -``` - -`audit` logs the size of each array it receives. How the five events are split -into batches, and in what order, varies from run to run: +## When to use a Custom Event Bus -```bash -serverless orders logs --function audit -``` +AWS recommends the Custom Event Bus for new applications. It fits when several +teams or services consume the same events, when a consumer needs events in +order, or when events must be kept on the bus for later delivery. AWS service +events and SaaS partner events arrive on the default bus or a partner bus, and +reach a Custom Event Bus only through an event source; schedules stay on Classic +rules or EventBridge Scheduler. The +[Choosing a bus](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#choosing-a-bus) +section of the EventBridge event docs compares the two, including pricing, +Regions and quotas. -```text -{"handler":"audit","received":1,"orders":["3fc7291c-…"]} -{"handler":"audit","received":3,"orders":["2a18361d-…","ae0265ec-…","c0ec4506-…"]} -{"handler":"audit","received":1,"orders":["46bcf29d-…"]} -``` +The Custom Event Bus is available in a subset of AWS Regions, and a subscriber +is created in its bus's Region. This example deploys to `us-east-1`, the +Framework's default Region; pass `--region` to deploy all three services to +another Region that offers the Custom Event Bus. ## Personal and preview stages @@ -315,12 +351,11 @@ resolver pinned to `dev`. The shows that pattern, and the Compose guide describes it in [Referencing a service deployed to a different stage](https://www.serverless.com/framework/docs/guides/compose#referencing-a-service-deployed-to-a-different-stage). -## Removal +## Cost and cleanup + +While the example is deployed, Amazon EventBridge bills the size of the events published to the bus and delivered to each subscriber and the storage of the events the bus retains, Lambda bills each invocation and the functions' compute time, Amazon SQS bills requests to the dead-letter queue, and CloudWatch Logs bills the functions' stored log data. See [Amazon EventBridge pricing](https://aws.amazon.com/eventbridge/pricing/), [Lambda pricing](https://aws.amazon.com/lambda/pricing/), [Amazon SQS pricing](https://aws.amazon.com/sqs/pricing/) and [CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/). -A bus with subscribers attached can't be deleted, so remove the consumers and -the producer before `events`. `serverless remove` runs in the reverse of the -deploy order, so from this directory it removes `orders` and `producer` first, -then `events`: +A bus with subscribers attached can't be deleted, so remove the consumers and the producer before `events`. `serverless remove` runs in the reverse of the deploy order, so from this directory it removes `orders` and `producer` first, then `events`: ```bash serverless remove @@ -333,16 +368,11 @@ serverless remove --service=orders,producer serverless remove --service=events ``` -The bus has no `DeletionPolicy`, so removing `events` deletes the bus and the -events it retains. For a long-lived environment, add `DeletionPolicy: Retain` -and `UpdateReplacePolicy: Retain` to `OrdersBus` in `events/serverless.yml`; the -bus then stays in the account after `serverless remove`, and you delete it -yourself. +The bus has no `DeletionPolicy`, so removing `events` deletes the bus and the events it retains. For a long-lived environment, add `DeletionPolicy: Retain` and `UpdateReplacePolicy: Retain` to `OrdersBus` in [`events/serverless.yml`](https://github.com/serverless/examples/blob/v4/compose-eventbridge-custom-bus/events/serverless.yml); the bus then stays in the account after `serverless remove`, and you delete it yourself. -## Learn more +## Next steps -- [EventBridge event: Custom Event Bus](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#custom-event-bus) -- [Serverless Compose](https://www.serverless.com/framework/docs/guides/compose) -- [Function build configuration](https://www.serverless.com/framework/docs/providers/aws/guide/building) -- [Amazon EventBridge Custom Event Bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-custom-bus.html) -- [Ordering on a Custom Event Bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-custom-bus-ordering.html) +- Read [EventBridge events: Custom Event Bus](https://www.serverless.com/framework/docs/providers/aws/events/event-bridge#custom-event-bus) for every subscriber setting, subscribing to a bus in another account, and moving a consumer from a Classic bus. +- Read [Serverless Compose](https://www.serverless.com/framework/docs/guides/compose) for parameters between services and deploying one service at a time. +- Match AWS service events or your own on the default bus with a rule, as the [EventBridge rule example](https://github.com/serverless/examples/tree/v4/aws-node-eventbridge-rule) does. +- Read [Ordering on a Custom Event Bus](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-custom-bus-ordering.html) in the EventBridge user guide. diff --git a/compose-eventbridge-custom-bus/example.json b/compose-eventbridge-custom-bus/example.json new file mode 100644 index 000000000..a73284e8a --- /dev/null +++ b/compose-eventbridge-custom-bus/example.json @@ -0,0 +1,29 @@ +{ + "title": "Serverless Compose EventBridge Custom Event Bus Subscribers", + "description": "Own an EventBridge Custom Event Bus in a stateful service and subscribe functions from other services to it, with ordered and batched delivery, wired together with Serverless Compose", + "language": "node", + "platform": "AWS", + "framework": "v4", + "author": { + "name": "Serverless, Inc.", + "link": "https://github.com/serverless", + "avatar": "https://avatars1.githubusercontent.com/u/13742415?s=200&v=4" + }, + "services": [ + "lambda", + "eventbridge", + "sqs", + "iam", + "logs" + ], + "test": { + "tier": "fast", + "checks": [ + { + "script": { + "path": "test/smoke.mjs" + } + } + ] + } +} diff --git a/compose-eventbridge-custom-bus/producer/package-lock.json b/compose-eventbridge-custom-bus/producer/package-lock.json index a111f9a71..60f5b5171 100644 --- a/compose-eventbridge-custom-bus/producer/package-lock.json +++ b/compose-eventbridge-custom-bus/producer/package-lock.json @@ -9,22 +9,22 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@aws-sdk/client-eventbridgev2": "^3.1156.0" + "@aws-sdk/client-eventbridgev2": "3.1172.0" } }, "node_modules/@aws-sdk/client-eventbridgev2": { - "version": "3.1156.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-eventbridgev2/-/client-eventbridgev2-3.1156.0.tgz", - "integrity": "sha512-RwVOpI2jzdjT7yVshycyRLqqhIRP7Mb0CHkCStB6M+5VlZB8AGierfIF+JHoD/ERGFm7n/A4FHiigs2sz8mALg==", + "version": "3.1172.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-eventbridgev2/-/client-eventbridgev2-3.1172.0.tgz", + "integrity": "sha512-5s74M5SwddLv7xKAi6Rw7hTGAASxqfM9a3DBd2E/C7Y9Lv4GM+Mfp0BQMKiYuOf5C89QjIonP7oI9J8+E0xmyA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/credential-provider-node": "^3.972.88", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.12.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/credential-provider-node": "^3.972.97", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -32,17 +32,17 @@ } }, "node_modules/@aws-sdk/core": { - "version": "3.978.5", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.978.5.tgz", - "integrity": "sha512-ruI0AWqcrfL20XDS6SwZIJFPOBZ6N0ADa9nLzWlBhxk1aoUjbUX3JkTR9vEmk7o35XpAHi68ahZ4T6RE2U9XyA==", + "version": "3.981.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.981.0.tgz", + "integrity": "sha512-Mnu7gaDrC5UCdyH8uLxLfB2eWbjE/HbjKX1U1J2VQxG3TTATUDObW2wU3I8iH3e9YH5NN2CY6w1mlAIe2XJ3jg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.975.0", - "@aws-sdk/xml-builder": "^3.972.41", + "@aws-sdk/types": "^3.975.1", + "@aws-sdk/xml-builder": "^3.972.43", "@aws/lambda-invoke-store": "^0.3.0", - "@smithy/core": "^3.36.1", - "@smithy/signature-v4": "^5.7.4", - "@smithy/types": "^4.19.0", + "@smithy/core": "^3.40.0", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", "bowser": "^2.11.0", "tslib": "^2.6.2" }, @@ -51,15 +51,15 @@ } }, "node_modules/@aws-sdk/credential-provider-env": { - "version": "3.972.76", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.76.tgz", - "integrity": "sha512-YxmL1Ar7bV9ZkJvtv+lj+MF6le76NnZnbmgySyZuxpZaCv0/1lZ3KxKy6RIj1h9ui2hWnVjZxbmTMeO0y/NrQA==", + "version": "3.972.84", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.84.tgz", + "integrity": "sha512-akZJetiMVeLRHsKzYh3LamDCo74ZUCeo0XoyRKMEMZT5qP7ReM6LhpioBCyuqKP5Vav5gEOeCmaQV0VVQr1Meg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -67,17 +67,17 @@ } }, "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.972.78", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.78.tgz", - "integrity": "sha512-3VHknDRngoebsaqyT1iR75b5cBT2zfEtODK6yYmYltljkK1HEAQLs2FEd1IpWqAeOYdMGaG9wikngWLTufY7RA==", + "version": "3.972.86", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.86.tgz", + "integrity": "sha512-U4mHaDRPWAn63yhl7FXIzbppNmW1F+4dSLeuiUpej2v3Xb6rGwvayEJ8SdlrdMV+/mZtd+GStTEP2HqurEzXtw==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.12.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -85,23 +85,23 @@ } }, "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.973.21", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.21.tgz", - "integrity": "sha512-aLx9hbCX6mGAyv4ZZd8UagJ4RASHVJw6BFDSIyuKmLkqNL6H47EjBPK6qaJ4B5TDV6mc+vMa0SJFYyo4mkvVQg==", + "version": "3.973.30", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.30.tgz", + "integrity": "sha512-r6r6499GWoGN943NA5YEhBEQ6TEOGTf7tTOBhHd/zw0UbNvSzd1/zPCNcDkPmRarA+e24X7KgxutqxjoWcskBg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/credential-provider-env": "^3.972.76", - "@aws-sdk/credential-provider-http": "^3.972.78", - "@aws-sdk/credential-provider-login": "^3.972.83", - "@aws-sdk/credential-provider-process": "^3.972.76", - "@aws-sdk/credential-provider-sso": "^3.973.20", - "@aws-sdk/credential-provider-web-identity": "^3.972.82", - "@aws-sdk/nested-clients": "^3.997.50", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/credential-provider-env": "^3.972.84", + "@aws-sdk/credential-provider-http": "^3.972.86", + "@aws-sdk/credential-provider-login": "^3.972.92", + "@aws-sdk/credential-provider-process": "^3.972.84", + "@aws-sdk/credential-provider-sso": "^3.973.28", + "@aws-sdk/credential-provider-web-identity": "^3.972.90", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", "@smithy/credential-provider-imds": "^4.5.2", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -109,16 +109,16 @@ } }, "node_modules/@aws-sdk/credential-provider-login": { - "version": "3.972.83", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.83.tgz", - "integrity": "sha512-9bJU6FjRacF4FK/QHf8Dyxhur7B1grRj8C1Yh4IkpoFW2exQflPdCv0VrbemLW9ZctLNle+AE7TETs9KNvuLYg==", + "version": "3.972.92", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.92.tgz", + "integrity": "sha512-96bcp9Pe/Xd60OEwncZ+kAQTQSu+fJnpUGz1qE6ghF5jnETmrk8XMU86mIP3lolvnCgR61XbZ+Ht6hdBjiQOmQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/nested-clients": "^3.997.50", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -126,21 +126,21 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.972.88", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.88.tgz", - "integrity": "sha512-AG0KID5qhQPzrFkh5b0Cws1Amytvzo0L0Xj6hMgJXEwD6ZXAqninDhSNAWJiN5zU4YVVZnuidnqwPwYJ04IamA==", + "version": "3.972.97", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.97.tgz", + "integrity": "sha512-E4a0IXXJVsIdo/K9roX4JAEfI0JJr7KTPymkbKgETRDqEcLygE4ZlLTe24+7Qkh8Dl5YpnPd+Tt0DOPJDFXIwA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/credential-provider-env": "^3.972.76", - "@aws-sdk/credential-provider-http": "^3.972.78", - "@aws-sdk/credential-provider-ini": "^3.973.21", - "@aws-sdk/credential-provider-process": "^3.972.76", - "@aws-sdk/credential-provider-sso": "^3.973.20", - "@aws-sdk/credential-provider-web-identity": "^3.972.82", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", + "@aws-sdk/credential-provider-env": "^3.972.84", + "@aws-sdk/credential-provider-http": "^3.972.86", + "@aws-sdk/credential-provider-ini": "^3.973.30", + "@aws-sdk/credential-provider-process": "^3.972.84", + "@aws-sdk/credential-provider-sso": "^3.973.28", + "@aws-sdk/credential-provider-web-identity": "^3.972.90", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", "@smithy/credential-provider-imds": "^4.5.2", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -148,15 +148,15 @@ } }, "node_modules/@aws-sdk/credential-provider-process": { - "version": "3.972.76", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.76.tgz", - "integrity": "sha512-pdhKFTXv1zPYhh92MTlp0jVbLWvUEV9v+rziuEkoskGGQ2iJskxHTO38nA8UAbT/N4IM3n8OZJ9rIY5IBO15/A==", + "version": "3.972.84", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.84.tgz", + "integrity": "sha512-199C6OpNejd0nq9GFAkEFIKids1FL0R6LJtL9c1OTiDOXki7S1OduuPxW4+hE0LwndcYJ7YHOuYTlqScfpCocA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -164,17 +164,17 @@ } }, "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.973.20", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.20.tgz", - "integrity": "sha512-DlxrAB3MnjNLx/da7b89W+3DyJQYso/q7Ns15MsST2IV2nkAYQOYTUCaffNSjgrpMP99Dm2mV2jxzcbyF94ZfA==", + "version": "3.973.28", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.28.tgz", + "integrity": "sha512-bGg7wH8wVDJQIcJggO9lg1ZYbG7l+PbLwHuM3Bi/e1TlCZhU712JS1W3tdRpyptdJD1UGyhBNGO/YrhrQCHKbg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/nested-clients": "^3.997.50", - "@aws-sdk/token-providers": "3.1155.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/token-providers": "3.1166.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -182,16 +182,16 @@ } }, "node_modules/@aws-sdk/credential-provider-web-identity": { - "version": "3.972.82", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.82.tgz", - "integrity": "sha512-LUo46IqPTJ4xKBsrLuoaxiv/D2GTBCcFDMD1y3jKIqPR/p7Rw14RJFZ0iRWftqZtyLPQX9JMGnSi3mBu4y/pNA==", + "version": "3.972.90", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.90.tgz", + "integrity": "sha512-duLeE3xlf0viHeH+1RM4z5duR3b32BCZTWVMu+MbxFPjQBxy7hmIGEqt5hekuFPRuXoyhMovjNl+PNNsb5oiGQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/nested-clients": "^3.997.50", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -199,18 +199,18 @@ } }, "node_modules/@aws-sdk/nested-clients": { - "version": "3.997.50", - "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.50.tgz", - "integrity": "sha512-nKb8qu4QsnpZTq/6JIXc72mzuzfh7BK4sUQkpQznPec2z4W7Ob2xYkcM4i5e1yGTBnbJVeFv/0sf3jcz85hclA==", + "version": "3.998.3", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.998.3.tgz", + "integrity": "sha512-acHTTzMB13CU6dU4sxABYExMI3PQM2zStWH2MiUwJp/7QKTrLg2f7mbzSXoegW2kYOk2tdqQYagsZrWB8Xv7eA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/signature-v4-multi-region": "^3.996.49", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.12.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -218,14 +218,14 @@ } }, "node_modules/@aws-sdk/signature-v4-multi-region": { - "version": "3.996.49", - "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.49.tgz", - "integrity": "sha512-nvuAZNRrRRVCiARRKsYlQ0VnXiEQiq7vXPH+UA+LSo+kN3Djl9eo/V2r0udkw85PnsNshmv2Em1clld5M3j67w==", + "version": "3.996.52", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.52.tgz", + "integrity": "sha512-6W6SjGc8OXUhMzNxU1X922ghD+PP1XvzmCk5Scui0jaYsLezycMYR1RaLp5xTIOUrhTXyb4DnAbPr3fBgmdnzg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.975.0", - "@smithy/signature-v4": "^5.7.4", - "@smithy/types": "^4.19.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/signature-v4": "^5.7.5", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -233,16 +233,16 @@ } }, "node_modules/@aws-sdk/token-providers": { - "version": "3.1155.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1155.0.tgz", - "integrity": "sha512-iIcQnYLhWuq9qOLQbIWFrxF3PF0svVeZvHnUS4DUnO4zUFmFHIyGyjqrntXG+e/5PUgfavV0pYfDIKHxTzN2LA==", + "version": "3.1166.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1166.0.tgz", + "integrity": "sha512-ngJ8mxXqtQ9mnp7QV6TWKJCxkpjVfPWxKQSc2FYhCyCfOVFIGdFv7P+/RqVffFrJAorwBPpktnv32gNlcEgF4g==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.978.5", - "@aws-sdk/nested-clients": "^3.997.50", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.36.1", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -250,12 +250,12 @@ } }, "node_modules/@aws-sdk/types": { - "version": "3.975.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.0.tgz", - "integrity": "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw==", + "version": "3.975.1", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.1.tgz", + "integrity": "sha512-7rGxUkCB2QPoQOeJmonmAICTN2zrH+fpmi1p4Iwu72lnxNaMhOgqcbpyddifnM1DBb19TWQ1u6z/XjkaFNEDWw==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -263,12 +263,12 @@ } }, "node_modules/@aws-sdk/xml-builder": { - "version": "3.972.41", - "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.41.tgz", - "integrity": "sha512-ctjVSyCMegrWfXlx6VqzSBFI6UqmQ5ZlnfMhdLIiWmhoH8UAQxSCP5N3OpG7X3k4LnS7ou74C4mt20+bfTW2aQ==", + "version": "3.972.43", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.43.tgz", + "integrity": "sha512-rG8QVx4DOrJWptsogu1Aq+CDsnPKaBrAlJpKLxrJrIDXAq1ElnW0yQjjBnlWSXll0cDakCG6UDvaqwz0A9d9Og==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -285,12 +285,12 @@ } }, "node_modules/@smithy/core": { - "version": "3.36.2", - "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.36.2.tgz", - "integrity": "sha512-oRw0rB9QSUiCZfEs23G5F4Af+b2rQt1lItIICWu5IejFNd+uPM8SWqiKLMpQ6bX1Q7slsLbjuoE2niErFtkVPQ==", + "version": "3.41.0", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.41.0.tgz", + "integrity": "sha512-fuZ34H1uizS3WgcX9VXG7Uy8od5A5/kCc+CR3NkHLNm2H/BE9AUHG02VIdu8ZB7FYhLqsr/RZbqAoXuOCg/Oxg==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -312,13 +312,13 @@ } }, "node_modules/@smithy/fetch-http-handler": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.0.tgz", - "integrity": "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA==", + "version": "5.8.1", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.1.tgz", + "integrity": "sha512-h8BdMUrUBhMhMaeK7QqAdINRZezCGuYOCpcOZZ1ewxbHST9rdTd09xwNpvLTYfzDRehxQiReK4SKbdYZxBA+ew==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.33.3", - "@smithy/types": "^4.18.0", + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -326,13 +326,13 @@ } }, "node_modules/@smithy/node-http-handler": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.12.1.tgz", - "integrity": "sha512-ThMkboGeONWXAelq9FvGsuJC4rOi+qyC4/zhUF58xYpxUg5sQKx2VXZYJmtNjr4dSuBJ1HeJXETQILCz3wOHvw==", + "version": "4.14.2", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.14.2.tgz", + "integrity": "sha512-i1uORV1v3qBqP43ayRKzIdm1q5x14tf8N4Dd06/QUX1Szm6VxHMrTsu20X5E63UFsaNZCRjI4SXG0jDmqYa+3w==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.33.3", - "@smithy/types": "^4.18.0", + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -340,12 +340,12 @@ } }, "node_modules/@smithy/signature-v4": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.4.tgz", - "integrity": "sha512-tHy0K0VtqNd5Y7Y41h0a0Lhh0L1GzC08dTWg0F7vRJWFtTENg7IZikf3wQkanYIRdb7ngoIPMTmqgUi401fEeQ==", + "version": "5.7.5", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.5.tgz", + "integrity": "sha512-WPjdr5oWOk1LArpI4pavu+fSo+/evi0Re1olxGvqwuZopd4gYR1UGCi+Soyn/IjmafqbWs+ZC+3AKxJS3ZpwUg==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.35.0", + "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, @@ -354,9 +354,9 @@ } }, "node_modules/@smithy/types": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.19.0.tgz", - "integrity": "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.20.0.tgz", + "integrity": "sha512-lCA6QG22dPk9ecHbv91jDQZsmtPUjdS1aE2Il6NNPqe7DrYc0dZQi6DhcESk2KYXH2sp5xbAcGdYMZDFnuzA2A==", "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" @@ -366,15 +366,15 @@ } }, "node_modules/bowser": { - "version": "2.14.1", - "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz", - "integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.15.0.tgz", + "integrity": "sha512-xic6KSZglg/I4ymp45fdM4GWfYpBK79Fxd/TOvJktlaPgQqqDxvmGwOPZl2V0dyeS3Lj5c180bLhXF43iyAjZQ==", "license": "MIT" }, "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", "license": "0BSD" } } diff --git a/compose-eventbridge-custom-bus/producer/package.json b/compose-eventbridge-custom-bus/producer/package.json index 4a13b6a56..91bf91105 100644 --- a/compose-eventbridge-custom-bus/producer/package.json +++ b/compose-eventbridge-custom-bus/producer/package.json @@ -4,6 +4,6 @@ "description": "Publishes order events to an EventBridge Custom Event Bus", "license": "MIT", "dependencies": { - "@aws-sdk/client-eventbridgev2": "^3.1156.0" + "@aws-sdk/client-eventbridgev2": "3.1172.0" } } diff --git a/compose-eventbridge-custom-bus/test/smoke.mjs b/compose-eventbridge-custom-bus/test/smoke.mjs new file mode 100644 index 000000000..638ea6096 --- /dev/null +++ b/compose-eventbridge-custom-bus/test/smoke.mjs @@ -0,0 +1,105 @@ +// Does what the README's Try it does: invokes the producer to publish five +// OrderPlaced events for one customer to the Custom Event Bus, then waits for +// both consumers. `fulfil` must log the five orders one per invocation, in +// publish order; `audit` must receive all five, in arrays. +// +// Run by the example test runner with EXAMPLE_STAGE and EXAMPLE_REGION set and +// AWS credentials in the environment. It calls the aws CLI to invoke the +// producer (lambda invoke) and to read the consumers' log groups +// (logs filter-log-events). +// +// Function names, each with the stage: +// compose-eventbus-producer--publish +// compose-eventbus-orders--fulfil +// compose-eventbus-orders--audit + +import { execFileSync } from 'node:child_process'; +import { randomBytes } from 'node:crypto'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; + +const COUNT = 5; +const DELAY_MS = 3_000; +const LOG_WAIT_MS = 180_000; + +const stage = process.env.EXAMPLE_STAGE; +const region = process.env.EXAMPLE_REGION ?? process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION; +if (!stage) fail('EXAMPLE_STAGE is not set'); +if (!region) fail('EXAMPLE_REGION is not set'); + +const customerId = `customer-${randomBytes(4).toString('hex')}`; +const start = Date.now(); +const published = publish(); +const orderIds = published.map((p) => p.orderId); + +let fulfilled = []; +let audited = new Set(); +for (;;) { + fulfilled = handlerLines('fulfil').filter((l) => orderIds.includes(l.orderId)); + audited = new Set(handlerLines('audit').flatMap((l) => l.orders ?? []).filter((id) => orderIds.includes(id))); + if (fulfilled.length >= COUNT && audited.size === COUNT) break; + if (Date.now() - start >= LOG_WAIT_MS) { + fail(`within ${LOG_WAIT_MS / 1000} s, fulfil logged ${fulfilled.length} of ${COUNT} orders and audit received ${audited.size} of ${COUNT}`); + } + await sleep(DELAY_MS); +} + +const sequences = fulfilled.map((l) => l.sequence); +const expected = published.map((p) => p.sequence); +if (JSON.stringify(sequences) !== JSON.stringify(expected)) { + fail(`fulfil: expected sequences ${expected.join(',')} in that order; got ${sequences.join(',')}`); +} + +console.log(`published ${COUNT} orders for ${customerId} -> fulfil logged sequences ${sequences.join(',')} in order; audit received all ${COUNT}`); + +function publish() { + const outFile = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'eventbus-smoke-')), 'out.json'); + aws(['lambda', 'invoke', '--function-name', `compose-eventbus-producer-${stage}-publish`, + '--cli-binary-format', 'raw-in-base64-out', '--payload', JSON.stringify({ count: COUNT, customerId }), outFile]); + const result = JSON.parse(fs.readFileSync(outFile, 'utf8')); + if (result.customerId !== customerId || result.published?.length !== COUNT) { + fail(`producer: expected ${COUNT} published orders for ${customerId}; got ${JSON.stringify(result).slice(0, 300)}`); + } + return result.published; +} + +// The handler's JSON log lines, oldest first. +function handlerLines(fn) { + let events; + try { + events = JSON.parse(aws(['logs', 'filter-log-events', '--log-group-name', `/aws/lambda/compose-eventbus-orders-${stage}-${fn}`, + '--filter-pattern', `"${fn}"`, '--start-time', String(start - 60_000)])).events; + } catch { + // The log group exists only after the first invocation. + return []; + } + return events + .sort((a, b) => a.timestamp - b.timestamp) + .map((e) => e.message.slice(e.message.indexOf('{'))) + .flatMap((text) => { + try { + const line = JSON.parse(text); + return line.handler === fn ? [line] : []; + } catch { + return []; + } + }); +} + +function aws(args) { + try { + return execFileSync('aws', [...args, '--region', region, '--output', 'json'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }); + } catch (err) { + throw new Error(`aws ${args.slice(0, 2).join(' ')}: exit ${err.status}, ${String(err.stderr ?? '').trim().slice(0, 300)}`); + } +} + +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +function fail(message) { + console.error(`smoke test failed: ${message}`); + process.exit(1); +}