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.59k stars 3.89k forks source link

aws-codecommit: IRepository does not allow 'notify' triggers #29105

Open SeriesOfUnlikelyExplanations opened 8 months ago

SeriesOfUnlikelyExplanations commented 8 months ago

Describe the bug

When I import a repository, I am unable to use the repo.notify event. It does work when I create a new repo.

This fails:

const repo = Repository.fromRepositoryName(this, 'repoName', repoName)

repo.notify(handler.functionArn, {
  branches: ['live'],
  events: [RepositoryEventTrigger.UPDATE_REF],
  name: 'push',
});

This works:

const repo = new Repository(this, repoName,{
  repositoryName: repoName,
});

repo.notify(handler.functionArn, {
  branches: ['live'],
  events: [RepositoryEventTrigger.UPDATE_REF],
  name: 'push',
});

Expected Behavior

I expect this to not produce an error:

const repo = Repository.fromRepositoryName(this, 'repoName', repoName)

repo.notify(handler.functionArn, {
  branches: ['live'],
  events: [RepositoryEventTrigger.UPDATE_REF],
  name: 'push',
});

Current Behavior

I get the following error:

Property 'notify' does not exist on type 'IRepository'. Did you mean 'notifyOn'?

Reproduction Steps

const repo = Repository.fromRepositoryName(this, 'repoName', repoName)

repo.notify(handler.functionArn, {
  branches: ['live'],
  events: [RepositoryEventTrigger.UPDATE_REF],
  name: 'push',
});

TSError: ⨯ Unable to compile TypeScript: codePipelineStack.ts:65:12 - error TS2551: Property 'notify' does not exist on type 'IRepository'. Did you mean 'notifyOn'?

65 repo.notify(handler.functionArn, {


  ../node_modules/aws-cdk-lib/aws-codecommit/lib/repository.d.ts:116:5
    116     notifyOn(id: string, target: notifications.INotificationRuleTarget, options: RepositoryNotifyOnOptions): notifications.INotificationRule;
'notifyOn' is declared here.

Possible Solution

Add the notify type to the IRepository class in addition to the Repository class.

Additional Information/Context

No response

CDK CLI Version

2.127.0

Framework Version

No response

Node.js Version

v20.10.0

OS

ubuntu

Language

TypeScript

Language Version

3.9.7

Other information

No response

pahud commented 8 months ago

Yes at this moment, notify is available only for class Repository, which represents a new one rather than an imported one(IRepository).

SeriesOfUnlikelyExplanations commented 8 months ago

Was that by design or is it a bug? If by design, why?

adamjkeller commented 1 day ago

We should close this issue as CodeCommit is no longer taking new customers and eventually will be deprecated. See here: https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/

@pahud