Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
1 task
phmello20 opened this issue Dec 12, 2024 · 5 comments
Closed
1 task
Assignees
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. p2

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
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-reproduction This issue needs reproduction. labels Dec 14, 2024
@khushail
Copy link
Contributor

Hi @phmello20 , thanks for reaching out.

Here is the sample code for reproducing the issue -

    const eventBus = new events.EventBus(this, 'EventBus');

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

and the synthesized template -

"EventIssueStackE5385CAB": {
   "Type": "AWS::Events::Rule",
   "Properties": {
    "EventBusName": {
     "Ref": "EventBus7B8748AA"
    },
    "EventPattern": {
     "detail": {
      "matchPrefix": [
       {
        "prefix": "created"
       }
      ],
      "matchSuffix": [
       {
        "suffix": "created"
       }
      ]
     }
    },
    "State": "ENABLED"
   },

which seems as expected.

is there anything being missed in the code ? Would request you to share insights on how this issue could be reproduced.

Thanks

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Dec 14, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 16, 2024
@phmello20
Copy link
Author

hey @khushail, thanks for your response, I'll try again and I'll let you know shortly

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Dec 17, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests

3 participants