aws-cdk-lib.aws_codecommit.Repository

class Repository (construct)

LanguageType name
.NETAmazon.CDK.AWS.CodeCommit.Repository
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodecommit#Repository
Javasoftware.amazon.awscdk.services.codecommit.Repository
Pythonaws_cdk.aws_codecommit.Repository
TypeScript (source)aws-cdk-lib » aws_codecommit » Repository

Implements IConstruct, IDependable, IResource, IRepository, INotificationRuleSource

Provides a CodeCommit Repository.

Example

declare const project: codebuild.PipelineProject;
const repository = new codecommit.Repository(this, 'MyRepository', {
  repositoryName: 'MyRepository',
});
const project = new codebuild.PipelineProject(this, 'MyProject');

const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.CodeCommitSourceAction({
  actionName: 'CodeCommit',
  repository,
  output: sourceOutput,
});
const buildAction = new codepipeline_actions.CodeBuildAction({
  actionName: 'CodeBuild',
  project,
  input: sourceOutput,
  outputs: [new codepipeline.Artifact()], // optional
  executeBatchBuild: true, // optional, defaults to false
  combineBatchBuildArtifacts: true, // optional, defaults to false
});

new codepipeline.Pipeline(this, 'MyPipeline', {
  stages: [
    {
      stageName: 'Source',
      actions: [sourceAction],
    },
    {
      stageName: 'Build',
      actions: [buildAction],
    },
  ],
});

Initializer

new Repository(scope: Construct, id: string, props: RepositoryProps)

Parameters

  • scope Construct
  • id string
  • props RepositoryProps

Construct Props

NameTypeDescription
repositoryNamestringName of the repository.
code?CodeThe contents with which to initialize the repository after it has been created.
description?stringA description of the repository.

repositoryName

Type: string

Name of the repository.

This property is required for all CodeCommit repositories.


code?

Type: Code (optional, default: No initialization (create empty repo))

The contents with which to initialize the repository after it has been created.


description?

Type: string (optional, default: No description.)

A description of the repository.

Use the description to identify the purpose of the repository.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
repositoryArnstringThe ARN of this Repository.
repositoryCloneUrlGrcstringThe HTTPS (GRC) clone URL.
repositoryCloneUrlHttpstringThe HTTP clone URL.
repositoryCloneUrlSshstringThe SSH clone URL.
repositoryNamestringThe human-visible name of this Repository.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


repositoryArn

Type: string

The ARN of this Repository.


repositoryCloneUrlGrc

Type: string

The HTTPS (GRC) clone URL.

HTTPS (GRC) is the protocol to use with git-remote-codecommit (GRC).

It is the recommended method for supporting connections made with federated access, identity providers, and temporary credentials.


repositoryCloneUrlHttp

Type: string

The HTTP clone URL.


repositoryCloneUrlSsh

Type: string

The SSH clone URL.


repositoryName

Type: string

The human-visible name of this Repository.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
bindAsNotificationRuleSource(_scope)Returns a source configuration for notification rule.
grant(grantee, ...actions)Grant the given principal identity permissions to perform the actions on this repository.
grantPull(grantee)Grant the given identity permissions to pull this repository.
grantPullPush(grantee)Grant the given identity permissions to pull and push this repository.
grantRead(grantee)Grant the given identity permissions to read this repository.
notifiyOnPullRequestMerged(id, target, options?)Defines a CodeStar Notification rule which triggers when a pull request is merged.
notify(arn, options?)Create a trigger to notify another service to run actions on repository events.
notifyOn(id, target, options)Defines a CodeStar Notification rule triggered when the project events specified by you are emitted. Similar to onEvent API.
notifyOnApprovalRuleOverridden(id, target, options?)Defines a CodeStar Notification rule which triggers when an approval rule is overridden.
notifyOnApprovalStatusChanged(id, target, options?)Defines a CodeStar Notification rule which triggers when an approval status is changed.
notifyOnBranchOrTagCreated(id, target, options?)Defines a CodeStar Notification rule which triggers when a new branch or tag is created.
notifyOnBranchOrTagDeleted(id, target, options?)Defines a CodeStar Notification rule which triggers when a branch or tag is deleted.
notifyOnPullRequestComment(id, target, options?)Defines a CodeStar Notification rule which triggers when a comment is made on a pull request.
notifyOnPullRequestCreated(id, target, options?)Defines a CodeStar Notification rule which triggers when a pull request is created.
notifyOnPullRequestMerged(id, target, options?)Defines a CodeStar Notification rule which triggers when a pull request is merged.
onCommentOnCommit(id, options?)Defines a CloudWatch event rule which triggers when a comment is made on a commit.
onCommentOnPullRequest(id, options?)Defines a CloudWatch event rule which triggers when a comment is made on a pull request.
onCommit(id, options?)Defines a CloudWatch event rule which triggers when a commit is pushed to a branch.
onEvent(id, options?)Defines a CloudWatch event rule which triggers for repository events.
onPullRequestStateChange(id, options?)Defines a CloudWatch event rule which triggers when a pull request state is changed.
onReferenceCreated(id, options?)Defines a CloudWatch event rule which triggers when a reference is created (i.e. a new branch/tag is created) to the repository.
onReferenceDeleted(id, options?)Defines a CloudWatch event rule which triggers when a reference is delete (i.e. a branch/tag is deleted) from the repository.
onReferenceUpdated(id, options?)Defines a CloudWatch event rule which triggers when a reference is updated (i.e. a commit is pushed to an existing or new branch) from the repository.
onStateChange(id, options?)Defines a CloudWatch event rule which triggers when a "CodeCommit Repository State Change" event occurs.
toString()Returns a string representation of this construct.
static fromRepositoryArn(scope, id, repositoryArn)Imports a codecommit repository.
static fromRepositoryName(scope, id, repositoryName)

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


bindAsNotificationRuleSource(_scope)

public bindAsNotificationRuleSource(_scope: Construct): NotificationRuleSourceConfig

Parameters

  • _scope Construct

Returns

  • NotificationRuleSourceConfig

Returns a source configuration for notification rule.


grant(grantee, ...actions)

public grant(grantee: IGrantable, ...actions: string[]): Grant

Parameters

  • grantee IGrantable
  • actions string

Returns

  • Grant

Grant the given principal identity permissions to perform the actions on this repository.


grantPull(grantee)

public grantPull(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

Grant the given identity permissions to pull this repository.


grantPullPush(grantee)

public grantPullPush(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

Grant the given identity permissions to pull and push this repository.


grantRead(grantee)

public grantRead(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

Grant the given identity permissions to read this repository.


notifiyOnPullRequestMerged(id, target, options?)

public notifiyOnPullRequestMerged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a pull request is merged.


notify(arn, options?)

public notify(arn: string, options?: RepositoryTriggerOptions): Repository

Parameters

  • arn string — Arn of the resource that repository events will notify.
  • options RepositoryTriggerOptions — Trigger options to run actions.

Returns

  • Repository

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


notifyOn(id, target, options)

public notifyOn(id: string, target: INotificationRuleTarget, options: RepositoryNotifyOnOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options RepositoryNotifyOnOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule triggered when the project events specified by you are emitted. Similar to onEvent API.

You can also use the methods to define rules for the specific event emitted. eg: notifyOnPullRequstCreated.


notifyOnApprovalRuleOverridden(id, target, options?)

public notifyOnApprovalRuleOverridden(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when an approval rule is overridden.


notifyOnApprovalStatusChanged(id, target, options?)

public notifyOnApprovalStatusChanged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when an approval status is changed.


notifyOnBranchOrTagCreated(id, target, options?)

public notifyOnBranchOrTagCreated(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a new branch or tag is created.


notifyOnBranchOrTagDeleted(id, target, options?)

public notifyOnBranchOrTagDeleted(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a branch or tag is deleted.


notifyOnPullRequestComment(id, target, options?)

public notifyOnPullRequestComment(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a comment is made on a pull request.


notifyOnPullRequestCreated(id, target, options?)

public notifyOnPullRequestCreated(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a pull request is created.


notifyOnPullRequestMerged(id, target, options?)

public notifyOnPullRequestMerged(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar Notification rule which triggers when a pull request is merged.


onCommentOnCommit(id, options?)

public onCommentOnCommit(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onCommentOnPullRequest(id, options?)

public onCommentOnPullRequest(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onCommit(id, options?)

public onCommit(id: string, options?: OnCommitOptions): Rule

Parameters

  • id string
  • options OnCommitOptions

Returns

  • Rule

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


onEvent(id, options?)

public onEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule which triggers for repository events.

Use rule.addEventPattern(pattern) to specify a filter.


onPullRequestStateChange(id, options?)

public onPullRequestStateChange(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onReferenceCreated(id, options?)

public onReferenceCreated(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onReferenceDeleted(id, options?)

public onReferenceDeleted(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onReferenceUpdated(id, options?)

public onReferenceUpdated(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


onStateChange(id, options?)

public onStateChange(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

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


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromRepositoryArn(scope, id, repositoryArn)

public static fromRepositoryArn(scope: Construct, id: string, repositoryArn: string): IRepository

Parameters

  • scope Construct
  • id string
  • repositoryArn string — (e.g. arn:aws:codecommit:us-east-1:123456789012:MyDemoRepo).

Returns

  • IRepository

Imports a codecommit repository.


static fromRepositoryName(scope, id, repositoryName)

public static fromRepositoryName(scope: Construct, id: string, repositoryName: string): IRepository

Parameters

  • scope Construct
  • id string
  • repositoryName string

Returns

  • IRepository