@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)",
date="2022-08-02T20:25:28.778Z")
public interface EventPattern
Important: this class can only be used with a Rule
class. In particular,
do not use it with CfnRule
class: your pattern will not be rendered
correctly. In a CfnRule
class, write the pattern as you normally would when
directly writing CloudFormation.
Rules use event patterns to select events and route them to targets. A pattern either matches an event or it doesn't. Event patterns are represented as JSON objects with a structure that is similar to that of events.
It is important to remember the following about event pattern matching:
"*": "*"
wildcard for fields not mentioned.Example:
import software.amazon.awscdk.services.lambda.*; Function fn = Function.Builder.create(this, "MyFunc") .runtime(Runtime.NODEJS_12_X) .handler("index.handler") .code(Code.fromInline("exports.handler = handler.toString()")) .build(); Rule rule = Rule.Builder.create(this, "rule") .eventPattern(EventPattern.builder() .source(List.of("aws.ec2")) .build()) .build(); Queue queue = new Queue(this, "Queue"); rule.addTarget(LambdaFunction.Builder.create(fn) .deadLetterQueue(queue) // Optional: add a dead letter queue .maxEventAge(Duration.hours(2)) // Optional: set the maxEventAge retry policy .retryAttempts(2) .build());
Modifier and Type | Interface and Description |
---|---|
static class |
EventPattern.Builder
A builder for
EventPattern |
static class |
EventPattern.Jsii$Proxy
An implementation for
EventPattern |
Modifier and Type | Method and Description |
---|---|
static EventPattern.Builder |
builder() |
default java.util.List<java.lang.String> |
getAccount()
The 12-digit number identifying an AWS account.
|
default java.util.Map<java.lang.String,java.lang.Object> |
getDetail()
A JSON object, whose content is at the discretion of the service originating the event.
|
default java.util.List<java.lang.String> |
getDetailType()
Identifies, in combination with the source field, the fields and values that appear in the detail field.
|
default java.util.List<java.lang.String> |
getId()
A unique value is generated for every event.
|
default java.util.List<java.lang.String> |
getRegion()
Identifies the AWS region where the event originated.
|
default java.util.List<java.lang.String> |
getResources()
This JSON array contains ARNs that identify resources that are involved in the event.
|
default java.util.List<java.lang.String> |
getSource()
Identifies the service that sourced the event.
|
default java.util.List<java.lang.String> |
getTime()
The event timestamp, which can be specified by the service originating the event.
|
default java.util.List<java.lang.String> |
getVersion()
By default, this is set to 0 (zero) in all events.
|
default java.util.List<java.lang.String> getAccount()
Default: - No filtering on account
default java.util.Map<java.lang.String,java.lang.Object> getDetail()
Default: - No filtering on detail
default java.util.List<java.lang.String> getDetailType()
Represents the "detail-type" event field.
Default: - No filtering on detail type
default java.util.List<java.lang.String> getId()
This can be helpful in tracing events as they move through rules to targets, and are processed.
Default: - No filtering on id
default java.util.List<java.lang.String> getRegion()
Default: - No filtering on region
default java.util.List<java.lang.String> getResources()
Inclusion of these ARNs is at the discretion of the service.
For example, Amazon EC2 instance state-changes include Amazon EC2 instance ARNs, Auto Scaling events include ARNs for both instances and Auto Scaling groups, but API calls with AWS CloudTrail do not include resource ARNs.
Default: - No filtering on resource
default java.util.List<java.lang.String> getSource()
All events sourced from within AWS begin with "aws." Customer-generated events can have any value here, as long as it doesn't begin with "aws." We recommend the use of Java package-name style reverse domain-name strings.
To find the correct value for source for an AWS service, see the table in AWS Service Namespaces. For example, the source value for Amazon CloudFront is aws.cloudfront.
Default: - No filtering on source
default java.util.List<java.lang.String> getTime()
If the event spans a time interval, the service might choose to report the start time, so this value can be noticeably before the time the event is actually received.
Default: - No filtering on time
default java.util.List<java.lang.String> getVersion()
Default: - No filtering on version
static EventPattern.Builder builder()
EventPattern.Builder
of EventPattern