mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* feat(pipes): apply EventBridge Pipe enrichment before target delivery
PipesPoller delivered the raw source record straight to the target; pipe.getEnrichment() was
stored but never invoked. Implement the AWS Pipes source->filter->ENRICHMENT->target flow: when an
enrichment Lambda is configured, invoke it once with the filtered events (bare JSON array) and
forward its response to the target (null/empty response skips the target, per AWS). Also resolve
qualified Lambda ARNs (:$LATEST) in PipesTargetInvoker. Covered by PipesTargetInvokerTest.
* fix(pipes): deliver enrichment result to the target as an event array
EventBridge Pipes delivers events to a target as a batch (JSON array). The
enrichment path forwarded a single-object enrichment response verbatim, so a
target expecting an array (e.g. a Step Functions state machine with
InputPath "$.[0]") received an object and resolved null. Wrap a non-array
enrichment response in a one-element array before target delivery. Covered by
PipesPollerTest.asEventArray*.
(cherry picked from commit f160f66857c2362e3f1bad3bbfdb025396b281a0)
* fix(pipes): treat a target/enrichment Lambda FunctionError as failed delivery
invokeLambda (the Lambda target path) discarded the InvokeResult, so a target
Lambda that returned a FunctionError (unhandled exception, throttle) was treated
as a successful delivery and the source record was consumed. Surface it (throw)
so the caller routes the record to the DLQ. Also switch applyEnrichment's
FunctionError failure from a bare RuntimeException to AwsException, per the
service-layer convention. Covered by PipesTargetInvokerTest.invoke_lambdaTargetFunctionErrorThrows.
* fix(pipes): only array-wrap the enrichment response for Lambda targets
deliverEnrichedBatch wrapped the enrichment response in a JSON batch array before invoking
the target unconditionally. That is correct for a Lambda target (which expects an
SQSRecord[]-style batch) but corrupts every other target — a Step Functions execution, SQS
message, SNS publish or EventBridge event must receive the raw enrichment response. Gate the
wrapping on isLambdaTarget, matching the non-enrichment delivery path. Adds pollSqs tests for
both a non-Lambda (raw) and a Lambda (wrapped) target.
* fix(pipes): align enrichment empty/unsupported handling with AWS + document SQS-only wiring
Review feedback:
- applyEnrichment now also skips the target when the Lambda enrichment returns an
empty object {} or empty array [] (whitespace variants included), matching AWS;
a non-empty array such as [{}] still invokes the target.
- A non-Lambda enrichment type (API destination, API Gateway, SFN Express) now
fails the batch to the DLQ instead of silently delivering the unenriched payload.
- Documented that enrichment is currently applied only on the SQS source path
(Kinesis/DynamoDB Streams/Kafka bypass it) in code and docs/services/pipes.md.
- Generalized a comment that named a specific downstream consumer.
- Tests: empty {}/[] skip, [{}] invokes, unsupported type throws.
* docs: regenerate action tables
3.3 KiB
3.3 KiB
EventBridge Pipes
Protocol: REST-JSON
Endpoint: POST http://localhost:4566/
Supported Actions
| Action | Description |
|---|---|
CreatePipe |
Create a new pipe with source, target, and optional enrichment |
DescribePipe |
Get pipe details including state and configuration |
UpdatePipe |
Update pipe configuration (source, target, role, enrichment, desired state) |
DeletePipe |
Delete a pipe |
ListPipes |
List all pipes with optional filtering by state and prefix |
StartPipe |
Start a stopped pipe |
StopPipe |
Stop a running pipe |
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_PIPES_ENABLED |
true |
Enable or disable the service |
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
# Create a pipe (SQS to Lambda)
aws pipes create-pipe \
--name my-pipe \
--source "arn:aws:sqs:us-east-1:000000000000:source-queue" \
--target "arn:aws:lambda:us-east-1:000000000000:function:my-function" \
--role-arn "arn:aws:iam::000000000000:role/pipe-role" \
--endpoint-url $AWS_ENDPOINT_URL
# Describe a pipe
aws pipes describe-pipe \
--name my-pipe \
--endpoint-url $AWS_ENDPOINT_URL
# List all pipes
aws pipes list-pipes \
--endpoint-url $AWS_ENDPOINT_URL
# Start a pipe
aws pipes start-pipe \
--name my-pipe \
--endpoint-url $AWS_ENDPOINT_URL
# Stop a pipe
aws pipes stop-pipe \
--name my-pipe \
--endpoint-url $AWS_ENDPOINT_URL
# Update a pipe
aws pipes update-pipe \
--name my-pipe \
--target "arn:aws:lambda:us-east-1:000000000000:function:new-function" \
--endpoint-url $AWS_ENDPOINT_URL
# Delete a pipe
aws pipes delete-pipe \
--name my-pipe \
--endpoint-url $AWS_ENDPOINT_URL
Pipe States
STARTING- Pipe is being startedRUNNING- Pipe is actively processing eventsSTOPPING- Pipe is being stoppedSTOPPED- Pipe is stopped and not processing eventsDELETED- Pipe has been deleted
Supported Sources and Targets
Floci emulates EventBridge Pipes with the following supported source and target types:
Sources:
- Amazon SQS queues
- Amazon Kinesis streams
- Amazon DynamoDB streams
- Kafka topics (MSK and self-managed via
smk://)
Targets:
- Lambda functions
- SQS queues
- SNS topics
- Kinesis streams
- Step Functions state machines
Enrichment
A pipe's optional enrichment step (source → filter → enrichment → target) is emulated for
Lambda enrichments: the filtered batch is invoked synchronously (RequestResponse) and the
response becomes the target input.
- Empty responses skip the target, matching AWS: an empty body,
null,{}, or[]consumes the source records without invoking the target. A non-empty array such as[{}]still invokes the target (with an empty-payload element). - A Lambda enrichment
FunctionErrorfails the batch — the source records are routed to the pipe's dead-letter queue rather than silently consumed. - Non-Lambda enrichment types (API destinations, API Gateway, Step Functions Express) are valid on AWS but not emulated; a pipe configured with one fails the batch to the DLQ rather than delivering the unenriched payload.
- Enrichment is currently applied only on the SQS source path. Kinesis, DynamoDB Streams and Kafka sources deliver filtered records straight to the target; an enrichment configured on those sources is not yet applied.