Skip to content
v2.275.0

Experimental

@aws-cdk/aws-pipes-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

Filter Class ​

The collection of event patterns used to filter events.

Example ​

ts
declare const sourceQueue: sqs.Queue;
declare const targetQueue: sqs.Queue;

const sourceFilter = new pipes.Filter(
  [
    pipes.FilterPattern.fromObject({
      body: {
        // only forward events with customerType B2B or B2C
        customerType: ['B2B', 'B2C']
      },
    })
  ]
)

const pipe = new pipes.Pipe(this, 'Pipe', {
  source: new SqsSource(sourceQueue),
  target: new SqsTarget(targetQueue),
  filter: sourceFilter,
});
python
# source_queue: sqs.Queue
# target_queue: sqs.Queue


source_filter = pipes.Filter([
    pipes.FilterPattern.from_object({
        "body": {
            # only forward events with customerType B2B or B2C
            "customer_type": ["B2B", "B2C"]
        }
    })
])

pipe = pipes.Pipe(self, "Pipe",
    source=SqsSource(source_queue),
    target=SqsTarget(target_queue),
    filter=source_filter
)
java
Queue sourceQueue;
Queue targetQueue;


Filter sourceFilter = new Filter(List.of(FilterPattern.fromObject(Map.of(
        "body", Map.of(
                // only forward events with customerType B2B or B2C
                "customerType", List.of("B2B", "B2C"))))));

Pipe pipe = Pipe.Builder.create(this, "Pipe")
        .source(new SqsSource(sourceQueue))
        .target(new SqsTarget(targetQueue))
        .filter(sourceFilter)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Pipes.Alpha
Queue sourceQueue;
Queue targetQueue;


var sourceFilter = new Filter(new [] { FilterPattern.FromObject(new Dictionary<string, object> {
    { "body", new Dictionary<string, string[]> {
        // only forward events with customerType B2B or B2C
        { "customerType", new [] { "B2B", "B2C" } }
    } }
}) });

var pipe = new Pipe(this, "Pipe", new PipeProps {
    Source = new SqsSource(sourceQueue),
    Target = new SqsTarget(targetQueue),
    Filter = sourceFilter
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkpipesalpha/v2
var sourceQueue Queue
var targetQueue Queue


sourceFilter := pipes.NewFilter([]IFilterPattern{
	pipes.FilterPattern_FromObject(map[string]interface{}{
		"body": map[string][]*string{
			// only forward events with customerType B2B or B2C
			"customerType": []*string{
				jsii.String("B2B"),
				jsii.String("B2C"),
			},
		},
	}),
})

pipe := pipes.NewPipe(this, jsii.String("Pipe"), &PipeProps{
	Source: awscdkpipessourcesalpha.NewSqsSource(sourceQueue),
	Target: awscdkpipestargetsalpha.NewSqsTarget(targetQueue),
	Filter: sourceFilter,
})

Initializer ​

ts
new Filter(filter: IFilterPattern[])
python
Filter(filter: typing.List[IFilterPattern])
java
new Filter(List<IFilterPattern> filter)
csharp
new Filter(IFilterPattern[] filter)
go
NewFilter(Filter *[]IFilterPattern)

Properties ​

filtersIFilterPattern[]filterstyping.List[IFilterPattern]filtersList<IFilterPattern>FiltersIFilterPattern[]Filters*[]IFilterPattern#
Filters for the source.