Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

feat(pipes): add source polling and target invocation for EventBridge Pipes (#555)

Christine Nguyen51bf4f848061
diff --git a/compatibility-tests/sdk-test-awscli/test/pipes.bats b/compatibility-tests/sdk-test-awscli/test/pipes.bats
new file mode 100644
index 0000000000..de40fd4599
--- /dev/null
+++ b/compatibility-tests/sdk-test-awscli/test/pipes.bats
@@ -0,0 +1,216 @@
+#!/usr/bin/env bats
+# EventBridge Pipes tests
+
+setup() {
+ load 'test_helper/common-setup'
+ PIPE_NAME="bats-pipe-$(unique_name)"
+ SOURCE_QUEUE="bats-pipe-src-$(unique_name)"
+ TARGET_QUEUE="bats-pipe-tgt-$(unique_name)"
+ SOURCE_QUEUE_URL=""
+ TARGET_QUEUE_URL=""
+ ROLE_ARN="arn:aws:iam::000000000000:role/pipe-role"
+}
+
+teardown() {
+ aws_cmd pipes delete-pipe --name "$PIPE_NAME" >/dev/null 2>&1 || true
+ if [ -n "$SOURCE_QUEUE_URL" ]; then
+ aws_cmd sqs delete-queue --queue-url "$SOURCE_QUEUE_URL" >/dev/null 2>&1 || true
+ fi
+ if [ -n "$TARGET_QUEUE_URL" ]; then
+ aws_cmd sqs delete-queue --queue-url "$TARGET_QUEUE_URL" >/dev/null 2>&1 || true
+ fi
+}
+
+create_queues() {
+ out=$(aws_cmd sqs create-queue --queue-name "$SOURCE_QUEUE")
+ SOURCE_QUEUE_URL=$(json_get "$out" '.QueueUrl')
+ out=$(aws_cmd sqs create-queue --queue-name "$TARGET_QUEUE")
+ TARGET_QUEUE_URL=$(json_get "$out" '.QueueUrl')
+}
+
+source_arn() {
+ echo "arn:aws:sqs:${AWS_DEFAULT_REGION}:000000000000:${SOURCE_QUEUE}"
+}
+
+target_arn() {
+ echo "arn:aws:sqs:${AWS_DEFAULT_REGION}:000000000000:${TARGET_QUEUE}"
+}
+
+@test "Pipes: create pipe in STOPPED state" {
+ create_queues
+
+ run aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED
+ assert_success
+
+ state=$(json_get "$output" '.CurrentState')
+ [ "$state" = "STOPPED" ]
+
+ name=$(json_get "$output" '.Name')
+ [ "$name" = "$PIPE_NAME" ]
+}
+
+@test "Pipes: describe pipe" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ run aws_cmd pipes describe-pipe --name "$PIPE_NAME"
+ assert_success
+
+ name=$(json_get "$output" '.Name')
+ [ "$name" = "$PIPE_NAME" ]
+
+ source=$(json_get "$output" '.Source')
+ [ "$source" = "$(source_arn)" ]
+
+ target=$(json_get "$output" '.Target')
+ [ "$target" = "$(target_arn)" ]
+}
+
+@test "Pipes: list pipes" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ run aws_cmd pipes list-pipes
+ assert_success
+
+ found=$(echo "$output" | jq --arg name "$PIPE_NAME" '.Pipes | any(.Name == $name)')
+ [ "$found" = "true" ]
+}
+
+@test "Pipes: update pipe" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ run aws_cmd pipes update-pipe \
+ --name "$PIPE_NAME" \
+ --role-arn "$ROLE_ARN" \
+ --description "updated description" \
+ --desired-state STOPPED
+ assert_success
+
+ run aws_cmd pipes describe-pipe --name "$PIPE_NAME"
+ assert_success
+ desc=$(json_get "$output" '.Description')
+ [ "$desc" = "updated description" ]
+}
+
+@test "Pipes: start and stop pipe" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ run aws_cmd pipes start-pipe --name "$PIPE_NAME"
+ assert_success
+ state=$(json_get "$output" '.CurrentState')
+ [ "$state" = "RUNNING" ]
+
+ run aws_cmd pipes stop-pipe --name "$PIPE_NAME"
+ assert_success
+ state=$(json_get "$output" '.CurrentState')
+ [ "$state" = "STOPPED" ]
+}
+
+@test "Pipes: delete pipe" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ run aws_cmd pipes delete-pipe --name "$PIPE_NAME"
+ assert_success
+
+ run aws_cmd pipes describe-pipe --name "$PIPE_NAME"
+ assert_failure
+}
+
+@test "Pipes: describe non-existent pipe returns error" {
+ run aws_cmd pipes describe-pipe --name "non-existent-pipe"
+ assert_failure
+}
+
+@test "Pipes: SQS to SQS forwarding" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state RUNNING >/dev/null
+
+ aws_cmd sqs send-message \
+ --queue-url "$SOURCE_QUEUE_URL" \
+ --message-body "hello from pipes" >/dev/null
+
+ # Poll target queue for forwarded message
+ local found=false
+ for i in $(seq 1 15); do
+ sleep 1
+ out=$(aws_cmd sqs receive-message \
+ --queue-url "$TARGET_QUEUE_URL" \
+ --max-number-of-messages 1 \
+ --wait-time-seconds 1)
+ if echo "$out" | grep -q "hello from pipes"; then
+ found=true
+ break
+ fi
+ done
+
+ [ "$found" = "true" ]
+}
+
+@test "Pipes: stopped pipe does not forward messages" {
+ create_queues
+ aws_cmd pipes create-pipe \
+ --name "$PIPE_NAME" \
+ --source "$(source_arn)" \
+ --target "$(target_arn)" \
+ --role-arn "$ROLE_ARN" \
+ --desired-state STOPPED >/dev/null
+
+ aws_cmd sqs send-message \
+ --queue-url "$SOURCE_QUEUE_URL" \
+ --message-body "should not forward" >/dev/null
+
+ sleep 3
+
+ # Source should still have the message
+ out=$(aws_cmd sqs get-queue-attributes \
+ --queue-url "$SOURCE_QUEUE_URL" \
+ --attribute-names ApproximateNumberOfMessages)
+ count=$(json_get "$out" '.Attributes.ApproximateNumberOfMessages')
+ [ "$count" = "1" ]
+
+ # Target should be empty
+ out=$(aws_cmd sqs receive-message \
+ --queue-url "$TARGET_QUEUE_URL" \
+ --max-number-of-messages 1)
+ msgs=$(echo "$out" | jq '.Messages // [] | length')
+ [ "$msgs" = "0" ]
+}
diff --git a/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go b/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go
index fbd4ac0491..05801120c9 100644
--- a/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go
+++ b/compatibility-tests/sdk-test-go/internal/testutil/fixtures.go
@@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/acm"
"github.com/aws/aws-sdk-go-v2/service/ecr"
+ "github.com/aws/aws-sdk-go-v2/service/pipes"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/iam"
@@ -120,6 +121,11 @@ func ECRClient() *ecr.Client {
return ecr.NewFromConfig(Config())
}
+// PipesClient returns a new EventBridge Pipes client.
+func PipesClient() *pipes.Client {
+ return pipes.NewFromConfig(Config())
+}
+
// MinimalZip returns a minimal Lambda deployment zip with a Node.js handler.
func MinimalZip() []byte {
code := `exports.handler = async (event) => {
diff --git a/compatibility-tests/sdk-test-go/tests/pipes_test.go b/compatibility-tests/sdk-test-go/tests/pipes_test.go
new file mode 100644
index 0000000000..762bb481e7
--- /dev/null
+++ b/compatibility-tests/sdk-test-go/tests/pipes_test.go
@@ -0,0 +1,314 @@
+package tests
+
+import (
+ "context"
+ "strings"
+ "testing"
+ "time"
+
+ "floci-sdk-test-go/internal/testutil"
+
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/service/pipes"
+ pipestypes "github.com/aws/aws-sdk-go-v2/service/pipes/types"
+ "github.com/aws/aws-sdk-go-v2/service/sqs"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+const (
+ pipesAccountID = "000000000000"
+ pipesRegion = "us-east-1"
+ pipesRoleArn = "arn:aws:iam::000000000000:role/pipe-role"
+)
+
+func sqsArn(queueName string) string {
+ return "arn:aws:sqs:" + pipesRegion + ":" + pipesAccountID + ":" + queueName
+}
+
+func TestPipes(t *testing.T) {
+ ctx := context.Background()
+ pipesSvc := testutil.PipesClient()
+ sqsSvc := testutil.SQSClient()
+
+ t.Run("CreatePipe", func(t *testing.T) {
+ pipeName := "go-test-create-pipe"
+ srcQueue := "go-pipe-src-create"
+ tgtQueue := "go-pipe-tgt-create"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ r, err := pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+ require.NoError(t, err)
+ assert.Equal(t, pipestypes.PipeStateStopped, r.CurrentState)
+ assert.True(t, strings.Contains(aws.ToString(r.Arn), pipeName))
+ })
+
+ t.Run("DescribePipe", func(t *testing.T) {
+ pipeName := "go-test-describe-pipe"
+ srcQueue := "go-pipe-src-describe"
+ tgtQueue := "go-pipe-tgt-describe"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ r, err := pipesSvc.DescribePipe(ctx, &pipes.DescribePipeInput{Name: aws.String(pipeName)})
+ require.NoError(t, err)
+ assert.Equal(t, pipeName, aws.ToString(r.Name))
+ assert.Equal(t, sqsArn(srcQueue), aws.ToString(r.Source))
+ assert.Equal(t, sqsArn(tgtQueue), aws.ToString(r.Target))
+ assert.Equal(t, pipestypes.PipeStateStopped, r.CurrentState)
+ })
+
+ t.Run("ListPipes", func(t *testing.T) {
+ pipeName := "go-test-list-pipe"
+ srcQueue := "go-pipe-src-list"
+ tgtQueue := "go-pipe-tgt-list"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ r, err := pipesSvc.ListPipes(ctx, &pipes.ListPipesInput{})
+ require.NoError(t, err)
+
+ found := false
+ for _, p := range r.Pipes {
+ if aws.ToString(p.Name) == pipeName {
+ found = true
+ break
+ }
+ }
+ assert.True(t, found, "pipe should appear in list")
+ })
+
+ t.Run("UpdatePipe", func(t *testing.T) {
+ pipeName := "go-test-update-pipe"
+ srcQueue := "go-pipe-src-update"
+ tgtQueue := "go-pipe-tgt-update"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ _, err := pipesSvc.UpdatePipe(ctx, &pipes.UpdatePipeInput{
+ Name: aws.String(pipeName),
+ RoleArn: aws.String(pipesRoleArn),
+ Description: aws.String("updated via SDK"),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+ require.NoError(t, err)
+
+ r, err := pipesSvc.DescribePipe(ctx, &pipes.DescribePipeInput{Name: aws.String(pipeName)})
+ require.NoError(t, err)
+ assert.Equal(t, "updated via SDK", aws.ToString(r.Description))
+ })
+
+ t.Run("DeletePipe", func(t *testing.T) {
+ pipeName := "go-test-delete-pipe"
+ srcQueue := "go-pipe-src-delete"
+ tgtQueue := "go-pipe-tgt-delete"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ _, err := pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ require.NoError(t, err)
+
+ _, err = pipesSvc.DescribePipe(ctx, &pipes.DescribePipeInput{Name: aws.String(pipeName)})
+ require.Error(t, err)
+ })
+
+ t.Run("DescribeNonExistentPipe", func(t *testing.T) {
+ _, err := pipesSvc.DescribePipe(ctx, &pipes.DescribePipeInput{Name: aws.String("nonexistent-pipe")})
+ require.Error(t, err)
+ })
+
+ t.Run("StartAndStopPipe", func(t *testing.T) {
+ pipeName := "go-test-startstop-pipe"
+ srcQueue := "go-pipe-src-startstop"
+ tgtQueue := "go-pipe-tgt-startstop"
+
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ cleanupQueue(ctx, sqsSvc, srcQueue)
+ cleanupQueue(ctx, sqsSvc, tgtQueue)
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ startR, err := pipesSvc.StartPipe(ctx, &pipes.StartPipeInput{Name: aws.String(pipeName)})
+ require.NoError(t, err)
+ assert.Equal(t, pipestypes.PipeStateRunning, startR.CurrentState)
+
+ stopR, err := pipesSvc.StopPipe(ctx, &pipes.StopPipeInput{Name: aws.String(pipeName)})
+ require.NoError(t, err)
+ assert.Equal(t, pipestypes.PipeStateStopped, stopR.CurrentState)
+ })
+
+ t.Run("SQSToSQSForwarding", func(t *testing.T) {
+ pipeName := "go-test-fwd-pipe"
+ srcQueue := "go-pipe-src-fwd"
+ tgtQueue := "go-pipe-tgt-fwd"
+
+ srcResp, _ := sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ srcURL := aws.ToString(srcResp.QueueUrl)
+ tgtResp, _ := sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+ tgtURL := aws.ToString(tgtResp.QueueUrl)
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ sqsSvc.DeleteQueue(ctx, &sqs.DeleteQueueInput{QueueUrl: aws.String(srcURL)})
+ sqsSvc.DeleteQueue(ctx, &sqs.DeleteQueueInput{QueueUrl: aws.String(tgtURL)})
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateRunning,
+ })
+
+ sqsSvc.SendMessage(ctx, &sqs.SendMessageInput{
+ QueueUrl: aws.String(srcURL),
+ MessageBody: aws.String("hello from pipes"),
+ })
+
+ found := false
+ for i := 0; i < 15; i++ {
+ time.Sleep(1 * time.Second)
+ r, err := sqsSvc.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
+ QueueUrl: aws.String(tgtURL),
+ MaxNumberOfMessages: 1,
+ WaitTimeSeconds: 1,
+ })
+ if err == nil && len(r.Messages) > 0 && strings.Contains(aws.ToString(r.Messages[0].Body), "hello from pipes") {
+ found = true
+ break
+ }
+ }
+ assert.True(t, found, "target queue should receive forwarded message")
+ })
+
+ t.Run("StoppedPipeDoesNotForward", func(t *testing.T) {
+ pipeName := "go-test-nofwd-pipe"
+ srcQueue := "go-pipe-src-nofwd"
+ tgtQueue := "go-pipe-tgt-nofwd"
+
+ srcResp, _ := sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(srcQueue)})
+ srcURL := aws.ToString(srcResp.QueueUrl)
+ tgtResp, _ := sqsSvc.CreateQueue(ctx, &sqs.CreateQueueInput{QueueName: aws.String(tgtQueue)})
+ tgtURL := aws.ToString(tgtResp.QueueUrl)
+
+ t.Cleanup(func() {
+ pipesSvc.DeletePipe(ctx, &pipes.DeletePipeInput{Name: aws.String(pipeName)})
+ sqsSvc.DeleteQueue(ctx, &sqs.DeleteQueueInput{QueueUrl: aws.String(srcURL)})
+ sqsSvc.DeleteQueue(ctx, &sqs.DeleteQueueInput{QueueUrl: aws.String(tgtURL)})
+ })
+
+ pipesSvc.CreatePipe(ctx, &pipes.CreatePipeInput{
+ Name: aws.String(pipeName),
+ Source: aws.String(sqsArn(srcQueue)),
+ Target: aws.String(sqsArn(tgtQueue)),
+ RoleArn: aws.String(pipesRoleArn),
+ DesiredState: pipestypes.RequestedPipeStateStopped,
+ })
+
+ sqsSvc.SendMessage(ctx, &sqs.SendMessageInput{
+ QueueUrl: aws.String(srcURL),
+ MessageBody: aws.String("should not forward"),
+ })
+
+ time.Sleep(3 * time.Second)
+
+ r, _ := sqsSvc.ReceiveMessage(ctx, &sqs.ReceiveMessageInput{
+ QueueUrl: aws.String(tgtURL),
+ MaxNumberOfMessages: 1,
+ WaitTimeSeconds: 1,
+ })
+ assert.Empty(t, r.Messages, "target queue should be empty")
+ })
+}
+
+func cleanupQueue(ctx context.Context, sqsSvc *sqs.Client, queueName string) {
+ r, err := sqsSvc.GetQueueUrl(ctx, &sqs.GetQueueUrlInput{QueueName: aws.String(queueName)})
+ if err == nil {
+ sqsSvc.DeleteQueue(ctx, &sqs.DeleteQueueInput{QueueUrl: r.QueueUrl})
+ }
+}
diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index cc1b2f8df3..d62c677061 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -189,6 +189,11 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>ecr</artifactId>
</dependency>
+ <!-- EventBridge Pipes client -->
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>pipes</artifactId>
+ </dependency>
<!-- EKS client -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index 550c593948..1087f1fa25 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -36,6 +36,7 @@ import software.amazon.awssdk.services.elasticache.ElastiCacheClient;
import software.amazon.awssdk.services.acm.AcmClient;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ecr.EcrClient;
+import software.amazon.awssdk.services.pipes.PipesClient;
import software.amazon.awssdk.services.ecs.EcsClient;
import software.amazon.awssdk.services.eks.EksClient;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
@@ -494,4 +495,12 @@ public final class TestFixtures {
.credentialsProvider(CREDENTIALS)
.build();
}
+
+ public static PipesClient pipesClient() {
+ return PipesClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PipesTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PipesTest.java
new file mode 100644
index 0000000000..be6970d243
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/PipesTest.java
@@ -0,0 +1,226 @@
+package com.floci.test;
+
+import org.junit.jupiter.api.*;
+import software.amazon.awssdk.services.pipes.PipesClient;
+import software.amazon.awssdk.services.pipes.model.*;
+import software.amazon.awssdk.services.sqs.SqsClient;
+import software.amazon.awssdk.services.sqs.model.*;
+
+import static org.assertj.core.api.Assertions.*;
+
+@DisplayName("EventBridge Pipes")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class PipesTest {
+
+ private static final String ACCOUNT_ID = "000000000000";
+ private static final String REGION = "us-east-1";
+ private static final String ROLE_ARN = "arn:aws:iam::" + ACCOUNT_ID + ":role/pipe-role";
+
+ private static PipesClient pipes;
+ private static SqsClient sqs;
+ private static String pipeName;
+ private static String srcQueue;
+ private static String tgtQueue;
+ private static String srcQueueUrl;
+ private static String tgtQueueUrl;
+
+ private static String sqsArn(String queueName) {
+ return "arn:aws:sqs:" + REGION + ":" + ACCOUNT_ID + ":" + queueName;
+ }
+
+ @BeforeAll
+ static void setup() {
+ pipes = TestFixtures.pipesClient();
+ sqs = TestFixtures.sqsClient();
+ pipeName = TestFixtures.uniqueName("pipe");
+ srcQueue = TestFixtures.uniqueName("pipe-src");
+ tgtQueue = TestFixtures.uniqueName("pipe-tgt");
+
+ srcQueueUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(srcQueue).build()).queueUrl();
+ tgtQueueUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(tgtQueue).build()).queueUrl();
+ }
+
+ @AfterAll
+ static void cleanup() {
+ if (pipes != null) {
+ try { pipes.deletePipe(DeletePipeRequest.builder().name(pipeName).build()); } catch (Exception ignored) {}
+ pipes.close();
+ }
+ if (sqs != null) {
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(srcQueueUrl).build()); } catch (Exception ignored) {}
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(tgtQueueUrl).build()); } catch (Exception ignored) {}
+ sqs.close();
+ }
+ }
+
+ @Test
+ @Order(1)
+ void createPipe() {
+ CreatePipeResponse response = pipes.createPipe(CreatePipeRequest.builder()
+ .name(pipeName)
+ .source(sqsArn(srcQueue))
+ .target(sqsArn(tgtQueue))
+ .roleArn(ROLE_ARN)
+ .desiredState(RequestedPipeState.STOPPED)
+ .build());
+
+ assertThat(response.currentState()).isEqualTo(PipeState.STOPPED);
+ assertThat(response.arn()).contains(pipeName);
+ }
+
+ @Test
+ @Order(2)
+ void describePipe() {
+ DescribePipeResponse response = pipes.describePipe(DescribePipeRequest.builder()
+ .name(pipeName).build());
+
+ assertThat(response.name()).isEqualTo(pipeName);
+ assertThat(response.source()).isEqualTo(sqsArn(srcQueue));
+ assertThat(response.target()).isEqualTo(sqsArn(tgtQueue));
+ assertThat(response.currentState()).isEqualTo(PipeState.STOPPED);
+ }
+
+ @Test
+ @Order(3)
+ void listPipes() {
+ ListPipesResponse response = pipes.listPipes(ListPipesRequest.builder().build());
+
+ assertThat(response.pipes())
+ .anyMatch(p -> pipeName.equals(p.name()));
+ }
+
+ @Test
+ @Order(4)
+ void updatePipe() {
+ pipes.updatePipe(UpdatePipeRequest.builder()
+ .name(pipeName)
+ .roleArn(ROLE_ARN)
+ .description("updated via SDK")
+ .desiredState(RequestedPipeState.STOPPED)
+ .build());
+
+ DescribePipeResponse response = pipes.describePipe(DescribePipeRequest.builder()
+ .name(pipeName).build());
+
+ assertThat(response.description()).isEqualTo("updated via SDK");
+ }
+
+ @Test
+ @Order(5)
+ void startAndStopPipe() {
+ StartPipeResponse startResponse = pipes.startPipe(StartPipeRequest.builder()
+ .name(pipeName).build());
+ assertThat(startResponse.currentState()).isEqualTo(PipeState.RUNNING);
+
+ StopPipeResponse stopResponse = pipes.stopPipe(StopPipeRequest.builder()
+ .name(pipeName).build());
+ assertThat(stopResponse.currentState()).isEqualTo(PipeState.STOPPED);
+ }
+
+ @Test
+ @Order(6)
+ void deletePipe() {
+ pipes.deletePipe(DeletePipeRequest.builder().name(pipeName).build());
+
+ assertThatThrownBy(() -> pipes.describePipe(DescribePipeRequest.builder()
+ .name(pipeName).build()))
+ .isInstanceOf(NotFoundException.class);
+ }
+
+ @Test
+ @Order(7)
+ void describeNonExistentPipe() {
+ assertThatThrownBy(() -> pipes.describePipe(DescribePipeRequest.builder()
+ .name("nonexistent-pipe").build()))
+ .isInstanceOf(NotFoundException.class);
+ }
+
+ @Test
+ @Order(10)
+ void sqsToSqsForwarding() throws InterruptedException {
+ String fwdPipeName = TestFixtures.uniqueName("pipe-fwd");
+ String fwdSrc = TestFixtures.uniqueName("pipe-fwd-src");
+ String fwdTgt = TestFixtures.uniqueName("pipe-fwd-tgt");
+ String fwdSrcUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(fwdSrc).build()).queueUrl();
+ String fwdTgtUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(fwdTgt).build()).queueUrl();
+
+ try {
+ pipes.createPipe(CreatePipeRequest.builder()
+ .name(fwdPipeName)
+ .source(sqsArn(fwdSrc))
+ .target(sqsArn(fwdTgt))
+ .roleArn(ROLE_ARN)
+ .desiredState(RequestedPipeState.RUNNING)
+ .build());
+
+ sqs.sendMessage(SendMessageRequest.builder()
+ .queueUrl(fwdSrcUrl)
+ .messageBody("hello from pipes")
+ .build());
+
+ boolean found = false;
+ for (int i = 0; i < 15; i++) {
+ Thread.sleep(1000);
+ ReceiveMessageResponse recv = sqs.receiveMessage(ReceiveMessageRequest.builder()
+ .queueUrl(fwdTgtUrl)
+ .maxNumberOfMessages(1)
+ .waitTimeSeconds(1)
+ .build());
+ if (!recv.messages().isEmpty()
+ && recv.messages().get(0).body().contains("hello from pipes")) {
+ found = true;
+ break;
+ }
+ }
+ assertThat(found).as("target queue should receive forwarded message").isTrue();
+ } finally {
+ try { pipes.deletePipe(DeletePipeRequest.builder().name(fwdPipeName).build()); } catch (Exception ignored) {}
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(fwdSrcUrl).build()); } catch (Exception ignored) {}
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(fwdTgtUrl).build()); } catch (Exception ignored) {}
+ }
+ }
+
+ @Test
+ @Order(11)
+ void stoppedPipeDoesNotForward() throws InterruptedException {
+ String nfPipeName = TestFixtures.uniqueName("pipe-nofwd");
+ String nfSrc = TestFixtures.uniqueName("pipe-nofwd-src");
+ String nfTgt = TestFixtures.uniqueName("pipe-nofwd-tgt");
+ String nfSrcUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(nfSrc).build()).queueUrl();
+ String nfTgtUrl = sqs.createQueue(CreateQueueRequest.builder()
+ .queueName(nfTgt).build()).queueUrl();
+
+ try {
+ pipes.createPipe(CreatePipeRequest.builder()
+ .name(nfPipeName)
+ .source(sqsArn(nfSrc))
+ .target(sqsArn(nfTgt))
+ .roleArn(ROLE_ARN)
+ .desiredState(RequestedPipeState.STOPPED)
+ .build());
+
+ sqs.sendMessage(SendMessageRequest.builder()
+ .queueUrl(nfSrcUrl)
+ .messageBody("should not forward")
+ .build());
+
+ Thread.sleep(3000);
+
+ ReceiveMessageResponse recv = sqs.receiveMessage(ReceiveMessageRequest.builder()
+ .queueUrl(nfTgtUrl)
+ .maxNumberOfMessages(1)
+ .waitTimeSeconds(1)
+ .build());
+ assertThat(recv.messages()).isEmpty();
+ } finally {
+ try { pipes.deletePipe(DeletePipeRequest.builder().name(nfPipeName).build()); } catch (Exception ignored) {}
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(nfSrcUrl).build()); } catch (Exception ignored) {}
+ try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(nfTgtUrl).build()); } catch (Exception ignored) {}
+ }
+ }
+}
diff --git a/compatibility-tests/sdk-test-node/package.json b/compatibility-tests/sdk-test-node/package.json
index 7b3ff85404..18391096f6 100644
--- a/compatibility-tests/sdk-test-node/package.json
+++ b/compatibility-tests/sdk-test-node/package.json
@@ -14,6 +14,7 @@
"@aws-sdk/client-cognito-identity-provider": "^3.500.0",
"@aws-sdk/client-dynamodb": "^3.500.0",
"@aws-sdk/client-ecr": "^3.500.0",
+ "@aws-sdk/client-pipes": "^3.500.0",
"@aws-sdk/client-iam": "^3.500.0",
"@aws-sdk/client-kinesis": "^3.500.0",
"@aws-sdk/client-kms": "^3.500.0",
diff --git a/compatibility-tests/sdk-test-node/tests/pipes.test.ts b/compatibility-tests/sdk-test-node/tests/pipes.test.ts
new file mode 100644
index 0000000000..3269db8c57
--- /dev/null
+++ b/compatibility-tests/sdk-test-node/tests/pipes.test.ts
@@ -0,0 +1,367 @@
+/**
+ * EventBridge Pipes integration tests.
+ */
+
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import {
+ PipesClient,
+ CreatePipeCommand,
+ DescribePipeCommand,
+ ListPipesCommand,
+ UpdatePipeCommand,
+ DeletePipeCommand,
+ StartPipeCommand,
+ StopPipeCommand,
+ RequestedPipeState,
+} from '@aws-sdk/client-pipes';
+import {
+ SQSClient,
+ CreateQueueCommand,
+ DeleteQueueCommand,
+ SendMessageCommand,
+ ReceiveMessageCommand,
+ GetQueueUrlCommand,
+ GetQueueAttributesCommand,
+} from '@aws-sdk/client-sqs';
+import { makeClient, uniqueName, ACCOUNT, REGION, sleep } from './setup';
+
+const ROLE_ARN = `arn:aws:iam::${ACCOUNT}:role/pipe-role`;
+
+const sqsArn = (queueName: string) =>
+ `arn:aws:sqs:${REGION}:${ACCOUNT}:${queueName}`;
+
+const getQueueUrl = async (sqs: SQSClient, name: string): Promise<string> => {
+ try {
+ const r = await sqs.send(new GetQueueUrlCommand({ QueueName: name }));
+ return r.QueueUrl ?? '';
+ } catch {
+ return '';
+ }
+};
+
+describe('Pipes CRUD', () => {
+ let pipes: PipesClient;
+ let sqs: SQSClient;
+ let pipeName: string;
+ let srcQueue: string;
+ let tgtQueue: string;
+
+ beforeAll(() => {
+ pipes = makeClient(PipesClient);
+ sqs = makeClient(SQSClient);
+ });
+
+ afterAll(async () => {
+ // Cleanup is handled per-test
+ });
+
+ it('should create a pipe in STOPPED state', async () => {
+ pipeName = `node-pipe-create-${uniqueName()}`;
+ srcQueue = `node-pipe-src-create-${uniqueName()}`;
+ tgtQueue = `node-pipe-tgt-create-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ const response = await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+ expect(response.CurrentState).toBe('STOPPED');
+ expect(response.Arn).toContain(pipeName);
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+
+ it('should describe a pipe', async () => {
+ pipeName = `node-pipe-describe-${uniqueName()}`;
+ srcQueue = `node-pipe-src-describe-${uniqueName()}`;
+ tgtQueue = `node-pipe-tgt-describe-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ const response = await pipes.send(new DescribePipeCommand({ Name: pipeName }));
+ expect(response.Name).toBe(pipeName);
+ expect(response.Source).toBe(sqsArn(srcQueue));
+ expect(response.Target).toBe(sqsArn(tgtQueue));
+ expect(response.CurrentState).toBe('STOPPED');
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+
+ it('should list pipes', async () => {
+ pipeName = `node-pipe-list-${uniqueName()}`;
+ srcQueue = `node-pipe-src-list-${uniqueName()}`;
+ tgtQueue = `node-pipe-tgt-list-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ const response = await pipes.send(new ListPipesCommand({}));
+ const names = response.Pipes?.map((p) => p.Name) ?? [];
+ expect(names).toContain(pipeName);
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+
+ it('should update a pipe', async () => {
+ pipeName = `node-pipe-update-${uniqueName()}`;
+ srcQueue = `node-pipe-src-update-${uniqueName()}`;
+ tgtQueue = `node-pipe-tgt-update-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ await pipes.send(
+ new UpdatePipeCommand({
+ Name: pipeName,
+ RoleArn: ROLE_ARN,
+ Description: 'updated via SDK',
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ const response = await pipes.send(new DescribePipeCommand({ Name: pipeName }));
+ expect(response.Description).toBe('updated via SDK');
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+
+ it('should delete a pipe', async () => {
+ pipeName = `node-pipe-delete-${uniqueName()}`;
+ srcQueue = `node-pipe-src-delete-${uniqueName()}`;
+ tgtQueue = `node-pipe-tgt-delete-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ await pipes.send(new DeletePipeCommand({ Name: pipeName }));
+
+ await expect(
+ pipes.send(new DescribePipeCommand({ Name: pipeName }))
+ ).rejects.toThrow();
+ } finally {
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+
+ it('should return error for non-existent pipe', async () => {
+ await expect(
+ pipes.send(new DescribePipeCommand({ Name: 'nonexistent-pipe' }))
+ ).rejects.toThrow();
+ });
+});
+
+describe('Pipes Lifecycle', () => {
+ let pipes: PipesClient;
+ let sqs: SQSClient;
+
+ beforeAll(() => {
+ pipes = makeClient(PipesClient);
+ sqs = makeClient(SQSClient);
+ });
+
+ it('should start and stop a pipe', async () => {
+ const pipeName = `node-pipe-lifecycle-${uniqueName()}`;
+ const srcQueue = `node-pipe-src-lifecycle-${uniqueName()}`;
+ const tgtQueue = `node-pipe-tgt-lifecycle-${uniqueName()}`;
+
+ await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ const startResponse = await pipes.send(new StartPipeCommand({ Name: pipeName }));
+ expect(startResponse.CurrentState).toBe('RUNNING');
+
+ const stopResponse = await pipes.send(new StopPipeCommand({ Name: pipeName }));
+ expect(stopResponse.CurrentState).toBe('STOPPED');
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, srcQueue) })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: await getQueueUrl(sqs, tgtQueue) })).catch(() => {});
+ }
+ });
+});
+
+describe('Pipes Polling', () => {
+ let pipes: PipesClient;
+ let sqs: SQSClient;
+
+ beforeAll(() => {
+ pipes = makeClient(PipesClient);
+ sqs = makeClient(SQSClient);
+ });
+
+ it('should forward SQS messages to SQS target', async () => {
+ const pipeName = `node-pipe-fwd-${uniqueName()}`;
+ const srcQueue = `node-pipe-src-fwd-${uniqueName()}`;
+ const tgtQueue = `node-pipe-tgt-fwd-${uniqueName()}`;
+
+ const srcResp = await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ const srcUrl = srcResp.QueueUrl!;
+ const tgtResp = await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+ const tgtUrl = tgtResp.QueueUrl!;
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.RUNNING,
+ })
+ );
+
+ await sqs.send(
+ new SendMessageCommand({ QueueUrl: srcUrl, MessageBody: 'hello from pipes' })
+ );
+
+ let found = false;
+ for (let i = 0; i < 15; i++) {
+ await sleep(1000);
+ const r = await sqs.send(
+ new ReceiveMessageCommand({
+ QueueUrl: tgtUrl,
+ MaxNumberOfMessages: 1,
+ WaitTimeSeconds: 1,
+ })
+ );
+ if (r.Messages?.length && r.Messages[0].Body?.includes('hello from pipes')) {
+ found = true;
+ break;
+ }
+ }
+
+ expect(found).toBe(true);
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: srcUrl })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: tgtUrl })).catch(() => {});
+ }
+ });
+
+ it('should not forward messages when pipe is stopped', async () => {
+ const pipeName = `node-pipe-nofwd-${uniqueName()}`;
+ const srcQueue = `node-pipe-src-nofwd-${uniqueName()}`;
+ const tgtQueue = `node-pipe-tgt-nofwd-${uniqueName()}`;
+
+ const srcResp = await sqs.send(new CreateQueueCommand({ QueueName: srcQueue }));
+ const srcUrl = srcResp.QueueUrl!;
+ const tgtResp = await sqs.send(new CreateQueueCommand({ QueueName: tgtQueue }));
+ const tgtUrl = tgtResp.QueueUrl!;
+
+ try {
+ await pipes.send(
+ new CreatePipeCommand({
+ Name: pipeName,
+ Source: sqsArn(srcQueue),
+ Target: sqsArn(tgtQueue),
+ RoleArn: ROLE_ARN,
+ DesiredState: RequestedPipeState.STOPPED,
+ })
+ );
+
+ await sqs.send(
+ new SendMessageCommand({ QueueUrl: srcUrl, MessageBody: 'should not forward' })
+ );
+
+ await sleep(3000);
+
+ const attrs = await sqs.send(
+ new GetQueueAttributesCommand({
+ QueueUrl: srcUrl,
+ AttributeNames: ['ApproximateNumberOfMessages'],
+ })
+ );
+ expect(attrs.Attributes?.ApproximateNumberOfMessages).toBe('1');
+
+ const r = await sqs.send(
+ new ReceiveMessageCommand({
+ QueueUrl: tgtUrl,
+ MaxNumberOfMessages: 1,
+ WaitTimeSeconds: 1,
+ })
+ );
+ expect(r.Messages ?? []).toHaveLength(0);
+ } finally {
+ await pipes.send(new DeletePipeCommand({ Name: pipeName })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: srcUrl })).catch(() => {});
+ await sqs.send(new DeleteQueueCommand({ QueueUrl: tgtUrl })).catch(() => {});
+ }
+ });
+});
diff --git a/compatibility-tests/sdk-test-python/conftest.py b/compatibility-tests/sdk-test-python/conftest.py
index 6a17bf726c..ed224e19c8 100644
--- a/compatibility-tests/sdk-test-python/conftest.py
+++ b/compatibility-tests/sdk-test-python/conftest.py
@@ -145,6 +145,12 @@ def ecr_client(aws_config, client_config):
return boto3.client("ecr", config=client_config, **aws_config)
+def pipes_client(aws_config, client_config):
+ """Create EventBridge Pipes client."""
+ return boto3.client("pipes", config=client_config, **aws_config)
+
+
# ============================================
# Utility Fixtures
# ============================================
diff --git a/compatibility-tests/sdk-test-python/tests/test_pipes.py b/compatibility-tests/sdk-test-python/tests/test_pipes.py
new file mode 100644
index 0000000000..a3d56f6b48
--- /dev/null
+++ b/compatibility-tests/sdk-test-python/tests/test_pipes.py
@@ -0,0 +1,307 @@
+"""EventBridge Pipes integration tests."""
+
+import time
+
+import pytest
+from botocore.exceptions import ClientError
+
+ACCOUNT_ID = "000000000000"
+REGION = "us-east-1"
+ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/pipe-role"
+
+
+def sqs_arn(queue_name):
+ return f"arn:aws:sqs:{REGION}:{ACCOUNT_ID}:{queue_name}"
+
+
+class TestPipesCRUD:
+ """Test Pipes create, describe, list, update, delete operations."""
+
+ def test_create_pipe(self, pipes_client, sqs_client, unique_name):
+ """Test CreatePipe creates a pipe in STOPPED state."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ response = pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+ assert response["CurrentState"] == "STOPPED"
+ assert pipe_name in response["Arn"]
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+ def test_describe_pipe(self, pipes_client, sqs_client, unique_name):
+ """Test DescribePipe returns pipe details."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+ response = pipes_client.describe_pipe(Name=pipe_name)
+ assert response["Name"] == pipe_name
+ assert response["Source"] == sqs_arn(src_name)
+ assert response["Target"] == sqs_arn(tgt_name)
+ assert response["CurrentState"] == "STOPPED"
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+ def test_list_pipes(self, pipes_client, sqs_client, unique_name):
+ """Test ListPipes returns created pipe."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+ response = pipes_client.list_pipes()
+ names = [p["Name"] for p in response["Pipes"]]
+ assert pipe_name in names
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+ def test_update_pipe(self, pipes_client, sqs_client, unique_name):
+ """Test UpdatePipe updates pipe description."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+ pipes_client.update_pipe(
+ Name=pipe_name,
+ RoleArn=ROLE_ARN,
+ Description="updated via SDK",
+ DesiredState="STOPPED",
+ )
+ response = pipes_client.describe_pipe(Name=pipe_name)
+ assert response["Description"] == "updated via SDK"
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+ def test_delete_pipe(self, pipes_client, sqs_client, unique_name):
+ """Test DeletePipe removes the pipe."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+ pipes_client.delete_pipe(Name=pipe_name)
+
+ with pytest.raises(ClientError) as exc_info:
+ pipes_client.describe_pipe(Name=pipe_name)
+ assert exc_info.value.response["Error"]["Code"] == "NotFoundException"
+ finally:
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+ def test_describe_nonexistent_pipe(self, pipes_client):
+ """Test DescribePipe for non-existent pipe returns NotFoundException."""
+ with pytest.raises(ClientError) as exc_info:
+ pipes_client.describe_pipe(Name="nonexistent-pipe")
+ assert exc_info.value.response["Error"]["Code"] == "NotFoundException"
+
+
+class TestPipesLifecycle:
+ """Test Pipes start/stop operations."""
+
+ def test_start_and_stop_pipe(self, pipes_client, sqs_client, unique_name):
+ """Test StartPipe and StopPipe transitions."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ sqs_client.create_queue(QueueName=src_name)
+ sqs_client.create_queue(QueueName=tgt_name)
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+
+ response = pipes_client.start_pipe(Name=pipe_name)
+ assert response["CurrentState"] == "RUNNING"
+
+ response = pipes_client.stop_pipe(Name=pipe_name)
+ assert response["CurrentState"] == "STOPPED"
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, src_name))
+ sqs_client.delete_queue(QueueUrl=_queue_url(sqs_client, tgt_name))
+
+
+class TestPipesPolling:
+ """Test Pipes source polling and target invocation."""
+
+ def test_sqs_to_sqs_forwarding(self, pipes_client, sqs_client, unique_name):
+ """Test that a RUNNING pipe forwards SQS messages to SQS target."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ src_resp = sqs_client.create_queue(QueueName=src_name)
+ src_url = src_resp["QueueUrl"]
+ tgt_resp = sqs_client.create_queue(QueueName=tgt_name)
+ tgt_url = tgt_resp["QueueUrl"]
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="RUNNING",
+ )
+
+ sqs_client.send_message(QueueUrl=src_url, MessageBody="hello from pipes")
+
+ found = False
+ for _ in range(15):
+ time.sleep(1)
+ resp = sqs_client.receive_message(
+ QueueUrl=tgt_url, MaxNumberOfMessages=1, WaitTimeSeconds=1
+ )
+ msgs = resp.get("Messages", [])
+ if msgs and "hello from pipes" in msgs[0]["Body"]:
+ found = True
+ break
+
+ assert found, "Target queue should receive forwarded message"
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=src_url)
+ sqs_client.delete_queue(QueueUrl=tgt_url)
+
+ def test_stopped_pipe_does_not_forward(self, pipes_client, sqs_client, unique_name):
+ """Test that a STOPPED pipe does not forward messages."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ src_resp = sqs_client.create_queue(QueueName=src_name)
+ src_url = src_resp["QueueUrl"]
+ tgt_resp = sqs_client.create_queue(QueueName=tgt_name)
+ tgt_url = tgt_resp["QueueUrl"]
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="STOPPED",
+ )
+
+ sqs_client.send_message(QueueUrl=src_url, MessageBody="should not forward")
+ time.sleep(3)
+
+ attrs = sqs_client.get_queue_attributes(
+ QueueUrl=src_url, AttributeNames=["ApproximateNumberOfMessages"]
+ )
+ assert attrs["Attributes"]["ApproximateNumberOfMessages"] == "1"
+
+ resp = sqs_client.receive_message(
+ QueueUrl=tgt_url, MaxNumberOfMessages=1, WaitTimeSeconds=1
+ )
+ assert len(resp.get("Messages", [])) == 0
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=src_url)
+ sqs_client.delete_queue(QueueUrl=tgt_url)
+
+ def test_source_queue_drained_after_forwarding(
+ self, pipes_client, sqs_client, unique_name
+ ):
+ """Test that source queue messages are deleted after forwarding."""
+ src_name = f"pipe-src-{unique_name}"
+ tgt_name = f"pipe-tgt-{unique_name}"
+ pipe_name = f"pipe-{unique_name}"
+
+ src_resp = sqs_client.create_queue(QueueName=src_name)
+ src_url = src_resp["QueueUrl"]
+ tgt_resp = sqs_client.create_queue(QueueName=tgt_name)
+ tgt_url = tgt_resp["QueueUrl"]
+ try:
+ pipes_client.create_pipe(
+ Name=pipe_name,
+ Source=sqs_arn(src_name),
+ Target=sqs_arn(tgt_name),
+ RoleArn=ROLE_ARN,
+ DesiredState="RUNNING",
+ )
+
+ sqs_client.send_message(QueueUrl=src_url, MessageBody="drain test")
+
+ drained = False
+ for _ in range(15):
+ time.sleep(1)
+ attrs = sqs_client.get_queue_attributes(
+ QueueUrl=src_url, AttributeNames=["ApproximateNumberOfMessages"]
+ )
+ if attrs["Attributes"]["ApproximateNumberOfMessages"] == "0":
+ drained = True
+ break
+
+ assert drained, "Source queue should be drained after pipe forwards messages"
+ finally:
+ pipes_client.delete_pipe(Name=pipe_name)
+ sqs_client.delete_queue(QueueUrl=src_url)
+ sqs_client.delete_queue(QueueUrl=tgt_url)
+
+
+def _queue_url(sqs_client, queue_name):
+ """Get queue URL by name, ignoring errors."""
+ try:
+ return sqs_client.get_queue_url(QueueName=queue_name)["QueueUrl"]
+ except Exception:
+ return ""
diff --git a/compatibility-tests/sdk-test-rust/Cargo.toml b/compatibility-tests/sdk-test-rust/Cargo.toml
index f59fa1b760..015b9962e6 100644
--- a/compatibility-tests/sdk-test-rust/Cargo.toml
+++ b/compatibility-tests/sdk-test-rust/Cargo.toml
@@ -22,6 +22,7 @@ aws-sdk-secretsmanager = "1"
aws-sdk-kms = "1"
aws-sdk-kinesis = "1"
aws-sdk-lambda = "1"
+aws-sdk-pipes = "1"
aws-sdk-cloudwatch = "1"
aws-sdk-cognitoidentityprovider = "1"
aws-sdk-cloudformation = "1"
diff --git a/compatibility-tests/sdk-test-rust/src/lib.rs b/compatibility-tests/sdk-test-rust/src/lib.rs
index e0628f1e73..f2ceed2af7 100644
--- a/compatibility-tests/sdk-test-rust/src/lib.rs
+++ b/compatibility-tests/sdk-test-rust/src/lib.rs
@@ -99,6 +99,11 @@ pub async fn cloudformation_client() -> aws_sdk_cloudformation::Client {
aws_sdk_cloudformation::Client::new(&base_config().await)
}
+/// Returns an EventBridge Pipes client.
+pub async fn pipes_client() -> aws_sdk_pipes::Client {
+ aws_sdk_pipes::Client::new(&base_config().await)
+}
+
/// Returns a minimal Lambda deployment zip with a Node.js handler.
pub fn minimal_zip() -> Vec<u8> {
use std::io::Write;
diff --git a/compatibility-tests/sdk-test-rust/tests/pipes_test.rs b/compatibility-tests/sdk-test-rust/tests/pipes_test.rs
new file mode 100644
index 0000000000..d31cd29185
--- /dev/null
+++ b/compatibility-tests/sdk-test-rust/tests/pipes_test.rs
@@ -0,0 +1,406 @@
+mod common;
+
+const ACCOUNT_ID: &str = "000000000000";
+const REGION: &str = "us-east-1";
+const ROLE_ARN: &str = "arn:aws:iam::000000000000:role/pipe-role";
+
+fn sqs_arn(queue_name: &str) -> String {
+ format!("arn:aws:sqs:{}:{}:{}", REGION, ACCOUNT_ID, queue_name)
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_create_pipe() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-create";
+ let tgt_queue = "rust-pipe-tgt-create";
+ let pipe_name = "rust-pipe-create";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ let result = pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await;
+ assert!(result.is_ok(), "CreatePipe failed: {:?}", result.err());
+
+ let output = result.unwrap();
+ assert_eq!(
+ output.current_state(),
+ Some(&aws_sdk_pipes::types::PipeState::Stopped)
+ );
+ assert!(output.arn().unwrap_or("").contains(pipe_name));
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_describe_pipe() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-describe";
+ let tgt_queue = "rust-pipe-tgt-describe";
+ let pipe_name = "rust-pipe-describe";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ let result = pipes.describe_pipe().name(pipe_name).send().await;
+ assert!(result.is_ok(), "DescribePipe failed: {:?}", result.err());
+
+ let output = result.unwrap();
+ assert_eq!(output.name().unwrap_or(""), pipe_name);
+ assert_eq!(output.source().unwrap_or(""), sqs_arn(src_queue));
+ assert_eq!(output.target().unwrap_or(""), sqs_arn(tgt_queue));
+ assert_eq!(
+ output.current_state(),
+ Some(&aws_sdk_pipes::types::PipeState::Stopped)
+ );
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_list_pipes() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-list";
+ let tgt_queue = "rust-pipe-tgt-list";
+ let pipe_name = "rust-pipe-list";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ let result = pipes.list_pipes().send().await;
+ assert!(result.is_ok(), "ListPipes failed: {:?}", result.err());
+
+ let found = result
+ .unwrap()
+ .pipes()
+ .iter()
+ .any(|p| p.name().unwrap_or("") == pipe_name);
+ assert!(found, "pipe should appear in list");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_update_pipe() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-update";
+ let tgt_queue = "rust-pipe-tgt-update";
+ let pipe_name = "rust-pipe-update";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ pipes
+ .update_pipe()
+ .name(pipe_name)
+ .role_arn(ROLE_ARN)
+ .description("updated via SDK")
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("update pipe");
+
+ let result = pipes.describe_pipe().name(pipe_name).send().await.expect("describe pipe");
+ assert_eq!(result.description().unwrap_or(""), "updated via SDK");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_delete_pipe() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-del";
+ let tgt_queue = "rust-pipe-tgt-del";
+ let pipe_name = "rust-pipe-del";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let sqs = sqs.clone();
+ async move {
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ let result = pipes.delete_pipe().name(pipe_name).send().await;
+ assert!(result.is_ok(), "DeletePipe failed: {:?}", result.err());
+
+ let describe = pipes.describe_pipe().name(pipe_name).send().await;
+ assert!(describe.is_err(), "DescribePipe should fail after deletion");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_describe_nonexistent() {
+ let pipes = common::pipes_client().await;
+ let result = pipes.describe_pipe().name("nonexistent-pipe").send().await;
+ assert!(result.is_err());
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_start_and_stop() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-startstop";
+ let tgt_queue = "rust-pipe-tgt-startstop";
+ let pipe_name = "rust-pipe-startstop";
+
+ sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ cleanup_queue(&sqs, src_queue).await;
+ cleanup_queue(&sqs, tgt_queue).await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ let start = pipes.start_pipe().name(pipe_name).send().await;
+ assert!(start.is_ok(), "StartPipe failed: {:?}", start.err());
+ assert_eq!(
+ start.unwrap().current_state(),
+ Some(&aws_sdk_pipes::types::PipeState::Running)
+ );
+
+ let stop = pipes.stop_pipe().name(pipe_name).send().await;
+ assert!(stop.is_ok(), "StopPipe failed: {:?}", stop.err());
+ assert_eq!(
+ stop.unwrap().current_state(),
+ Some(&aws_sdk_pipes::types::PipeState::Stopped)
+ );
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_sqs_to_sqs_forwarding() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-fwd";
+ let tgt_queue = "rust-pipe-tgt-fwd";
+ let pipe_name = "rust-pipe-fwd";
+
+ let src_resp = sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ let src_url = src_resp.queue_url().unwrap_or("").to_string();
+ let tgt_resp = sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+ let tgt_url = tgt_resp.queue_url().unwrap_or("").to_string();
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ let src_url = src_url.clone();
+ let tgt_url = tgt_url.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ let _ = sqs.delete_queue().queue_url(&src_url).send().await;
+ let _ = sqs.delete_queue().queue_url(&tgt_url).send().await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Running)
+ .send()
+ .await
+ .expect("create pipe");
+
+ sqs.send_message()
+ .queue_url(&src_url)
+ .message_body("hello from pipes")
+ .send()
+ .await
+ .expect("send message");
+
+ let mut found = false;
+ for _ in 0..15 {
+ tokio::time::sleep(std::time::Duration::from_secs(1)).await;
+ let recv = sqs
+ .receive_message()
+ .queue_url(&tgt_url)
+ .max_number_of_messages(1)
+ .wait_time_seconds(1)
+ .send()
+ .await;
+ if let Ok(r) = recv {
+ if let Some(msgs) = r.messages() {
+ if !msgs.is_empty() && msgs[0].body().unwrap_or("").contains("hello from pipes") {
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ assert!(found, "target queue should receive forwarded message");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn test_pipes_stopped_pipe_does_not_forward() {
+ let pipes = common::pipes_client().await;
+ let sqs = common::sqs_client().await;
+ let src_queue = "rust-pipe-src-nofwd";
+ let tgt_queue = "rust-pipe-tgt-nofwd";
+ let pipe_name = "rust-pipe-nofwd";
+
+ let src_resp = sqs.create_queue().queue_name(src_queue).send().await.expect("create src queue");
+ let src_url = src_resp.queue_url().unwrap_or("").to_string();
+ let tgt_resp = sqs.create_queue().queue_name(tgt_queue).send().await.expect("create tgt queue");
+ let tgt_url = tgt_resp.queue_url().unwrap_or("").to_string();
+
+ let _guard = common::CleanupGuard::new({
+ let pipes = pipes.clone();
+ let sqs = sqs.clone();
+ let src_url = src_url.clone();
+ let tgt_url = tgt_url.clone();
+ async move {
+ let _ = pipes.delete_pipe().name(pipe_name).send().await;
+ let _ = sqs.delete_queue().queue_url(&src_url).send().await;
+ let _ = sqs.delete_queue().queue_url(&tgt_url).send().await;
+ }
+ });
+
+ pipes
+ .create_pipe()
+ .name(pipe_name)
+ .source(sqs_arn(src_queue))
+ .target(sqs_arn(tgt_queue))
+ .role_arn(ROLE_ARN)
+ .desired_state(aws_sdk_pipes::types::RequestedPipeState::Stopped)
+ .send()
+ .await
+ .expect("create pipe");
+
+ sqs.send_message()
+ .queue_url(&src_url)
+ .message_body("should not forward")
+ .send()
+ .await
+ .expect("send message");
+
+ tokio::time::sleep(std::time::Duration::from_secs(3)).await;
+
+ let recv = sqs
+ .receive_message()
+ .queue_url(&tgt_url)
+ .max_number_of_messages(1)
+ .wait_time_seconds(1)
+ .send()
+ .await
+ .expect("receive message");
+ assert!(
+ recv.messages().is_empty(),
+ "target queue should be empty"
+ );
+}
+
+async fn cleanup_queue(sqs: &aws_sdk_sqs::Client, queue_name: &str) {
+ if let Ok(r) = sqs.get_queue_url().queue_name(queue_name).send().await {
+ if let Some(url) = r.queue_url() {
+ let _ = sqs.delete_queue().queue_url(url).send().await;
+ }
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycle.java b/src/main/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycle.java
index 0907d268da..5babb53145 100644
--- a/src/main/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycle.java
+++ b/src/main/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycle.java
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.elasticache.proxy.ElastiCacheProxyMan
import io.github.hectorvent.floci.services.lambda.DynamoDbStreamsEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.KinesisEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.SqsEventSourcePoller;
+import io.github.hectorvent.floci.services.pipes.PipesService;
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
import io.github.hectorvent.floci.services.rds.proxy.RdsProxyManager;
import io.quarkus.runtime.Quarkus;
@@ -42,6 +43,7 @@ public class EmulatorLifecycle {
private final SqsEventSourcePoller sqsPoller;
private final KinesisEventSourcePoller kinesisPoller;
private final DynamoDbStreamsEventSourcePoller dynamodbStreamsPoller;
+ private final PipesService pipesService;
@Inject
public EmulatorLifecycle(StorageFactory storageFactory, ServiceRegistry serviceRegistry,
@@ -53,7 +55,8 @@ public class EmulatorLifecycle {
InitializationHooksRunner initializationHooksRunner,
SqsEventSourcePoller sqsPoller,
KinesisEventSourcePoller kinesisPoller,
- DynamoDbStreamsEventSourcePoller dynamodbStreamsPoller) {
+ DynamoDbStreamsEventSourcePoller dynamodbStreamsPoller,
+ PipesService pipesService) {
this.storageFactory = storageFactory;
this.serviceRegistry = serviceRegistry;
this.config = config;
@@ -65,6 +68,7 @@ public class EmulatorLifecycle {
this.sqsPoller = sqsPoller;
this.kinesisPoller = kinesisPoller;
this.dynamodbStreamsPoller = dynamodbStreamsPoller;
+ this.pipesService = pipesService;
}
void onStart(@Observes StartupEvent ignored) {
@@ -78,6 +82,7 @@ public class EmulatorLifecycle {
sqsPoller.startPersistedPollers();
kinesisPoller.startPersistedPollers();
dynamodbStreamsPoller.startPersistedPollers();
+ pipesService.startPersistedPollers();
if (!initializationHooksRunner.hasHooks(InitializationHook.START)) {
LOG.info("=== AWS Local Emulator Ready ===");
diff --git a/src/main/java/io/github/hectorvent/floci/services/pipes/PipesPoller.java b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesPoller.java
new file mode 100644
index 0000000000..18385ac225
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesPoller.java
@@ -0,0 +1,321 @@
+package io.github.hectorvent.floci.services.pipes;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.services.dynamodb.DynamoDbStreamService;
+import io.github.hectorvent.floci.services.kinesis.KinesisService;
+import io.github.hectorvent.floci.services.pipes.model.DesiredState;
+import io.github.hectorvent.floci.services.pipes.model.Pipe;
+import io.github.hectorvent.floci.services.sqs.SqsService;
+import io.github.hectorvent.floci.services.sqs.model.Message;
+import io.vertx.core.Vertx;
+import jakarta.annotation.PreDestroy;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@ApplicationScoped
+public class PipesPoller {
+
+ private static final Logger LOG = Logger.getLogger(PipesPoller.class);
+ private static final long POLL_INTERVAL_MS = 1000;
+ private static final int DEFAULT_BATCH_SIZE = 10;
+
+ private final Vertx vertx;
+ private final SqsService sqsService;
+ private final KinesisService kinesisService;
+ private final DynamoDbStreamService dynamoDbStreamService;
+ private final PipesTargetInvoker targetInvoker;
+ private final ObjectMapper objectMapper;
+ private final String baseUrl;
+ private final ConcurrentHashMap<String, Long> timerIds = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, Boolean> activePolls = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, String> kinesisIterators = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, String> dynamoDbIterators = new ConcurrentHashMap<>();
+ private final ExecutorService pollExecutor = Executors.newCachedThreadPool(r -> {
+ Thread t = new Thread(r, "pipes-poller");
+ t.setDaemon(true);
+ return t;
+ });
+
+ @Inject
+ public PipesPoller(Vertx vertx,
+ SqsService sqsService,
+ KinesisService kinesisService,
+ DynamoDbStreamService dynamoDbStreamService,
+ PipesTargetInvoker targetInvoker,
+ ObjectMapper objectMapper,
+ EmulatorConfig config) {
+ this.vertx = vertx;
+ this.sqsService = sqsService;
+ this.kinesisService = kinesisService;
+ this.dynamoDbStreamService = dynamoDbStreamService;
+ this.targetInvoker = targetInvoker;
+ this.objectMapper = objectMapper;
+ this.baseUrl = config.effectiveBaseUrl();
+ }
+
+ @PreDestroy
+ void shutdown() {
+ pollExecutor.shutdownNow();
+ timerIds.values().forEach(vertx::cancelTimer);
+ timerIds.clear();
+ LOG.info("PipesPoller shut down");
+ }
+
+ public void startPolling(Pipe pipe) {
+ String pipeKey = pipeKey(pipe);
+ if (timerIds.containsKey(pipeKey)) {
+ return;
+ }
+ long timerId = vertx.setPeriodic(POLL_INTERVAL_MS, id -> pollAndInvoke(pipe));
+ timerIds.put(pipeKey, timerId);
+ LOG.infov("Pipe {0}: started polling source {1}", pipe.getName(), pipe.getSource());
+ }
+
+ public void stopPolling(Pipe pipe) {
+ String pipeKey = pipeKey(pipe);
+ Long timerId = timerIds.remove(pipeKey);
+ if (timerId != null) {
+ vertx.cancelTimer(timerId);
+ kinesisIterators.remove(pipeKey);
+ dynamoDbIterators.remove(pipeKey);
+ LOG.infov("Pipe {0}: stopped polling", pipe.getName());
+ }
+ }
+
+ public boolean isPolling(Pipe pipe) {
+ return timerIds.containsKey(pipeKey(pipe));
+ }
+
+ private void pollAndInvoke(Pipe pipe) {
+ String pipeKey = pipeKey(pipe);
+ if (activePolls.putIfAbsent(pipeKey, Boolean.TRUE) != null) {
+ return;
+ }
+ pollExecutor.submit(() -> {
+ try {
+ if (pipe.getDesiredState() != DesiredState.RUNNING) {
+ return;
+ }
+ String sourceArn = pipe.getSource();
+ String region = extractRegionFromArn(sourceArn);
+ if (sourceArn.contains(":sqs:")) {
+ pollSqs(pipe, region);
+ } else if (sourceArn.contains(":kinesis:")) {
+ pollKinesis(pipe, region);
+ } else if (sourceArn.contains(":dynamodb:")) {
+ pollDynamoDbStreams(pipe, region);
+ } else {
+ LOG.warnv("Pipe {0}: unsupported source type: {1}", pipe.getName(), sourceArn);
+ }
+ } catch (Exception e) {
+ LOG.warnv("Pipe {0}: poll error: {1} ({2})",
+ pipe.getName(), e.getMessage(), e.getClass().getSimpleName());
+ } finally {
+ activePolls.remove(pipeKey);
+ }
+ });
+ }
+
+ private void pollSqs(Pipe pipe, String region) {
+ String queueUrl = AwsArnUtils.arnToQueueUrl(pipe.getSource(), baseUrl);
+ List<Message> messages = sqsService.receiveMessage(queueUrl, DEFAULT_BATCH_SIZE, 30, 0, region);
+ if (messages.isEmpty()) {
+ return;
+ }
+ LOG.infov("Pipe {0}: received {1} SQS message(s)", pipe.getName(), messages.size());
+ String eventJson = buildSqsEvent(messages, pipe);
+ targetInvoker.invoke(pipe, eventJson, region);
+ for (Message msg : messages) {
+ try {
+ sqsService.deleteMessage(queueUrl, msg.getReceiptHandle(), region);
+ } catch (Exception e) {
+ LOG.warnv("Pipe {0}: failed to delete SQS message {1}: {2}",
+ pipe.getName(), msg.getMessageId(), e.getMessage());
+ }
+ }
+ }
+
+ private void pollKinesis(Pipe pipe, String region) {
+ String pipeKey = pipeKey(pipe);
+ String streamName = extractResourceName(pipe.getSource());
+ String iterator = kinesisIterators.get(pipeKey);
+ if (iterator == null) {
+ iterator = initKinesisIterator(streamName, region);
+ if (iterator == null) return;
+ }
+ try {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> result = kinesisService.getRecords(iterator, DEFAULT_BATCH_SIZE, region);
+ String nextIterator = (String) result.get("NextShardIterator");
+ if (nextIterator != null) {
+ kinesisIterators.put(pipeKey, nextIterator);
+ }
+ @SuppressWarnings("unchecked")
+ List<?> records = (List<?>) result.get("Records");
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ LOG.infov("Pipe {0}: received {1} Kinesis record(s)", pipe.getName(), records.size());
+ String eventJson = buildKinesisEvent(records, pipe, region);
+ targetInvoker.invoke(pipe, eventJson, region);
+ } catch (AwsException e) {
+ if ("ExpiredIteratorException".equals(e.getErrorCode())) {
+ kinesisIterators.remove(pipeKey);
+ }
+ throw e;
+ }
+ }
+
+ private String initKinesisIterator(String streamName, String region) {
+ try {
+ return kinesisService.getShardIterator(
+ streamName, "shardId-000000000000", "TRIM_HORIZON", null, null, region);
+ } catch (Exception e) {
+ LOG.warnv("Failed to get Kinesis shard iterator for {0}: {1}", streamName, e.getMessage());
+ return null;
+ }
+ }
+
+ private void pollDynamoDbStreams(Pipe pipe, String region) {
+ String pipeKey = pipeKey(pipe);
+ String streamArn = pipe.getSource();
+ String iterator = dynamoDbIterators.get(pipeKey);
+ if (iterator == null) {
+ iterator = initDynamoDbIterator(streamArn);
+ if (iterator == null) return;
+ }
+ try {
+ var result = dynamoDbStreamService.getRecords(iterator, DEFAULT_BATCH_SIZE);
+ String nextIterator = result.nextShardIterator();
+ if (nextIterator != null) {
+ dynamoDbIterators.put(pipeKey, nextIterator);
+ }
+ var records = result.records();
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ LOG.infov("Pipe {0}: received {1} DynamoDB Stream record(s)", pipe.getName(), records.size());
+ String eventJson = buildDynamoDbEvent(records, pipe, region);
+ targetInvoker.invoke(pipe, eventJson, region);
+ } catch (AwsException e) {
+ if ("ExpiredIteratorException".equals(e.getErrorCode()) ||
+ "TrimmedDataAccessException".equals(e.getErrorCode())) {
+ dynamoDbIterators.remove(pipeKey);
+ }
+ throw e;
+ }
+ }
+
+ private String initDynamoDbIterator(String streamArn) {
+ try {
+ return dynamoDbStreamService.getShardIterator(
+ streamArn, DynamoDbStreamService.SHARD_ID, "TRIM_HORIZON", null);
+ } catch (Exception e) {
+ LOG.warnv("Failed to get DynamoDB stream iterator for {0}: {1}", streamArn, e.getMessage());
+ return null;
+ }
+ }
+
+ // ──────────────────────────── Event Builders ────────────────────────────
+
+ private String buildSqsEvent(List<Message> messages, Pipe pipe) {
+ try {
+ var records = objectMapper.createArrayNode();
+ for (Message msg : messages) {
+ ObjectNode record = objectMapper.createObjectNode();
+ record.put("messageId", msg.getMessageId());
+ record.put("receiptHandle", msg.getReceiptHandle());
+ record.put("body", msg.getBody());
+ ObjectNode attrs = record.putObject("attributes");
+ attrs.put("ApproximateReceiveCount", String.valueOf(msg.getReceiveCount()));
+ attrs.put("SentTimestamp", String.valueOf(System.currentTimeMillis()));
+ record.putObject("messageAttributes");
+ record.put("md5OfBody", msg.getMd5OfBody() != null ? msg.getMd5OfBody() : "");
+ record.put("eventSource", "aws:sqs");
+ record.put("eventSourceARN", pipe.getSource());
+ record.put("awsRegion", extractRegionFromArn(pipe.getSource()));
+ records.add(record);
+ }
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("Records", records);
+ return objectMapper.writeValueAsString(root);
+ } catch (Exception e) {
+ return "{\"Records\":[]}";
+ }
+ }
+
+ private String buildKinesisEvent(List<?> records, Pipe pipe, String region) {
+ try {
+ var recordsArray = objectMapper.createArrayNode();
+ for (Object record : records) {
+ ObjectNode node = objectMapper.valueToTree(record);
+ ObjectNode eventRecord = objectMapper.createObjectNode();
+ eventRecord.put("eventSource", "aws:kinesis");
+ eventRecord.put("eventSourceARN", pipe.getSource());
+ eventRecord.put("awsRegion", region);
+ eventRecord.put("eventID", pipe.getSource() + ":" +
+ node.path("SequenceNumber").asText());
+ ObjectNode kinesis = eventRecord.putObject("kinesis");
+ kinesis.put("partitionKey", node.path("PartitionKey").asText());
+ kinesis.put("sequenceNumber", node.path("SequenceNumber").asText());
+ kinesis.put("approximateArrivalTimestamp",
+ node.path("ApproximateArrivalTimestamp").asDouble());
+ String data = node.path("Data").asText();
+ kinesis.put("data", data);
+ recordsArray.add(eventRecord);
+ }
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("Records", recordsArray);
+ return objectMapper.writeValueAsString(root);
+ } catch (Exception e) {
+ return "{\"Records\":[]}";
+ }
+ }
+
+ private String buildDynamoDbEvent(List<?> records, Pipe pipe, String region) {
+ try {
+ var recordsArray = objectMapper.createArrayNode();
+ for (Object record : records) {
+ ObjectNode node = objectMapper.valueToTree(record);
+ node.put("eventSource", "aws:dynamodb");
+ node.put("eventSourceARN", pipe.getSource());
+ node.put("awsRegion", region);
+ recordsArray.add(node);
+ }
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("Records", recordsArray);
+ return objectMapper.writeValueAsString(root);
+ } catch (Exception e) {
+ return "{\"Records\":[]}";
+ }
+ }
+
+ // ──────────────────────────── Utilities ────────────────────────────
+
+ private static String pipeKey(Pipe pipe) {
+ return pipe.getArn();
+ }
+
+ private static String extractRegionFromArn(String arn) {
+ String[] parts = arn.split(":");
+ return parts.length >= 4 ? parts[3] : "us-east-1";
+ }
+
+ private static String extractResourceName(String arn) {
+ int slashIdx = arn.lastIndexOf('/');
+ if (slashIdx >= 0) return arn.substring(slashIdx + 1);
+ int colonIdx = arn.lastIndexOf(':');
+ return colonIdx >= 0 ? arn.substring(colonIdx + 1) : arn;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/pipes/PipesService.java b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesService.java
index 4c803aeae4..f4e5ce85a2 100644
--- a/src/main/java/io/github/hectorvent/floci/services/pipes/PipesService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesService.java
@@ -27,12 +27,26 @@ public class PipesService implements TagHandler {
private final StorageBackend<String, Pipe> storage;
private final EmulatorConfig config;
+ private final PipesPoller poller;
@Inject
- public PipesService(StorageFactory storageFactory, EmulatorConfig config) {
+ public PipesService(StorageFactory storageFactory, EmulatorConfig config, PipesPoller poller) {
this.storage = storageFactory.create("pipes", "pipes.json",
new TypeReference<Map<String, Pipe>>() {});
this.config = config;
+ this.poller = poller;
+ }
+
+ public void startPersistedPollers() {
+ List<Pipe> runningPipes = storage.scan(key -> true).stream()
+ .filter(pipe -> pipe.getCurrentState() == PipeState.RUNNING)
+ .toList();
+ for (Pipe pipe : runningPipes) {
+ poller.startPolling(pipe);
+ }
+ if (!runningPipes.isEmpty()) {
+ LOG.infov("Resumed polling for {0} pipe(s)", runningPipes.size());
+ }
}
public Pipe createPipe(String name, String source, String target, String roleArn,
@@ -83,6 +97,10 @@ public class PipesService implements TagHandler {
storage.put(key, pipe);
LOG.infov("Created pipe: {0}", name);
+
+ if (pipe.getCurrentState() == PipeState.RUNNING) {
+ poller.startPolling(pipe);
+ }
return pipe;
}
@@ -108,6 +126,11 @@ public class PipesService implements TagHandler {
if (desiredState != null) {
pipe.setDesiredState(desiredState);
pipe.setCurrentState(desiredState == DesiredState.RUNNING ? PipeState.RUNNING : PipeState.STOPPED);
+ if (desiredState == DesiredState.RUNNING) {
+ poller.startPolling(pipe);
+ } else {
+ poller.stopPolling(pipe);
+ }
}
if (enrichment != null) pipe.setEnrichment(enrichment);
if (sourceParameters != null) pipe.setSourceParameters(sourceParameters);
@@ -122,10 +145,10 @@ public class PipesService implements TagHandler {
public void deletePipe(String name, String region) {
String key = region + "::" + name;
- if (storage.get(key).isEmpty()) {
- throw new AwsException("NotFoundException",
- "Pipe " + name + " does not exist.", 404);
- }
+ Pipe pipe = storage.get(key)
+ .orElseThrow(() -> new AwsException("NotFoundException",
+ "Pipe " + name + " does not exist.", 404));
+ poller.stopPolling(pipe);
storage.delete(key);
LOG.infov("Deleted pipe: {0}", name);
}
@@ -152,6 +175,7 @@ public class PipesService implements TagHandler {
pipe.setCurrentState(PipeState.RUNNING);
pipe.setLastModifiedTime(Instant.now());
storage.put(key, pipe);
+ poller.startPolling(pipe);
LOG.infov("Started pipe: {0}", name);
return pipe;
}
@@ -162,6 +186,7 @@ public class PipesService implements TagHandler {
.orElseThrow(() -> new AwsException("NotFoundException",
"Pipe " + name + " does not exist.", 404));
+ poller.stopPolling(pipe);
pipe.setDesiredState(DesiredState.STOPPED);
pipe.setCurrentState(PipeState.STOPPED);
pipe.setLastModifiedTime(Instant.now());
diff --git a/src/main/java/io/github/hectorvent/floci/services/pipes/PipesTargetInvoker.java b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesTargetInvoker.java
new file mode 100644
index 0000000000..9b4fd72c28
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/pipes/PipesTargetInvoker.java
@@ -0,0 +1,116 @@
+package io.github.hectorvent.floci.services.pipes;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.services.eventbridge.EventBridgeService;
+import io.github.hectorvent.floci.services.lambda.LambdaService;
+import io.github.hectorvent.floci.services.lambda.model.InvocationType;
+import io.github.hectorvent.floci.services.pipes.model.Pipe;
+import io.github.hectorvent.floci.services.sns.SnsService;
+import io.github.hectorvent.floci.services.sqs.SqsService;
+import io.github.hectorvent.floci.services.stepfunctions.StepFunctionsService;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@ApplicationScoped
+public class PipesTargetInvoker {
+
+ private static final Logger LOG = Logger.getLogger(PipesTargetInvoker.class);
+
+ private final LambdaService lambdaService;
+ private final SqsService sqsService;
+ private final SnsService snsService;
+ private final EventBridgeService eventBridgeService;
+ private final StepFunctionsService stepFunctionsService;
+ private final ObjectMapper objectMapper;
+ private final String baseUrl;
+
+ @Inject
+ public PipesTargetInvoker(LambdaService lambdaService,
+ SqsService sqsService,
+ SnsService snsService,
+ EventBridgeService eventBridgeService,
+ StepFunctionsService stepFunctionsService,
+ ObjectMapper objectMapper,
+ EmulatorConfig config) {
+ this.lambdaService = lambdaService;
+ this.sqsService = sqsService;
+ this.snsService = snsService;
+ this.eventBridgeService = eventBridgeService;
+ this.stepFunctionsService = stepFunctionsService;
+ this.objectMapper = objectMapper;
+ this.baseUrl = config.effectiveBaseUrl();
+ }
+
+ public void invoke(Pipe pipe, String payload, String region) {
+ String targetArn = pipe.getTarget();
+ try {
+ if (targetArn.contains(":lambda:") || targetArn.contains(":function:")) {
+ invokeLambda(targetArn, payload, region);
+ } else if (targetArn.contains(":sqs:")) {
+ invokeSqs(targetArn, payload);
+ } else if (targetArn.contains(":sns:")) {
+ invokeSns(targetArn, payload, region);
+ } else if (targetArn.contains(":events:")) {
+ invokeEventBridge(targetArn, payload, region);
+ } else if (targetArn.contains(":states:")) {
+ invokeStepFunctions(targetArn, payload, region);
+ } else {
+ LOG.warnv("Pipe {0}: unsupported target ARN type: {1}", pipe.getName(), targetArn);
+ }
+ } catch (Exception e) {
+ LOG.warnv("Pipe {0}: failed to deliver to target {1}: {2}",
+ pipe.getName(), targetArn, e.getMessage());
+ }
+ }
+
+ private void invokeLambda(String arn, String payload, String region) {
+ String fnName = arn.substring(arn.lastIndexOf(':') + 1);
+ String fnRegion = extractRegionFromArn(arn, region);
+ lambdaService.invoke(fnRegion, fnName, payload.getBytes(), InvocationType.RequestResponse);
+ LOG.debugv("Pipe delivered to Lambda: {0}", arn);
+ }
+
+ private void invokeSqs(String arn, String payload) {
+ String queueUrl = AwsArnUtils.arnToQueueUrl(arn, baseUrl);
+ sqsService.sendMessage(queueUrl, payload, 0);
+ LOG.debugv("Pipe delivered to SQS: {0}", arn);
+ }
+
+ private void invokeSns(String arn, String payload, String region) {
+ String topicRegion = extractRegionFromArn(arn, region);
+ snsService.publish(arn, null, payload, "Pipes", topicRegion);
+ LOG.debugv("Pipe delivered to SNS: {0}", arn);
+ }
+
+ private void invokeEventBridge(String arn, String payload, String region) {
+ String busName = arn.substring(arn.lastIndexOf('/') + 1);
+ String ebRegion = extractRegionFromArn(arn, region);
+ Map<String, Object> entry = Map.of(
+ "EventBusName", busName,
+ "Source", "aws.pipes",
+ "DetailType", "PipeForwarded",
+ "Detail", payload
+ );
+ eventBridgeService.putEvents(List.of(entry), ebRegion);
+ LOG.debugv("Pipe delivered to EventBridge: {0}", arn);
+ }
+
+ private void invokeStepFunctions(String arn, String payload, String region) {
+ String sfnRegion = extractRegionFromArn(arn, region);
+ String executionName = "pipes-" + UUID.randomUUID();
+ stepFunctionsService.startExecution(arn, executionName, payload, sfnRegion);
+ LOG.debugv("Pipe delivered to Step Functions: {0}", arn);
+ }
+
+ private static String extractRegionFromArn(String arn, String defaultRegion) {
+ String[] parts = arn.split(":");
+ return parts.length >= 4 && !parts[3].isEmpty() ? parts[3] : defaultRegion;
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycleTest.java b/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycleTest.java
index 4323afb966..3a79835baf 100644
--- a/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycleTest.java
+++ b/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorLifecycleTest.java
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.elasticache.proxy.ElastiCacheProxyMan
import io.github.hectorvent.floci.services.lambda.DynamoDbStreamsEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.KinesisEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.SqsEventSourcePoller;
+import io.github.hectorvent.floci.services.pipes.PipesService;
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
import io.github.hectorvent.floci.services.rds.proxy.RdsProxyManager;
import io.quarkus.runtime.ShutdownDelayInitiatedEvent;
@@ -45,6 +46,7 @@ class EmulatorLifecycleTest {
@Mock private SqsEventSourcePoller sqsPoller;
@Mock private KinesisEventSourcePoller kinesisPoller;
@Mock private DynamoDbStreamsEventSourcePoller dynamodbStreamsPoller;
+ @Mock private PipesService pipesService;
private EmulatorLifecycle emulatorLifecycle;
@@ -54,7 +56,7 @@ class EmulatorLifecycleTest {
storageFactory, serviceRegistry, config,
elastiCacheContainerManager, elastiCacheProxyManager,
rdsContainerManager, rdsProxyManager, initializationHooksRunner,
- sqsPoller, kinesisPoller, dynamodbStreamsPoller);
+ sqsPoller, kinesisPoller, dynamodbStreamsPoller, pipesService);
}
private void stubStorageConfig() {
diff --git a/src/test/java/io/github/hectorvent/floci/services/pipes/PipesPollerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/pipes/PipesPollerIntegrationTest.java
new file mode 100644
index 0000000000..78178e4240
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/pipes/PipesPollerIntegrationTest.java
@@ -0,0 +1,169 @@
+package io.github.hectorvent.floci.services.pipes;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.*;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class PipesPollerIntegrationTest {
+
+ private static final String SQS_CONTENT_TYPE = "application/x-www-form-urlencoded";
+
+ @Test
+ @Order(1)
+ void createSourceQueue() {
+ given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "CreateQueue")
+ .formParam("QueueName", "pipe-source-queue")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ @Order(2)
+ void createTargetQueue() {
+ given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "CreateQueue")
+ .formParam("QueueName", "pipe-target-queue")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ @Order(3)
+ void createPipeFromSqsToSqs() {
+ given()
+ .contentType("application/json")
+ .body("""
+ {
+ "Source": "arn:aws:sqs:us-east-1:000000000000:pipe-source-queue",
+ "Target": "arn:aws:sqs:us-east-1:000000000000:pipe-target-queue",
+ "RoleArn": "arn:aws:iam::000000000000:role/pipe-role",
+ "DesiredState": "RUNNING"
+ }
+ """)
+ .when()
+ .post("/v1/pipes/sqs-to-sqs-pipe")
+ .then()
+ .statusCode(200)
+ .body("CurrentState", equalTo("RUNNING"));
+ }
+
+ @Test
+ @Order(4)
+ void sendMessageToSourceQueue() {
+ given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "SendMessage")
+ .formParam("QueueUrl", "http://localhost:4566/000000000000/pipe-source-queue")
+ .formParam("MessageBody", "hello from pipes")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200);
+ }
+
+ @Test
+ @Order(5)
+ void targetQueueReceivesForwardedMessage() throws Exception {
+ String body = null;
+ for (int i = 0; i < 10; i++) {
+ Thread.sleep(500);
+ body = given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "ReceiveMessage")
+ .formParam("QueueUrl", "http://localhost:4566/000000000000/pipe-target-queue")
+ .formParam("MaxNumberOfMessages", "1")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .extract().body().asString();
+
+ if (body.contains("hello from pipes") || body.contains("Records")) {
+ break;
+ }
+ }
+ assertTrue(body.contains("hello from pipes") || body.contains("Records"),
+ "Target queue should contain forwarded message but got: " + body);
+ }
+
+ @Test
+ @Order(6)
+ void sourceQueueIsDrained() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ Thread.sleep(500);
+ String body = given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "GetQueueAttributes")
+ .formParam("QueueUrl", "http://localhost:4566/000000000000/pipe-source-queue")
+ .formParam("AttributeName.1", "ApproximateNumberOfMessages")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .extract().body().asString();
+
+ if (body.contains("<Value>0</Value>")) {
+ return;
+ }
+ }
+ org.junit.jupiter.api.Assertions.fail("Source queue should be drained");
+ }
+
+ @Test
+ @Order(7)
+ void stopPipeStopsPolling() {
+ given()
+ .contentType("application/json")
+ .when()
+ .post("/v1/pipes/sqs-to-sqs-pipe/stop")
+ .then()
+ .statusCode(200)
+ .body("CurrentState", equalTo("STOPPED"));
+
+ given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "SendMessage")
+ .formParam("QueueUrl", "http://localhost:4566/000000000000/pipe-source-queue")
+ .formParam("MessageBody", "should stay in source")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200);
+
+ try { Thread.sleep(2000); } catch (InterruptedException ignored) {}
+
+ given()
+ .contentType(SQS_CONTENT_TYPE)
+ .formParam("Action", "GetQueueAttributes")
+ .formParam("QueueUrl", "http://localhost:4566/000000000000/pipe-source-queue")
+ .formParam("AttributeName.1", "ApproximateNumberOfMessages")
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body(containsString("<Value>1</Value>"));
+ }
+
+ @Test
+ @Order(8)
+ void cleanupPipe() {
+ given()
+ .contentType("application/json")
+ .when()
+ .delete("/v1/pipes/sqs-to-sqs-pipe")
+ .then()
+ .statusCode(200);
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/services/pipes/PipesServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/pipes/PipesServiceTest.java
index d366ac96f7..6b2644ebc2 100644
--- a/src/test/java/io/github/hectorvent/floci/services/pipes/PipesServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/pipes/PipesServiceTest.java
@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
class PipesServiceTest {
@@ -30,7 +31,8 @@ class PipesServiceTest {
EmulatorConfig config = Mockito.mock(EmulatorConfig.class);
when(config.defaultAccountId()).thenReturn("000000000000");
- pipesService = new PipesService(storageFactory, config);
+ PipesPoller poller = Mockito.mock(PipesPoller.class);
+ pipesService = new PipesService(storageFactory, config, poller);
}
@Test