aws-cdk: (@aws-cdk/aws-codestarnotifications): CodeCommit repository not supported as source for Notification Rule

Currently @aws-cdk/aws-codestarnotifications module does not seem to support using repository as the source. However, this does appear to be supported in Cloudformation. From the CDK api docs: “Currently, Supported sources include pipelines in AWS CodePipeline and build projects in AWS CodeBuild in this L2 constructor.”

and from CloudFormation template reference: “Supported resources include pipelines in AWS CodePipeline, repositories in AWS CodeCommit, and build projects in AWS CodeBuild.”

In the console notification rules can easily be created for repository events and sent to SNS or Chatbot targets. I would like to replicate that with the CDK.

Environment

  • CDK CLI Version: 1.109.0
  • Module Version: 1.109.0
  • Node.js Version: 14.17.0
  • OS: Windows 10
  • Language (Version): 4.3.4

Other information

According to CloudFormation, an ARN is required, however re-creating an ARN won’t work INotificationRuleSource won’t accept a string. Ideally it should work something like this:

    const repositoryNotification = new NotificationRule(this, 'PullRequestNotificationRule', {
      source: repository.repositoryArn,
      events: [
        'codecommit-repository-pull-request-created',
        'codecommit-repository-pull-request-merged'
      ],
      targets: [chatbot],
      detailType: DetailType.FULL,
      notificationRuleName: 'pull-request-status'
    })
    repositoryNotification.addTarget(chatbot)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@luckily Back in business. I followed the blog post you referenced and used WSL2 on WIndows. Got the environment working. Now I can go back to working on the code.

@aws-cdk/aws-codecommit: yarn run v1.22.10
@aws-cdk/aws-codecommit: $ cdk-test
@aws-cdk/aws-codecommit: test.codecommit.js
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - add an SNS trigger to repository
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - fails when triggers have duplicate names
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - can be imported using a Repository ARN
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - can be imported using a Repository ARN and respect the region in clone urls
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - can be imported using just a Repository name (the ARN is deduced)
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - grant push
@aws-cdk/aws-codecommit: ✔ CodeCommit Repositories - HTTPS (GRC) clone URL
@aws-cdk/aws-codecommit: OK: 13 assertions (10484ms)
@aws-cdk/aws-codecommit: =============================== Coverage summary ===============================
@aws-cdk/aws-codecommit: Statements   : 57.38% ( 70/122 )
@aws-cdk/aws-codecommit: Branches     : 57.78% ( 26/45 )
@aws-cdk/aws-codecommit: Functions    : 31.11% ( 14/45 )
@aws-cdk/aws-codecommit: Lines        : 57.02% ( 69/121 )
@aws-cdk/aws-codecommit: ================================================================================
@aws-cdk/aws-codecommit: Verifying integ.codecommit-events.js against integ.codecommit-events.expected.json ... OK.
@aws-cdk/aws-codecommit: Tests successful. Total time (42.1s) | /mnt/c/Users/Ken/cloud/dev/aws-cdk/aws-cdk/node_modules/nyc/bin/nyc.js (28.8s) | cdk-integ-assert (13.1s)
@aws-cdk/aws-codecommit: Done in 44.00s.
lerna success run Ran npm script 'test' in 1 package in 44.5s:
lerna success - @aws-cdk/aws-codecommit