aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

(pipelines): Allow using S3 Event Notifications as pipeline trigger. #26894

Open SantiRaposo opened 1 year ago

SantiRaposo commented 1 year ago

Describe the feature

Currently, the S3 triggers that CDK Pipelines support are described here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline_actions.S3Trigger.html

However, a simpler way to enable eventbridge notifications for an S3 bucket exists as a bucket level setting: https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html

However when using S3Trigger.EVENTS the generated event pattern is:

{
  "detail-type": ["AWS API Call via CloudTrail"],
  "source": ["aws.s3"],
  "detail": {
    "requestParameters": {
      "bucketName": ["<bucket-name>"],
      "key": ["<buckt-key>"]
    },
    "resources": {
      "ARN": ["<object-arn>"]
    },
    "eventName": ["CompleteMultipartUpload", "CopyObject", "PutObject"]
  }
}

Which does not match with the event generated by the S3 integration.

Use Case

Allow using event-triggered pipes (which AWS recommends https://docs.aws.amazon.com/codepipeline/latest/userguide/update-change-detection.html#update-change-detection-S3-event) without having to provision a CloudTrail trail.

Proposed Solution

Another enum value that generates an event pattern similar to the following:

{
  "source": [
    "aws.s3"
  ],
  "detailType": [
    "Object Created",
    "Object Restore Completed"
  ],
  "detail": {
    "bucket": {
      "name": "<bucket-name>"
    },
    "object": {
      "key": "<object-key>"
    }
  }
}

Other Information

No response

Acknowledgements

CDK version used

2.93.0

Environment details (OS name and version, etc.)

macOS 13.5.1

pahud commented 1 year ago

Makes sense for me. And this is the recommended configuration according to the document.

tgmedia-nz commented 11 months ago

same here - please prioritise :)