aws / aws/aws-cdk

codebuild: Multiple entries in FilterGroup.inEventOf generates incorrect CloudFormation entry

Open
#33,197 1 comment 0 reactions 1 assignee Claimed by @pahud View on GitHub
@aws-cdk/aws-codebuild bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

```typescript
const project = new Project(this, 'MyProject', {
source: Source.gitHub({
webhook: true,
webhookFilters: [
FilterGroup.inEventOf(
EventAction.PULL_REQUEST_CREATED,
EventAction.PULL_REQUEST_UPDATED,
),
]
})
})
```

This results in a CloudFormation template like this:

```yaml
Triggers:
FilterGroups:
- - Pattern: PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED
Type: EVENT
```

Note the space after the comma.

This doesn't actually work when deployed to AWS using `cdk deploy`; only the first entry is honored, and the CodeBuild UI just shows `PULL_REQUEST_CREATED` as the trigger.

I have confirmed that the space is the issue, by using the following escape hatch, which generates without the space and works correctly on AWS:

```typescript
const cfnProject = project.node.defaultChild as CfnProject
const triggers = cfnProject.triggers as CfnProject.ProjectTriggersProperty
const filterGroups = triggers.filterGroups as CfnProject.WebhookFilterProperty[][]
filterGroups[0].pop()
filterGroups[0].push({
type: 'EVENT',
pattern: 'PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED',
})
```

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

Correct CodeFormation template to be generated.

### Current Behavior

Incorrect CodeFormation template was generated.

### Reproduction Steps

As above.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.177.0 (build b396961)

### Framework Version

aws-cdk and aws-cdk-lib both 2.177.0

### Node.js Version

v20.14.0

### OS

macOS 15.1.1 (24B91)

### Language

TypeScript

### Language Version

TypeScript 5.5.4

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.