-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(@aws-cdk/aws-codestarnotifications): CodeCommit repository not supported as source for Notification Rule #15653
Comments
Thanks for opening the issue @badfun! We encourage community contributions, so if you'd be interested in submitting us a Pull Request adding this functionality, here's our "Contributing guide": https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md. |
Also tagging @luckily for visibility, as he's the author of this functionality in the CDK. |
In the meantime, to unblock yourself, you should be able to write a class that implements the import * as notifications from '@aws-cdk/aws-codestarnotifications';
import * as codecommit from '@aws-cdk/aws-codecommit';
export class CodeCommitNotification implements notifications.INotificationRuleSource {
constructor(private readonly repository: codecommit.IRepository) {
}
public bindAsNotificationRuleSource(_scope: Construct): notifications.NotificationRuleSourceConfig {
return {
sourceArn: this.repository.repositoryArn,
};
}
} |
Hi @badfun, can you try something like this? import * as cdk from '@aws-cdk/core';
import * as codecommit from '@aws-cdk/aws-codecommit';
import * as notifications from '@aws-cdk/aws-codestarnotifications';
import * as sns from '@aws-cdk/aws-sns';
import * as subs from '@aws-cdk/aws-sns-subscriptions';
const repo = new codecommit.Repository(this, 'MyRepo', {
repositoryName: 'MyTestRepo',
description: 'For CDK testing',
});
const topic = new sns.Topic(this, 'MySns', {
topicName: 'NotifyFromCodecommit',
});
topic.addSubscription(new subs.EmailSubscription('my@email.address'));
const notification = new notifications.NotificationRule(this, 'MyNotificaitonRule', {
source: {
bindAsNotificationRuleSource: () => {
return { sourceArn: repo.repositoryArn };
},
},
events: [
'codecommit-repository-pull-request-created',
],
});
notification.addTarget(topic); You can also use This is a quick workaround. It works. I would like to know If you want to contribute for this, I will be happy to give you suggestions and assist in the review. 🙂 If you don't want to contribute, I may try to contribute in a few days, but I'm not sure. |
I will wait for your contribution @badfun! 😄 |
What were the problems with Gitpod @badfun? |
I couldn't figure out how to do the pull request from it. I think it may have been browser issues, but not sure. It seemed to hang when trying to authorize, etc. |
Hmm, weird... It always worked very smoothly for me. Sorry for the troubles! |
that sounds like a commitment! ;-) |
Sorry fellas, I tried. I could not get an environment to work for me. Gitpod has some kind of access issues with my Github account and I could not push to my repo from the Workspace. I tried the local build, as per the instructions here: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md, but it failed on the '../../../scripts/buildup' step. I tried resuming, restarting, etc. but I always ended up with this error:
I'm guessing it is something to do with packages not being correct versions or whatnot. I have done a bunch of work which I think should be correct, you can access it in this branch of my fork: Too frustrated to carry on right now. ps @luckily your code above worked fine and that is what I am using for now. |
@badfun Sorry, I didn't expect that you might use Windows environment, but I think you can solve this problem with Docker, and you should mount CDK source of local directory into Docker to execute some commands, and always execute scripts via Docker. Gitpod is a good choice if you don't have suitable development environment. |
@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#15739) ---- Fixes aws#15653 Notification rule can be created for CodeCommit Repository events using @aws-cdk/aws-codestarnotifications *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…aws#15739) ---- Fixes aws#15653 Notification rule can be created for CodeCommit Repository events using @aws-cdk/aws-codestarnotifications *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…aws#15739) ---- Fixes aws#15653 Notification rule can be created for CodeCommit Repository events using @aws-cdk/aws-codestarnotifications *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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
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:The text was updated successfully, but these errors were encountered: