Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/@aws-cdk/mixins-preview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const pattern = bucketEvents.objectCreatedPattern({

### Standalone Event Patterns

Standalone patterns are not tied to any specific resource. They match events across all resources of that type. For example, a standalone `awsAPICallViaCloudTrailPattern()` will match CloudTrail API calls for all S3 buckets in the account, not just a specific one.
Standalone patterns are not tied to any specific resource. They match events across all resources of that type. For example, a standalone `AWSAPICallViaCloudTrail.eventPattern()` will match CloudTrail API calls for all S3 buckets in the account, not just a specific one.

#### Event Patterns Basic Usage

Expand All @@ -229,7 +229,7 @@ declare const fn: lambda.Function;

// Works with L2 Rule
new events.Rule(scope, 'Rule', {
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern({
eventPattern: AWSAPICallViaCloudTrail.eventPattern({
tlsDetails: { tlsVersion: ['TLSv1.3'] },
eventMetadata: { region: ['us-east-1'] },
}),
Expand All @@ -239,7 +239,7 @@ new events.Rule(scope, 'Rule', {
// Also works with L1 CfnRule
new events.CfnRule(scope, 'CfnRule', {
state: 'ENABLED',
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern({
eventPattern: AWSAPICallViaCloudTrail.eventPattern({
tlsDetails: { tlsVersion: ['TLSv1.3'] },
eventMetadata: { region: ['us-east-1'] },
}),
Expand All @@ -253,7 +253,7 @@ new events.CfnRule(scope, 'CfnRule', {
import { AWSAPICallViaCloudTrail } from '@aws-cdk/mixins-preview/aws-s3/events';

// Matches CloudTrail API calls across ALL S3 buckets
const pattern = AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern();
const pattern = AWSAPICallViaCloudTrail.eventPattern();
```

**Event Metadata Support**: Control EventBridge pattern metadata
Expand All @@ -262,7 +262,7 @@ const pattern = AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern();
import { AWSAPICallViaCloudTrail } from '@aws-cdk/mixins-preview/aws-s3/events';
import * as events from 'aws-cdk-lib/aws-events';

const pattern = AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern({
const pattern = AWSAPICallViaCloudTrail.eventPattern({
eventMetadata: {
region: events.Match.prefix('us-'),
version: ['0']
Expand All @@ -276,10 +276,10 @@ Event patterns are generated for EventBridge events available in the AWS Event S

**S3 Events**:

* `objectCreatedPattern()` - Object creation events
* `objectDeletedPattern()` - Object deletion events
* `objectTagsAddedPattern()` - Object tagging events
* `awsAPICallViaCloudTrailPattern()` - CloudTrail API calls
* `ObjectCreated.eventPattern()` - Object creation events
* `ObjectDeleted.eventPattern()` - Object deletion events
* `ObjectTagsAdded.eventPattern()` - Object tagging events
* `AWSAPICallViaCloudTrail.eventPattern()` - CloudTrail API calls

Import events from service-specific modules:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,8 @@ class StandaloneEventGenerator {
hasResource,
});

const methodName = naming.eventPatternMethodName(namespaceName);
const eventPatternMethod = eventNamespace.addMethod({
name: methodName,
name: 'eventPattern',
static: true,
returnType: eventsEventPattern,
docs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('with L2 Rule', () => {

test('awsAPICallViaCloudTrailPattern with tlsDetails and eventMetadata', () => {
new Rule(stack, 'Rule', {
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern({
eventPattern: AWSAPICallViaCloudTrail.eventPattern({
tlsDetails: { tlsVersion: ['TLSv1.3'] },
eventMetadata: { region: ['us-east-1'] },
}),
Expand All @@ -31,7 +31,7 @@ describe('with L2 Rule', () => {

test('awsAPICallViaCloudTrailPattern bare call', () => {
new Rule(stack, 'Rule', {
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern(),
eventPattern: AWSAPICallViaCloudTrail.eventPattern(),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand All @@ -44,7 +44,7 @@ describe('with L2 Rule', () => {

test('objectCreatedPattern with reason filter', () => {
new Rule(stack, 'Rule', {
eventPattern: ObjectCreated.objectCreatedPattern({ reason: ['PutObject'] }),
eventPattern: ObjectCreated.eventPattern({ reason: ['PutObject'] }),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand All @@ -58,7 +58,7 @@ describe('with L2 Rule', () => {

test('objectDeletedPattern with reason filter', () => {
new Rule(stack, 'Rule', {
eventPattern: ObjectDeleted.objectDeletedPattern({ reason: ['DeleteObject'] }),
eventPattern: ObjectDeleted.eventPattern({ reason: ['DeleteObject'] }),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand All @@ -80,7 +80,7 @@ describe('with L1 CfnRule', () => {
test('awsAPICallViaCloudTrailPattern with tlsDetails and eventMetadata', () => {
new CfnRule(stack, 'Rule', {
state: 'ENABLED',
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern({
eventPattern: AWSAPICallViaCloudTrail.eventPattern({
tlsDetails: { tlsVersion: ['TLSv1.3'] },
eventMetadata: { region: ['us-east-1'] },
}),
Expand All @@ -101,7 +101,7 @@ describe('with L1 CfnRule', () => {
test('awsAPICallViaCloudTrailPattern bare call', () => {
new CfnRule(stack, 'Rule', {
state: 'ENABLED',
eventPattern: AWSAPICallViaCloudTrail.awsAPICallViaCloudTrailPattern(),
eventPattern: AWSAPICallViaCloudTrail.eventPattern(),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand All @@ -115,7 +115,7 @@ describe('with L1 CfnRule', () => {
test('objectCreatedPattern with reason filter', () => {
new CfnRule(stack, 'Rule', {
state: 'ENABLED',
eventPattern: ObjectCreated.objectCreatedPattern({ reason: ['PutObject'] }),
eventPattern: ObjectCreated.eventPattern({ reason: ['PutObject'] }),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand All @@ -130,7 +130,7 @@ describe('with L1 CfnRule', () => {
test('objectDeletedPattern with reason filter', () => {
new CfnRule(stack, 'Rule', {
state: 'ENABLED',
eventPattern: ObjectDeleted.objectDeletedPattern({ reason: ['DeleteObject'] }),
eventPattern: ObjectDeleted.eventPattern({ reason: ['DeleteObject'] }),
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
Expand Down
Loading