AWS CDK CodePipeline S3 Source set Detection Option to Cloudwatch

39 Views Asked by At

I am using AWS CDK to create a S3SourceAction in AWS CodePipeline as shown in the screenshot attached. However this is using AWS CodePipeline as the detection option. How can I make the detection option Amazon CloudWatch Events via CDK? enter image description here

Here is my current code for the S3SourceAction.

const sourceAction = new S3SourceAction({

  actionName: 'S3ConfigSource',

  bucket: bucketConfigFiles,

  bucketKey: zippedConfigsDir,

  output: sourceOutput,

  role: codeDeployRole,

});

Or if that’s not possible is there another way via CDK to automatically have my Pipeline run on changes to a S3 Bucket file?

1

There are 1 best solutions below

0
Caldazar On

In your sourceAction creation just add trigger: codepipeline_actions.S3Trigger.EVENTS

const sourceAction = new S3SourceAction({
  actionName: 'S3ConfigSource',
  bucket: bucketConfigFiles,
  bucketKey: zippedConfigsDir,
  output: sourceOutput,
  trigger: codepipeline_actions.S3Trigger.EVENTS,
  role: codeDeployRole,

});

From CDK documentation, these are trigger options:

  • NONE The Action will never detect changes - the Pipeline it's part of will only begin a run when explicitly started.
  • POLL CodePipeline will poll S3 to detect changes.
  • EVENTS CodePipeline will use CloudWatch Events to be notified of changes.