@aws-cdk/codecommit

AWS CodeCommit Construct Library

To add a CodeCommit Repository to your stack:

import { Repository } from '@aws-cdk/codecommit';

const repository = new Repository(stack, 'Repository' ,{
    repositoryName: 'MyRepositoryName'
});

To add an SNS trigger to your repository:

import { Repository } from '@aws-cdk/codecommit';

const repository = new Repository(stack, 'Repository', {
    repositoryName: 'MyRepositoryName'
});

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

Events

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

// starts a CodeBuild project when a commit is pushed to the "master" branch of the repo
repo.onCommit('CommitToMaster', buildProject, 'master');

// publishes a message to an SNS topic when a comment is made on a pull request
const rule = repo.onCommentOnPullRequest('CommentOnPullRequest');
rule.addTarget(myTopic);

Reference

Repository

class _aws-cdk_codecommit.Repository(parent, name, props)

Provides a CodeCommit Repository

Extends:

RepositoryRef

Parameters:
  • parent (Construct) –
  • name (string) –
  • props (RepositoryProps) –
notify(arn[, options]) → @aws-cdk/codecommit.Repository

Create a trigger to notify another service to run actions on repository events.

Parameters:
  • arn (string) – Arn of the resource that repository events will notify
  • options (RepositoryTriggerOptions or None) – Trigger options to run actions
Return type:

Repository

repositoryArn

The ARN of this Repository.

Type:RepositoryArn (readonly)
repositoryCloneUrlHttp
Type:RepositoryCloneUrlHttp (readonly)
repositoryCloneUrlSsh
Type:RepositoryCloneUrlSsh (readonly)
repositoryName

The human-visible name of this Repository.

Type:RepositoryName (readonly)

RepositoryEventTrigger (enum)

class _aws-cdk_codecommit.RepositoryEventTrigger
All
UpdateRef
CreateRef
DeleteRef

RepositoryProps (interface)

class _aws-cdk_codecommit.RepositoryProps
repositoryName

Name of the repository. This property is required for all repositories.

Type:string
description

A description of the repository. Use the description to identify the purpose of the repository.

Type:string or None

RepositoryRef

class _aws-cdk_codecommit.RepositoryRef(parent, name)

Represents a reference to a CodeCommit Repository. If you want to create a new Repository managed alongside your CDK code, use the {@link Repository} class. If you want to reference an already existing Repository, use the {@link RepositoryRef.import} method.

Extends:

Construct

Abstract:

Yes

Parameters:
  • parent (Construct) – The parent construct
  • name (string) –
static import(parent, name, props) → @aws-cdk/codecommit.RepositoryRef

Import a Repository defined either outside the CDK, or in a different Stack (exported with the {@link export} method).

Parameters:
  • parent (Construct) – the parent Construct for the Repository
  • name (string) – the name of the Repository Construct
  • props (RepositoryRefProps) – the properties used to identify the existing Repository
Returns:

a reference to the existing Repository

Return type:

RepositoryRef

export() → @aws-cdk/codecommit.RepositoryRefProps

Exports this Repository. Allows the same Repository to be used in 2 different Stacks.

Return type:RepositoryRefProps
onEvent(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers for repository events. Use rule.addEventPattern(pattern) to specify a filter.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onStateChange(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a “CodeCommit Repository State Change” event occurs.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onReferenceCreated(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a reference is created (i.e. a new brach/tag is created) to the repository.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onReferenceUpdated(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a reference is updated (i.e. a commit is pushed to an existig branch) from the repository.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onReferenceDeleted(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a reference is delete (i.e. a branch/tag is deleted) from the repository.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onPullRequestStateChange(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a pull request state is changed.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onCommentOnPullRequest(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a comment is made on a pull request.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onCommentOnCommit(name[, target[, options]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a comment is made on a commit.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) –
  • options (EventRuleProps or None) –
Return type:

EventRule

onCommit(name[, target[, branch]]) → @aws-cdk/events.EventRule

Defines a CloudWatch event rule which triggers when a commit is pushed to a branch.

Parameters:
  • name (string) –
  • target (IEventRuleTarget or None) – The target of the event
  • branch (string or None) – The branch to monitor. Defaults to all branches.
Return type:

EventRule

repositoryArn

The ARN of this Repository.

Type:RepositoryArn (readonly) (abstract)
repositoryName

The human-visible name of this Repository.

Type:RepositoryName (readonly) (abstract)

RepositoryRefProps (interface)

class _aws-cdk_codecommit.RepositoryRefProps

Properties for the {@link RepositoryRef.import} method.

repositoryName

The name of an existing CodeCommit Repository that we are referencing. Must be in the same account and region as the root Stack.

Type:RepositoryName

RepositoryTriggerOptions (interface)

class _aws-cdk_codecommit.RepositoryTriggerOptions

Creates for a repository trigger to an SNS topic or Lambda function.

name

A name for the trigger.Triggers on a repository must have unique names

Type:string or None
events

The repository events for which AWS CodeCommit sends information to the target, which you specified in the DestinationArn property.If you don’t specify events, the trigger runs for all repository events.

Type:RepositoryEventTrigger or None
branches

The names of the branches in the AWS CodeCommit repository that contain events that you want to include in the trigger. If you don’t specify at least one branch, the trigger applies to all branches.

Type:string or None
customData

When an event is triggered, additional information that AWS CodeCommit includes when it sends information to the target.

Type:string or None