Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(events rule): Event pattern is not valid. Reason: suffix match pattern must be a string #32492

Open
1 task
phmello20 opened this issue Dec 12, 2024 · 1 comment
Assignees
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. needs-reproduction This issue needs reproduction. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@phmello20
Copy link

phmello20 commented Dec 12, 2024

Describe the bug

Match.suffix method seems to be generating an invalid event patter

Here's the example:

const searchIndexRule = new events.Rule(this, id, {
    eventPattern: {
      detail: {
        matchPrefix: events.Match.prefix('created'),
        matchSuffix: events.Match.suffix('created'),
      },
    },
    eventBus,
    enabled,
  });

Once the code is deployed the result is the following:

{
    "Rules": [
        {
            "Name": "----",
            "Arn": "----",
            "EventPattern": "{\"detail\": {\"matchPrefix\": [{\"prefix\": \"created:\"}], \"matchSuffix\": [{\"suffix\": [\":created\"]}]}}",
            "State": "ENABLED",
        }
    ]
}

prefix works fine and the result is {"prefix": "created"} however, suffix is invalid as the result is {"suffix":["created"]}

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

the event patter should be {"suffix":"created"}

Current Behavior

the event pattern is {"suffix":["created"]}

Reproduction Steps

cdk deploy

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.172.0

Framework Version

No response

Node.js Version

v20.12.2

OS

Mac OS 14.6.1

Language

TypeScript

Language Version

5.6.3

Other information

No response

@phmello20 phmello20 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2024
@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Dec 12, 2024
@nmussy
Copy link
Contributor

nmussy commented Dec 12, 2024

I'm not able to reproduce the issue in your example, would you be able to provide a complete reproducible code sample?

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');
const eventBus = new EventBus(stack, 'EventBus');
new Rule(stack, 'Rule', {
  eventPattern: {
    detail: {
      matchPrefix: m.prefix('created'),
      matchSuffix: m.suffix('created'),
    },
  },
  eventBus,
});

Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
  'EventPattern': {
    'detail': {
      matchPrefix: [{ 'prefix': 'created' }],
      matchSuffix: [{ 'suffix': 'created' }],
    },
  },
  'State': 'ENABLED',
});

EDIT: I misread your expected result, sorry about that

@khushail khushail added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2024
@khushail khushail self-assigned this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. needs-reproduction This issue needs reproduction. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants