AWS invokes a Lambda target with a JSON array of up to MaxBatchSize events (10 by default), synchronously unless InvocationType is EVENT, and with LambdaParameters.Qualifier resolved from each event. It checks a Lambda TargetArn's form, then the Region and account of any target, then that the parameter block is the target's. A reset or deleting the subscriber drops the invocations still waiting. AWS drops a waiting event only once it outlives the subscriber's MaxEventAgeInSeconds or uses up MaxRetryAttempts, so a burst behind a slow function is not cut at a fixed count.
22 KiB
EventBridge V2
Protocol: Smithy RPC v2 CBOR (smithy-protocol: rpc-v2-cbor)
Endpoint: POST http://localhost:4566/service/AWSEventsV2/operation/<Operation>
EventBridge V2 is a separate service from EventBridge. Its event buses are
event-busv2 resources, arn:aws:events:<region>:<account>:event-busv2/<name>/<id>, which accept
events and deliver each one to every subscriber whose filters it matches. It signs requests with the
same events name as EventBridge, but nothing is shared between the two: a V2 bus is not visible to
EventBridge's ListEventBuses, and the reverse holds as well.
The AWS CLI calls it aws eventsv2 and the SDKs EventBridgeV2.
Supported Actions
| Action | Description |
|---|---|
CreateEventBus |
Create an event bus, with an optional description, KMS key, retention period, and tags |
DescribeEventBus |
Return an event bus's name, description, configuration, state and times |
DeleteEventBus |
Delete an event bus that has no subscribers or event sources that are not revoked |
ListEventBuses |
List the Region's event buses in name order, filtered by name prefix, a page at a time |
CreateSubscriber |
Create a subscriber that delivers the events its filters match to an Amazon SQS queue or an AWS Lambda function |
DescribeSubscriber |
Return a subscriber's target, filters, transformer, delivery settings, state and times |
ListSubscribers |
List the Region's subscribers, or one event bus's, filtered by name prefix, a page at a time |
UpdateSubscriber |
Change a subscriber's settings, keeping those the request leaves out |
DeleteSubscriber |
Delete a subscriber |
CreateEventSource |
Create a webhook event source on an event bus, with its URL and a managed secret |
DescribeEventSource |
Return a webhook event source's configuration, URL, secret ARN, state and times |
ListEventSources |
List the Region's event sources, or one event bus's, filtered by name prefix, a page at a time |
UpdateEventSource |
Replace a webhook event source's configuration and description |
RotateWebhookCredentials |
Replace the credential in a webhook event source's secret, with a given or a generated one |
RevokeResource |
Revoke a webhook event source or a subscriber for good, keeping it but ending its use |
DeleteEventSource |
Delete a webhook event source and schedule its secret for deletion |
TagResource |
Add tags to an event bus, a subscriber or an event source |
UntagResource |
Remove tags from an event bus, a subscriber or an event source |
ListTagsForResource |
List the tags of an event bus, a subscriber or an event source |
PutEvents |
Publish events in the EventBridge envelope to an event bus |
Every other EventBridge V2 operation answers UnsupportedOperation.
Event buses
- A new bus is
ACTIVEat once. AWS creates it in theCREATINGstate first; theEventBusActivewaiter accepts either. - A bus name is unique per account and Region. Creating one that exists fails with
ResourceAlreadyExistsException. - A retried
CreateEventBusorCreateSubscriberwith the sameClientTokenreturns what the first call created. The same token with a different request fails withIdempotentParameterMismatchException. DeleteEventBusfails withResourceInUseExceptionwhile the bus has subscribers or event sources.ListEventBuseslists only your own buses. Floci does not share buses across accounts, so anEventBusAccountIdnaming another account lists none.EncryptionConfiguration.KmsKeyIdentifieris stored and returned as given. AWS returns the key's ARN.StorageConfiguration.RetentionPeriodInDaysis stored and returned. No default retention period is applied when it is omitted, andRetentionWindowStartTimeis not returned. Events are not retained, so they cannot be replayed.
Subscribers and filters
A subscriber delivers each event to one target. Floci delivers to an Amazon SQS queue or an
AWS Lambda function in your account and Region. The TargetArn of a function may carry a qualifier.
Any other target type is refused with InvalidInputException, as is a parameter block that does not
belong to the target: SqsParameters for a queue and LambdaParameters for a function.
FilterConfiguration.Filters holds at most one EventBridge pattern for each scope, and an event must
match every filter. A subscriber without a FilterConfiguration receives every event on the bus.
| Scope | Matches against |
|---|---|
DATA |
The event data. For PutEvents, the EventBridge envelope, with your Detail under detail |
METADATA |
The producer's metadata. Exact values only. A PutEvents event has none |
SYSTEM_METADATA |
The fields EventBridge sets: ContentType (application/eventbridge+json), EventGroupId, DeduplicationId, aws:EventId, aws:IngestionTime, aws:SequenceNumber, aws:DeliveryType, aws:Source, aws:DetailType |
Patterns support exact values, prefix, suffix, equals-ignore-case, anything-but, numeric,
exists and $or. As on AWS, a wildcard is rejected, as are two filters of one scope and patterns
over 4,096 bytes in all, a field given a single value rather than a list, and a numeric matcher
whose operators or operands are not comparisons and numbers. A pattern naming fields the event does not
have is not an error; it matches nothing.
A matcher Floci does not evaluate, such as cidr or anything-but with numeric, is refused with
InvalidInputException when the subscriber is created or updated, where AWS would accept it.
Delivery
Transformer.TypeRAW, the default, sends the event data as the message body: forPutEvents, the envelope.WITH_METADATAsends{"Data": ..., "Metadata": ..., "SystemMetadata": ...}. AJSONATAtransformer is refused.SqsParameters(MessageGroupId,MessageDeduplicationId,DelaySeconds,MessageAttributes) take a literal, or an expression that is a path into the event, such as{% $events.SystemMetadata.EventGroupId %}or{% $events.SystemMetadata."aws:EventId" %}. Other JSONata is refused when the subscriber is created.- A queue gets one message per event at once, in the bus's sequence order, also across concurrent
PutEventsrequests. A delivery that fails, for example to a queue or a function that does not exist, is logged and its events are dropped:RetryPolicyandOnFailureConfigurationare stored but not applied. - A function receives a JSON array of events, each in the form
Transformer.Typegives. The events onePutEventscall, webhook event or AWS service event makes for the subscriber go in one invocation, in sequence order.BatchConfiguration.MaxBatchSize, 10 when not set, caps the events in an invocation.MaxBatchWindowInSecondsis stored but not applied. LambdaParameters.QualifierandDurableExecutionNametake a literal or a path into the event, asSqsParametersdo, and are resolved for each event. A batch ends where either changes. Both are passed to Invoke.InvocationTypeEVENTinvokes the function asynchronously.REQUEST_RESPONSE, the default, invokes it synchronously. A subscriber's invocations run in order and never hold upPutEvents.TenantIdandInvocationTimeoutSecondsare stored but not applied.- A
STOPPEDsubscriber receives nothing.StartingPositionPOINT_IN_TIMEis stored but delivers from the latest event, since events are not retained. - The
RoleArnis checked for shape only; delivery does not assume it.
Updating a subscriber
UpdateSubscriber changes only the settings the request gives. Its InvokeConfiguration replaces the role and
the target parameters but has no TargetArn: a subscriber keeps its target. An update is checked as a whole, so a
request with one invalid setting changes nothing. ResumePosition is accepted and has no effect, since events are
not retained. DescribeSubscriber and ListSubscribers return Revoked once the subscriber is revoked, and leave it out before.
Revoking a resource
RevokeResource takes the ARN of an event source or of a subscriber and answers it back. A revoke cannot be
undone. A second revoke answers 200 and changes nothing.
- A revoked source answers
403on its webhook URL for every POST that reaches authentication. Its secret stays and its name stays taken.UpdateEventSourceandRotateWebhookCredentialsanswerInvalidStateException(409) after their own400checks. A rotation also checks itsClientTokenfirst, so a repeat of an earlier rotation still answers200. - A revoked subscriber receives no more events.
UpdateSubscriberanswersInvalidStateException(409) after its own400checks. - Both stay
ACTIVEorRUNNING, reportRevoked, and can still be described, listed and deleted. DeleteEventBusignores revoked sources and subscribers. A revoked resource outlives its bus. Its description then has noConfigurationfor a source. A subscriber has noInvokeConfiguration,BatchConfiguration,Transformer,RetryPolicy,FilterConfiguration,OnFailureConfigurationorLogConfiguration, and itsDescriptionreads*** Not accessible: event bus deleted ***. A new bus of the same name does not take it over. It can have a subscriber of the orphan's name, but a source name stays taken.- The ARN of a webhook source or subscriber that does not exist is answered
403as access denied. A source ARN of typeaws.serviceoraws.partnerthat does not exist is answered404.
Webhook event sources
Floci serves event sources of the WebhookEventsConfiguration and AwsServiceEventsConfiguration kinds. This
section covers the webhook kind. A PartnerEventsConfiguration always fails, as described below.
- A source is
ACTIVEat once. Its ARN isarn:aws:events:<region>:<account>:event-sourcev2/webhook/<name>/<id>. - A source name is unique per account and Region, across event buses.
- The webhook URL is
<scheme>://<host id>.c01.events-webhook.<region>.<authority>/<token>/. The scheme and authority are those of Floci's base URL. A POST to it publishes an event, as described below. With TLS on, Floci's generated certificate names the webhook hosts of a Region once a source is created or described there. A user-provided certificate must name*.c01.events-webhook.<region>.<host>itself. - Each source has a Secrets Manager secret named
events-webhook!<uuid>, owned byevents-webhook. It holds the static token, the HMAC secret, or the Basic credential as{"username":"...","password":"..."}. A credential the request leaves out is generated. The secret ARN is inEventSourceDetails.WebhookDetails.SecretArn. DescribeEventSourcereturnsConfigurationas given, withoutSecretValue,UsernameandPassword.UpdateEventSourcereplaces the whole webhook configuration and keeps the URL, the secret and the authentication type. It does not accept credentials.RotateWebhookCredentialsreplaces the credential in the secret and keeps the URL, the secret ARN andLastModifiedTime. The new value becomesAWSCURRENTand the one it replacesAWSPREVIOUS. The webhook URL keeps accepting the credential the last rotation replaced for 15 minutes. An earlier one is refused at once.Credentialmust set the member of the source's authentication type, or be left out to generate a value. Basic keeps its username. A repeat of aClientTokenof the source with the same request changes nothing. Floci forgets a token 8 hours after its rotation. A rotation answersInvalidStateException(409) when the secret is scheduled for deletion or deleted.KmsKeyIdentifieris returned as given, and the secret is encrypted with that key. An update that changes the key re-encrypts the secret, and one that leaves it out or sets""returns the secret to the default key. A key that does not exist answersAccessDeniedException(403), and an AWS managed key such asalias/aws/secretsmanageranswersInvalidInputException(400), and so does a key ARN of another Region or account.DeleteEventSourceschedules the secret for deletion at once.DescribeEventSourceandListEventSourcesreturnRevokedonce the source is revoked, and leave it out before.
Receiving events
A POST to the webhook URL authenticates the caller and publishes the body as an event on the source's bus.
Subscribers receive it as they receive a PutEvents event, with the next sequence number of the bus.
The request is answered in this order.
- A method other than POST is
400, even on an unknown URL. - A path that is not exactly
/<token>/or a token that does not belong to the host is404. A query string is accepted. - A body over 1048576 bytes is
400. - A caller that fails authentication is
403. So is a URL whose source was deleted. - A body that is not one JSON value is
400.
The answers are OK, Forbidden, Bad Request and Not Found as text/plain, with x-amzn-RequestId.
A 400 also sends Connection: close and closes the connection.
- The body may be any JSON value. Floci refuses an empty body, a duplicate key at any depth, a second value,
trailing text, a byte order mark, text that is not UTF-8,
NaN, single quotes, comments, trailing commas and a leading zero. Floats are written as doubles, so1e2becomes100.0. Integers keep their size.Content-Typeis not checked. StaticTokenAuthConfigurationcompares the whole value ofTokenHttpHeaderwith the secret.BasicHttpAuthConfigurationreadsAuthorizationwith the schemeBasicin any case and one space.HmacAuthConfigurationsigns the body, the timestamp and the body, or the message id, the timestamp and the body, withAlgorithmSHA1orSHA256.EncodingisHEXorBASE64. A hex signature may be in any case. A Base64 signature may lack padding and may not be URL-safe.SecretEncodingBASE64decodes the secret first.SignaturePrefixis required when set.Delimitersplits a list of signatures and any one may match. WhenSignatureHttpHeaderandTimestampHttpHeaderare the same header, the elements may come in any order. A timestamp is epoch seconds or an ISO-8601 date and time with an offset.TimestampToleranceInSecondsapplies to past and future, and is 300 when the source does not set it. A message id with a.is refused.- The event is
Data,MetadataandSystemMetadata.Datais the parsed body.Metadataholds theMetadataHttpHeadersof the source under lower-case names. Repeated headers are joined with,. An empty value and a value over 1024 UTF-8 bytes are dropped. The names come in the order AWS gives them, which is that of a hash map and not that of the list. SystemMetadatahasEventGroupId,DeduplicationId,ContentType,aws:IngestionTime,aws:EventId,aws:SequenceNumberandaws:DeliveryType. It has noaws:Sourceoraws:DetailType.- A
WITH_METADATAsubscriber receives the three parts. ARAWsubscriber receives the request body as sent. DeduplicationTypeCONTENT_BASEDdrops a request whose body bytes and copied metadata the source saw in the last 5 minutes. The request is answered200and publishes nothing.EventGroupIdandDeduplicationIdare then a 64 character hash, and otherwise a random UUID. The hash is SHA-256 over an encoding of Floci's own, so it does not equal the hash AWS gives. The hashes are kept in memory and are lost on restart.- The host of the request decides the source. The Region in the host is not checked.
- Not emulated:
429throttling andLogConfigurationdelivery.
AWS service event sources
An AwsServiceEventsConfiguration source forwards the events of one AWS service, such as aws.ssm, to its bus.
- A source is
ACTIVEat once. Its ARN isarn:aws:events:<region>:<account>:event-sourcev2/aws.service/<name>/<id>. It has noEventSourceDetails, andListEventSourcesanswersTypeAWS_SERVICE_EVENTS. DescribeEventSourcereturnsConfigurationas given.Patternis the exact string that was sent.- Floci creates a managed rule on the default bus of the account and Region. It is named by the id in the source
ARN and has
ManagedByevents.amazonaws.com. Its pattern setssource,accountandregion, then the members ofPatternin their own order. Its one target is the bus of the source.OnFailureConfiguration.Arnbecomes the target'sDeadLetterConfig. Patternmay not setsource,accountorregion. The dead-letter queue must be a standard queue of the caller's account and Region. A queue that does not exist is accepted.- An event of the service that matches the managed rule reaches the bus.
Datais the event of the default bus as it is.Metadatais empty.SystemMetadatahasEventGroupIdandDeduplicationId, both the event id, thenContentType,aws:IngestionTime,aws:Source,aws:DetailType,aws:EventId,aws:SequenceNumberandaws:DeliveryType. A bus takes one event per event id, however many sources of the service it has. UpdateEventSourcereplaces the whole configuration and rewrites the rule. ADescriptionalone leaves the rule alone. The type of a source cannot change.- A
Patternthat is no event pattern on its own, such as{}, is answered400withEventSource forwarding could not be provisioned: InvalidEventPatternException. The source is still kept. After a create it isCREATE_FAILEDwith no rule. After an update it isUPDATE_FAILED, holds the new configuration, and keeps the rule it had. A later valid update makes itACTIVEand writes the rule. DeleteEventSourceremoves the managed rule. A revoked source keeps its rule and takes no more events.DeleteEventBusis blocked by a source that is not revoked, but not by one that isCREATE_FAILED.RotateWebhookCredentialsdoes not take the ARN of a service source.
A PartnerEventsConfiguration always fails with InvalidInputException, as AWS does for a partner event source
that does not exist, since Floci models no partner event sources.
Tags
TagResource refuses to take a bus, a subscriber or an event source past 50 tags with LimitExceededException.
A key that starts with aws: in any case is refused with AccessDeniedException (403). A revoked subscriber or
event source cannot be tagged or untagged, and still lists its tags. TagResource and UntagResource do not change
LastModifiedTime. DescribeEventBus, DescribeSubscriber and DescribeEventSource return no tags.
CreateEventBus, CreateSubscriber and CreateEventSource refuse a key that starts with aws: and more than
50 tags in the same way.
IAM
Under IAM enforcement, EventBridge V2 operations are authorized as the events actions of the same
name, as on AWS, and checked on the resource their request names: PutEvents, DescribeEventBus
and DeleteEventBus on the event-busv2 ARN in EventBusArn, the subscriber operations on the
subscriber ARN in SubscriberArn, and CreateSubscriber on its bus and on
subscriber/<name>/*, and CreateEventBus on event-busv2/<name>/*. A V2 request is never
checked on the default EventBridge bus.
The tags of a bus, a subscriber and an event source are read for aws:ResourceTag conditions.
Where the two APIs share an operation name, the API serving the request decides which resource is
checked, not the members the request gives. An EventBridge request that adds a V2 bus's
EventBusArn is still checked on the EventBridge bus it acts on.
CloudFormation
AWS::EventsV2::EventBus and AWS::EventsV2::Subscriber are provisioned from their properties.
Ref returns the ARN of each.
| Type | Fn::GetAtt |
|---|---|
AWS::EventsV2::EventBus |
EventBusArn, State, CreationTime, LastModifiedTime |
AWS::EventsV2::Subscriber |
SubscriberArn, BusName, CreationTime, LastModifiedTime |
An update that keeps a bus's Name changes it in place. An update that keeps a subscriber's Name,
EventBusArn, InvokeConfiguration.TargetArn, Type, StartingPosition and PointInTimeConfiguration
changes the rest in place.
Changing any of them replaces the subscriber. With a new Name, the new subscriber is created and the
old one deleted once the update completes. Under the same Name, the old subscriber is deleted first and
then created again, the delete_then_create replacement its schema declares. If that update rolls back,
or the new subscriber cannot be created, the old subscriber is recreated with its original ARN and
settings; a rollback that cannot recreate it fails rather than reporting success. An update rolled back after
changing a bus or subscriber in place puts back the settings it had.
With aws-cdk-lib 2.272 to 2.273, CfnSubscriber lacks its invokeConfiguration prop
(aws/aws-cdk#38996); set it with
addPropertyOverride("InvokeConfiguration", {...}).
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_EVENTBRIDGEV2_ENABLED |
true |
Enable or disable the service |
Example
export AWS_ENDPOINT_URL=http://localhost:4566
QUEUE_URL=$(aws sqs create-queue --queue-name large-orders --query QueueUrl --output text)
QUEUE_ARN=$(aws sqs get-queue-attributes --queue-url "$QUEUE_URL" \
--attribute-names QueueArn --query Attributes.QueueArn --output text)
BUS_ARN=$(aws eventsv2 create-event-bus --name orders --query EventBusArn --output text)
aws eventsv2 create-subscriber \
--name large-orders \
--event-bus-arn "$BUS_ARN" \
--invoke-configuration "{\"TargetArn\":\"$QUEUE_ARN\",\"RoleArn\":\"arn:aws:iam::000000000000:role/EventBusDelivery\"}" \
--filter-configuration '{"Filters":[{"Scope":"DATA","Pattern":"{\"detail\":{\"total\":[{\"numeric\":[\">\",500]}]}}"}]}'
aws eventsv2 put-events --event-bus-arn "$BUS_ARN" \
--entries '[{"Source":"com.shop","DetailType":"Order Placed","Detail":"{\"total\":750}"}]'
aws sqs receive-message --queue-url "$QUEUE_URL"