flaviostutz / flaviostutz/cdk-practical-constructs

EventType enum should include a larger set of common AWS events

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
7
Forks
7
PR merge metrics
No merged PRs in 30d

Description

## Problem being solved

In the `BaseNodeJsFunction` construct the field `eventType` is limited to this enum:
```ts
export enum EventType {
Cloudwatch = 'cloudwatch',
Http = 'http',
CustomResource = 'custom-resource',
}
```

That does not cover all "common" AWS events (e.g. SQS, StepFunctions, EventBridge, etc) and it makes consuming the construct slightly confusing for those scenarios.

And as a consumer of the construct it seems you have to reccur to using a custom resource:

```ts
new BaseNodeJsFunction(
this,
'my-function-name',
{
eventType: EventType.CustomResource,
baseCodePath: 'src/handlers',
```

## Proposal

1. Improve the enum list to include more event types.
2. Allow sending any `string` value if the consumer wishes to standardize his project in his own setup without having to always use `entry`

Examples of the proposal:

```ts
new BaseNodeJsFunction(
this,
'my-function-name',
{
eventType: EventType.Sqs,
baseCodePath: 'src/handlers',

new BaseNodeJsFunction(
this,
'my-function-name',
{
eventType: EventType.StepFunction,
baseCodePath: 'src/handlers',

new BaseNodeJsFunction(
this,
'my-function-name',
{
eventType: 'my-custom-event-type',
baseCodePath: 'src/handlers',
```

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.