

This is the new *CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::CodeCommit::Repository
<a name="aws-resource-codecommit-repository"></a>

Creates a new, empty repository.

**Important**  
AWS CodeCommit is no longer available to new customers. Existing customers of AWS CodeCommit can continue to use the service as normal. [Learn more"](https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider)

## Syntax
<a name="aws-resource-codecommit-repository-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-codecommit-repository-syntax.json"></a>

```
{
  "Type" : "AWS::CodeCommit::Repository",
  "Properties" : {
      "[Code](#cfn-codecommit-repository-code)" : Code,
      "[KmsKeyId](#cfn-codecommit-repository-kmskeyid)" : String,
      "[RepositoryDescription](#cfn-codecommit-repository-repositorydescription)" : String,
      "[RepositoryName](#cfn-codecommit-repository-repositoryname)" : String,
      "[Tags](#cfn-codecommit-repository-tags)" : [ Tag, ... ],
      "[Triggers](#cfn-codecommit-repository-triggers)" : [ RepositoryTrigger, ... ]
    }
}
```

### YAML
<a name="aws-resource-codecommit-repository-syntax.yaml"></a>

```
Type: AWS::CodeCommit::Repository
Properties:
  [Code](#cfn-codecommit-repository-code): 
    Code
  [KmsKeyId](#cfn-codecommit-repository-kmskeyid): String
  [RepositoryDescription](#cfn-codecommit-repository-repositorydescription): String
  [RepositoryName](#cfn-codecommit-repository-repositoryname): String
  [Tags](#cfn-codecommit-repository-tags): 
    - Tag
  [Triggers](#cfn-codecommit-repository-triggers): 
    - RepositoryTrigger
```

## Properties
<a name="aws-resource-codecommit-repository-properties"></a>

`Code`  <a name="cfn-codecommit-repository-code"></a>
Information about code to be committed to a repository after it is created in an AWS CloudFormation stack. Information about code is only used in resource creation. Updates to a stack will not reflect changes made to code properties after initial resource creation.   
You can only use this property to add code when creating a repository with a CloudFormation template at creation time. This property cannot be used for updating code to an existing repository.
*Required*: No  
*Type*: [Code](aws-properties-codecommit-repository-code.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`KmsKeyId`  <a name="cfn-codecommit-repository-kmskeyid"></a>
The ID of the AWS Key Management Service encryption key used to encrypt and decrypt the repository.  
The input can be the full ARN, the key ID, or the key alias. For more information, see [Finding the key ID and key ARN](https://docs.aws.amazon.com/kms/latest/developerguide/find-cmk-id-arn.html).
*Required*: No  
*Type*: String  
*Pattern*: `^[a-zA-Z0-9:/_-]+$`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`RepositoryDescription`  <a name="cfn-codecommit-repository-repositorydescription"></a>
A comment or description about the new repository.  
The description field for a repository accepts all HTML characters and all valid Unicode characters. Applications that do not HTML-encode the description and display it in a webpage can expose users to potentially malicious code. Make sure that you HTML-encode the description field in any application that uses this API to display the repository description on a webpage.
*Required*: No  
*Type*: String  
*Maximum*: `1000`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`RepositoryName`  <a name="cfn-codecommit-repository-repositoryname"></a>
The name of the new repository to be created.  
The repository name must be unique across the calling AWS account. Repository names are limited to 100 alphanumeric, dash, and underscore characters, and cannot include certain characters. For more information about the limits on repository names, see [Quotas](https://docs.aws.amazon.com/codecommit/latest/userguide/limits.html) in the *AWS CodeCommit User Guide*. The suffix .git is prohibited.
*Required*: Yes  
*Type*: String  
*Pattern*: `[\w\.-]+`  
*Minimum*: `1`  
*Maximum*: `100`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Tags`  <a name="cfn-codecommit-repository-tags"></a>
One or more tag key-value pairs to use when tagging this repository.  
*Required*: No  
*Type*: Array of [Tag](aws-properties-codecommit-repository-tag.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Triggers`  <a name="cfn-codecommit-repository-triggers"></a>
The JSON block of configuration information for each trigger.  
*Required*: No  
*Type*: Array of [RepositoryTrigger](aws-properties-codecommit-repository-repositorytrigger.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return values
<a name="aws-resource-codecommit-repository-return-values"></a>

### Ref
<a name="aws-resource-codecommit-repository-return-values-ref"></a>

When the logical ID of this resource is provided to the Ref intrinsic function, `Ref` returns the repository ID. 

For more information about using the `Ref` function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html).

### Fn::GetAtt
<a name="aws-resource-codecommit-repository-return-values-fn--getatt"></a>

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html).

#### 
<a name="aws-resource-codecommit-repository-return-values-fn--getatt-fn--getatt"></a>

`Arn`  <a name="Arn-fn::getatt"></a>
When you pass the logical ID of this resource, the function returns the Amazon Resource Name (ARN) of the repository.

`CloneUrlHttp`  <a name="CloneUrlHttp-fn::getatt"></a>
When you pass the logical ID of this resource, the function returns the URL to use for cloning the repository over HTTPS.

`CloneUrlSsh`  <a name="CloneUrlSsh-fn::getatt"></a>
When you pass the logical ID of this resource, the function returns the URL to use for cloning the repository over SSH.

`Name`  <a name="Name-fn::getatt"></a>
When you pass the logical ID of this resource, the function returns the repository's name.

## Examples
<a name="aws-resource-codecommit-repository--examples"></a>

The following examples can help you create CodeCommit repositories using CloudFormation.

**Topics**
+ [Example](#aws-resource-codecommit-repository--examples--Example)
+ [Example](#aws-resource-codecommit-repository--examples--Example)

### Example
<a name="aws-resource-codecommit-repository--examples--Example"></a>

The following example creates a CodeCommit repository named *MyDemoRepo*. The newly created repository is populated with code stored in an Amazon S3 bucket named *MySourceCodeBucket* and placed in a branch named *development*, which is the default branch for the repository. 

#### JSON
<a name="aws-resource-codecommit-repository--examples--Example--json"></a>

```
{
    "MyRepo": {
        "Type": "AWS::CodeCommit::Repository",
        "Properties": {
            "RepositoryName": "MyDemoRepo",
            "RepositoryDescription": "This is a repository for my project with code from MySourceCodeBucket.",
            "Code": {
                "BranchName": "development",
                "S3": {
                    "Bucket": "MySourceCodeBucket",
                    "Key": "MyKey",
                    "ObjectVersion": "1"
                }
            }
        }
    }
}
```

#### YAML
<a name="aws-resource-codecommit-repository--examples--Example--yaml"></a>

```
MyRepo:
  Type: AWS::CodeCommit::Repository
  Properties:
    RepositoryName: MyDemoRepo
    RepositoryDescription: This is a repository for my project with code from MySourceCodeBucket.
    Code:
      BranchName: development
      S3: 
        Bucket: MySourceCodeBucket
        Key: MyKey
        ObjectVersion: 1
```

### Example
<a name="aws-resource-codecommit-repository--examples--Example"></a>

The following example creates a CodeCommit repository with a trigger for all events in the *development* branch. 

#### JSON
<a name="aws-resource-codecommit-repository--examples--Example--json"></a>

```
{
    "MyRepo": {
        "Type": "AWS: : CodeCommit: : Repository",
        "Properties": {
            "RepositoryName": "MyRepoName",
            "RepositoryDescription": "a description",
            "Triggers": [
                {
                    "Name": "MyTrigger",
                    "CustomData": "Project ID 12345",
                    "DestinationArn": {
                        "Ref": "SNSarn"
                    },
                    "Branches": [
                        "development"
                    ],
                    "Events": [
                        "all"
                    ]
                }
            ]
        }
    }
}
```

#### YAML
<a name="aws-resource-codecommit-repository--examples--Example--yaml"></a>

```
MyRepo:
  Type: AWS::CodeCommit::Repository
  Properties:
    RepositoryName: MyRepoName
    RepositoryDescription: a description
    Triggers:
    - Name: MyTrigger
      CustomData: Project ID 12345
      DestinationArn:
        Ref: SNSarn
      Branches:
      - development
      Events:
      - all
```

# AWS::CodeCommit::Repository Code
<a name="aws-properties-codecommit-repository-code"></a>

Information about code to be committed.

## Syntax
<a name="aws-properties-codecommit-repository-code-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-codecommit-repository-code-syntax.json"></a>

```
{
  "[BranchName](#cfn-codecommit-repository-code-branchname)" : String,
  "[S3](#cfn-codecommit-repository-code-s3)" : S3
}
```

### YAML
<a name="aws-properties-codecommit-repository-code-syntax.yaml"></a>

```
  [BranchName](#cfn-codecommit-repository-code-branchname): String
  [S3](#cfn-codecommit-repository-code-s3): 
    S3
```

## Properties
<a name="aws-properties-codecommit-repository-code-properties"></a>

`BranchName`  <a name="cfn-codecommit-repository-code-branchname"></a>
Optional. Specifies a branch name to be used as the default branch when importing code into a repository on initial creation. If this property is not set, the name *main* will be used for the default branch for the repository. Changes to this property are ignored after initial resource creation. We recommend using this parameter to set the name to *main* to align with the default behavior of CodeCommit unless another name is needed.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`S3`  <a name="cfn-codecommit-repository-code-s3"></a>
Information about the Amazon S3 bucket that contains a ZIP file of code to be committed to the repository. Changes to this property are ignored after initial resource creation.  
*Required*: Yes  
*Type*: [S3](aws-properties-codecommit-repository-s3.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

# AWS::CodeCommit::Repository RepositoryTrigger
<a name="aws-properties-codecommit-repository-repositorytrigger"></a>

Information about a trigger for a repository. 

**Note**  
If you want to receive notifications about repository events, consider using notifications instead of triggers. For more information, see [Configuring notifications for repository events](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-repository-email.html).

## Syntax
<a name="aws-properties-codecommit-repository-repositorytrigger-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-codecommit-repository-repositorytrigger-syntax.json"></a>

```
{
  "[Branches](#cfn-codecommit-repository-repositorytrigger-branches)" : [ String, ... ],
  "[CustomData](#cfn-codecommit-repository-repositorytrigger-customdata)" : String,
  "[DestinationArn](#cfn-codecommit-repository-repositorytrigger-destinationarn)" : String,
  "[Events](#cfn-codecommit-repository-repositorytrigger-events)" : [ String, ... ],
  "[Name](#cfn-codecommit-repository-repositorytrigger-name)" : String
}
```

### YAML
<a name="aws-properties-codecommit-repository-repositorytrigger-syntax.yaml"></a>

```
  [Branches](#cfn-codecommit-repository-repositorytrigger-branches): 
    - String
  [CustomData](#cfn-codecommit-repository-repositorytrigger-customdata): String
  [DestinationArn](#cfn-codecommit-repository-repositorytrigger-destinationarn): String
  [Events](#cfn-codecommit-repository-repositorytrigger-events): 
    - String
  [Name](#cfn-codecommit-repository-repositorytrigger-name): String
```

## Properties
<a name="aws-properties-codecommit-repository-repositorytrigger-properties"></a>

`Branches`  <a name="cfn-codecommit-repository-repositorytrigger-branches"></a>
The branches to be included in the trigger configuration. If you specify an empty array, the trigger applies to all branches.  
Although no content is required in the array, you must include the array itself.
*Required*: No  
*Type*: Array of String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`CustomData`  <a name="cfn-codecommit-repository-repositorytrigger-customdata"></a>
Any custom data associated with the trigger to be included in the information sent to the target of the trigger.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`DestinationArn`  <a name="cfn-codecommit-repository-repositorytrigger-destinationarn"></a>
The ARN of the resource that is the target for a trigger (for example, the ARN of a topic in Amazon SNS).  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Events`  <a name="cfn-codecommit-repository-repositorytrigger-events"></a>
The repository events that cause the trigger to run actions in another service, such as sending a notification through Amazon SNS.   
The valid value "all" cannot be used with any other values.
*Required*: Yes  
*Type*: Array of String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Name`  <a name="cfn-codecommit-repository-repositorytrigger-name"></a>
The name of the trigger.  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

# AWS::CodeCommit::Repository S3
<a name="aws-properties-codecommit-repository-s3"></a>

Information about the Amazon S3 bucket that contains the code that will be committed to the new repository. Changes to this property are ignored after initial resource creation.

## Syntax
<a name="aws-properties-codecommit-repository-s3-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-codecommit-repository-s3-syntax.json"></a>

```
{
  "[Bucket](#cfn-codecommit-repository-s3-bucket)" : String,
  "[Key](#cfn-codecommit-repository-s3-key)" : String,
  "[ObjectVersion](#cfn-codecommit-repository-s3-objectversion)" : String
}
```

### YAML
<a name="aws-properties-codecommit-repository-s3-syntax.yaml"></a>

```
  [Bucket](#cfn-codecommit-repository-s3-bucket): String
  [Key](#cfn-codecommit-repository-s3-key): String
  [ObjectVersion](#cfn-codecommit-repository-s3-objectversion): String
```

## Properties
<a name="aws-properties-codecommit-repository-s3-properties"></a>

`Bucket`  <a name="cfn-codecommit-repository-s3-bucket"></a>
The name of the Amazon S3 bucket that contains the ZIP file with the content that will be committed to the new repository. This can be specified using the name of the bucket in the AWS account. Changes to this property are ignored after initial resource creation.  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Key`  <a name="cfn-codecommit-repository-s3-key"></a>
The key to use for accessing the Amazon S3 bucket. Changes to this property are ignored after initial resource creation. For more information, see [Creating object key names](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html) and [Uploading objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html) in the Amazon S3 User Guide.  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`ObjectVersion`  <a name="cfn-codecommit-repository-s3-objectversion"></a>
The object version of the ZIP file, if versioning is enabled for the Amazon S3 bucket. Changes to this property are ignored after initial resource creation.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

# AWS::CodeCommit::Repository Tag
<a name="aws-properties-codecommit-repository-tag"></a>

A tag is a key-value pair that is used to manage the resource.

## Syntax
<a name="aws-properties-codecommit-repository-tag-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-codecommit-repository-tag-syntax.json"></a>

```
{
  "[Key](#cfn-codecommit-repository-tag-key)" : String,
  "[Value](#cfn-codecommit-repository-tag-value)" : String
}
```

### YAML
<a name="aws-properties-codecommit-repository-tag-syntax.yaml"></a>

```
  [Key](#cfn-codecommit-repository-tag-key): String
  [Value](#cfn-codecommit-repository-tag-value): String
```

## Properties
<a name="aws-properties-codecommit-repository-tag-properties"></a>

`Key`  <a name="cfn-codecommit-repository-tag-key"></a>
The tag's key.  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Value`  <a name="cfn-codecommit-repository-tag-value"></a>
The tag's value.  
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)