Skip to content

EventPattern: JSON Serialization of detail_type is incorrect #16563

@mickael-caro-sonarsource

Description

While using the aws_events.EventPattern class, cdk output as JSON, for detail_type renders detailType instead of detail-type, which cause the pattern to not match the real payload received from EventBridge.

Reproduction Steps

Create the following event pattern

    event_pattern = aws_events.EventPattern(
        account=[core.Aws.ACCOUNT_ID],
        detail={
        'Status': ['Failed', 'TimedOut', 'Cancelled']
    },
        region='eu-central-1',
        source=['aws.ssm'],
        detail_type=['EC2 Automation Execution Status-change Notification']
    )

When issuing a CDK synth, the output eventPattern looks like this :

"EventPattern": {
"account": [
{
"Ref": "AWS::AccountId"
}
],
"detail": {
"Status": [
"Failed",
"TimedOut",
"Cancelled"
]
},
"detailType": [
"EC2 Automation Execution Status-change Notification"
],
"region": [
"eu-central-1"
],
"source": [
"aws.ssm"
]
}

What did you expect to happen?

detailType object should be rendered as detail-type instead.

Environment

  • **CDK CLI Version :1.122.0 **
  • **Node.js Version: v14.15.5 **
  • **OS :Ubuntu 18.04 LTS **
  • **Language (Version): Python 3.8.10 **

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-eventsRelated to CloudWatch EventsbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions