Repository

class aws_cdk.aws_codecommit.Repository(scope, id, *, repository_name, code=None, description=None)

Bases: Resource

Provides a CodeCommit Repository.

ExampleMetadata:

infused

Example:

# project: codebuild.PipelineProject

repository = codecommit.Repository(self, "MyRepository",
    repository_name="MyRepository"
)
project = codebuild.PipelineProject(self, "MyProject")

source_output = codepipeline.Artifact()
source_action = codepipeline_actions.CodeCommitSourceAction(
    action_name="CodeCommit",
    repository=repository,
    output=source_output
)
build_action = codepipeline_actions.CodeBuildAction(
    action_name="CodeBuild",
    project=project,
    input=source_output,
    outputs=[codepipeline.Artifact()],  # optional
    execute_batch_build=True,  # optional, defaults to false
    combine_batch_build_artifacts=True
)

codepipeline.Pipeline(self, "MyPipeline",
    stages=[codepipeline.StageProps(
        stage_name="Source",
        actions=[source_action]
    ), codepipeline.StageProps(
        stage_name="Build",
        actions=[build_action]
    )
    ]
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • repository_name (str) – Name of the repository. This property is required for all CodeCommit repositories.

  • code (Optional[Code]) – The contents with which to initialize the repository after it has been created. Default: - No initialization (create empty repo)

  • description (Optional[str]) – A description of the repository. Use the description to identify the purpose of the repository. Default: - No description.

Methods

apply_removal_policy(policy)

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).

Parameters:

policy (RemovalPolicy) –

Return type:

None

bind_as_notification_rule_source(_scope)

Returns a source configuration for notification rule.

Parameters:

_scope (Construct) –

Return type:

NotificationRuleSourceConfig

grant(grantee, *actions)

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

Parameters:
Return type:

Grant

grant_pull(grantee)

Grant the given identity permissions to pull this repository.

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_pull_push(grantee)

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

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_read(grantee)

Grant the given identity permissions to read this repository.

Parameters:

grantee (IGrantable) –

Return type:

Grant

notifiy_on_pull_request_merged(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify(arn, *, branches=None, custom_data=None, events=None, name=None)

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

Parameters:
  • arn (str) – Arn of the resource that repository events will notify.

  • branches (Optional[Sequence[str]]) – 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.

  • custom_data (Optional[str]) – When an event is triggered, additional information that AWS CodeCommit includes when it sends information to the target.

  • events (Optional[Sequence[RepositoryEventTrigger]]) – 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.

  • name (Optional[str]) – A name for the trigger.Triggers on a repository must have unique names.

Return type:

Repository

notify_on(id, target, *, events, detail_type=None, enabled=None, notification_rule_name=None)

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.

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • events (Sequence[RepositoryNotificationEvents]) – A list of event types associated with this notification rule for CodeCommit repositories. For a complete list of event types and IDs, see Notification concepts in the Developer Tools Console User Guide.

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_approval_rule_overridden(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_approval_status_changed(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_branch_or_tag_created(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_branch_or_tag_deleted(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_pull_request_comment(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_pull_request_created(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

notify_on_pull_request_merged(id, target, *, detail_type=None, enabled=None, notification_rule_name=None)

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

Parameters:
  • id (str) –

  • target (INotificationRuleTarget) –

  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

Return type:

INotificationRule

on_comment_on_commit(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_comment_on_pull_request(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_commit(id, *, branches=None, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • branches (Optional[Sequence[str]]) – The branch to monitor. Default: - All branches

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_event(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

Defines a CloudWatch event rule which triggers for repository events.

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_pull_request_state_change(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_reference_created(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_reference_deleted(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_reference_updated(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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.

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

on_state_change(id, *, target=None, cross_stack_scope=None, description=None, event_pattern=None, rule_name=None)

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

Parameters:
  • id (str) –

  • target (Optional[IRuleTarget]) – The target to register for the event. Default: - No target is added to the rule. Use addTarget() to add a target.

  • cross_stack_scope (Optional[Construct]) – The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)

  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Additional restrictions for the event to route to the specified target. The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering. Default: - No additional filtering based on an event pattern.

  • rule_name (Optional[str]) – A name for the rule. Default: AWS CloudFormation generates a unique physical ID.

Return type:

Rule

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

env

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

The tree node.

repository_arn

The ARN of this Repository.

repository_clone_url_grc

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.

repository_clone_url_http

The HTTP clone URL.

repository_clone_url_ssh

The SSH clone URL.

repository_name

The human-visible name of this Repository.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_repository_arn(scope, id, repository_arn)

Imports a codecommit repository.

Parameters:
  • scope (Construct) –

  • id (str) –

  • repository_arn (str) – (e.g. arn:aws:codecommit:us-east-1:123456789012:MyDemoRepo).

Return type:

IRepository

classmethod from_repository_name(scope, id, repository_name)
Parameters:
  • scope (Construct) –

  • id (str) –

  • repository_name (str) –

Return type:

IRepository

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool