# @aws-cdk/aws-codecommit

> The CDK Construct Library for AWS::CodeCommit

Latest version **1.204.0** (published 2023-06-19) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @aws-cdk/aws-codecommit
pnpm add @aws-cdk/aws-codecommit
yarn add @aws-cdk/aws-codecommit
bun add @aws-cdk/aws-codecommit
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.204.0 |
| Published | 2023-06-19 |
| First published | 2018-07-31 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14.15.0 |
| Dependencies | 6 |
| Unpacked size | 407.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12907 |
| Author | Amazon Web Services |
| Maintainers | romainmuller, amzn-oss, rix0rrr, aws-cdk-team |
| Keywords | aws, cdk, constructs, codecommit |

## Links

- npm: https://www.npmjs.com/package/@aws-cdk/aws-codecommit
- Repository: https://github.com/aws/aws-cdk
- Issues: https://github.com/aws/aws-cdk/issues
- npm.io page: https://npm.io/package/@aws-cdk/aws-codecommit

## Dependencies (6)

- [constructs](https://npm.io/package/constructs.md) ^3.3.69
- [@aws-cdk/core](https://npm.io/package/@aws-cdk/core.md) 1.204.0
- [@aws-cdk/aws-iam](https://npm.io/package/@aws-cdk/aws-iam.md) 1.204.0
- [@aws-cdk/aws-events](https://npm.io/package/@aws-cdk/aws-events.md) 1.204.0
- [@aws-cdk/aws-s3-assets](https://npm.io/package/@aws-cdk/aws-s3-assets.md) 1.204.0
- [@aws-cdk/aws-codestarnotifications](https://npm.io/package/@aws-cdk/aws-codestarnotifications.md) 1.204.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.204.0 (latest) — 2023-06-19
- 1.203.0 — 2023-05-31
- 1.202.0 — 2023-05-22
- 1.201.0 — 2023-05-10
- 1.200.0 — 2023-04-26
- 1.199.0 — 2023-04-20
- 1.198.1 — 2023-03-31
- 1.198.0 — 2023-03-22
- 1.197.0 — 2023-03-14
- 1.196.0 — 2023-03-08
- 1.195.0 — 2023-03-02
- 1.194.0 — 2023-02-21
- 1.193.0 — 2023-02-15
- 1.192.0 — 2023-02-09
- 1.191.0 — 2023-01-31
- … 273 more at https://npm.io/package/@aws-cdk/aws-codecommit/versions

## README

# AWS CodeCommit Construct Library
<!--BEGIN STABILITY BANNER-->

---

![End-of-Support](https://img.shields.io/badge/End--of--Support-critical.svg?style=for-the-badge)

> AWS CDK v1 has reached End-of-Support on 2023-06-01.
> This package is no longer being updated, and users should migrate to AWS CDK v2.
>
> For more information on how to migrate, see the [_Migrating to AWS CDK v2_ guide][doc].
>
> [doc]: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html

---

<!--END STABILITY BANNER-->

AWS CodeCommit is a version control service that enables you to privately store and manage Git repositories in the AWS cloud.

For further information on CodeCommit,
see the [AWS CodeCommit documentation](https://docs.aws.amazon.com/codecommit).

To add a CodeCommit Repository to your stack:

```ts
const repo = new codecommit.Repository(this, 'Repository', {
  repositoryName: 'MyRepositoryName',
  description: 'Some description.', // optional property
});
```

Use the `repositoryCloneUrlHttp`, `repositoryCloneUrlSsh` or `repositoryCloneUrlGrc`
property to clone your repository.

To add an Amazon SNS trigger to your repository:

```ts
declare const repo: codecommit.Repository;

// trigger is established for all repository actions on all branches by default.
repo.notify('arn:aws:sns:*:123456789012:my_topic');
```

## Add initial commit

It is possible to initialize the Repository via the `Code` class.
It provides methods for loading code from a directory, `.zip` file and from a pre-created CDK Asset.

Example:

```ts
const repo = new codecommit.Repository(this, 'Repository', {
  repositoryName: 'MyRepositoryName',
  code: codecommit.Code.fromDirectory(path.join(__dirname, 'directory/'), 'develop'), // optional property, branch parameter can be omitted
});
```

## Events

CodeCommit repositories emit Amazon CloudWatch events for certain activities.
Use the `repo.onXxx` methods to define rules that trigger on these events
and invoke targets as a result:

```ts
import * as sns from '@aws-cdk/aws-sns';
import * as targets from '@aws-cdk/aws-events-targets';

declare const repo: codecommit.Repository;
declare const project: codebuild.PipelineProject;
declare const myTopic: sns.Topic;

// starts a CodeBuild project when a commit is pushed to the "master" branch of the repo
repo.onCommit('CommitToMaster', {
  target: new targets.CodeBuildProject(project),
  branches: ['master'],
});

// publishes a message to an Amazon SNS topic when a comment is made on a pull request
const rule = repo.onCommentOnPullRequest('CommentOnPullRequest', {
  target: new targets.SnsTopic(myTopic),
});
```

## CodeStar Notifications

To define CodeStar Notification rules for Repositories, use one of the `notifyOnXxx()` methods.
They are very similar to `onXxx()` methods for CloudWatch events:

```ts
import * as chatbot from '@aws-cdk/aws-chatbot';

declare const repository: codecommit.Repository;
const target = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', {
  slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
  slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
  slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
});
const rule = repository.notifyOnPullRequestCreated('NotifyOnPullRequestCreated', target);
```

---
_Source: https://npm.io/package/@aws-cdk/aws-codecommit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
