What is the best way to create an AWS CodeBuild Project with a GitHub Webhook for running checks on Pull Requests using the aws-cdk?
Unfortunately, as of writing this (December 2018), this functionality is not supported through CloudFormation (see AWS forum post here).
Because the CDK uses CloudFormation behind the scenes to perform deployments, if something is not supported in CloudFormation, we also can't support it in the CDK.
EDIT: I was actually wrong. While the branchFilter attribute that you see in the AWS Console for CodeBuild is not supported in CloudFormation, the webhook itself is.
Example code of creating a webhook with the CDK (in TypeScript):
import codebuild = require('@aws-cdk/aws-codebuild');
import cdk = require('@aws-cdk/cdk');
const project = new codebuild.Project(this, 'MyProject', {
source: new codebuild.GitHubSource({
owner: 'awslabs',
repo: 'aws-cdk',
oauthToken: new cdk.SecretParameter(this, 'GitHubOAuthToken', {
ssmParameter: 'my-github-token',
}),
webhook: true, // default: false
}),
// remaining Project parameters here...
});
Note that you need CDK version 0.21.0 or later for this functionality to be present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With