AWS::CodeCommit::Repository
Creates a new, empty repository.
Syntax
To declare this entity in your Amazon CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::CodeCommit::Repository", "Properties" : { "Code" :Code, "RepositoryDescription" :String, "RepositoryName" :String, "Tags" :[ Tag, ... ], "Triggers" :[ RepositoryTrigger, ... ]} }
YAML
Type: AWS::CodeCommit::Repository Properties: Code:CodeRepositoryDescription:StringRepositoryName:StringTags:- TagTriggers:- RepositoryTrigger
Properties
CodeInformation about code to be committed to a repository after it is created in an Amazon 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.
Note
You can only use this property to add code when creating a repository with a Amazon CloudFormation template at creation time. This property cannot be used for updating code to an existing repository.
Required: No
Type: Code
Update requires: No interruption
RepositoryDescription-
A comment or description about the new repository.
Note
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:
1000Update requires: No interruption
RepositoryName-
The name of the new repository to be created.
Note
The repository name must be unique across the calling Amazon Web Services 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 in the Amazon CodeCommit User Guide. The suffix .git is prohibited.
Required: Yes
Type: String
Minimum:
1Maximum:
100Pattern:
[\w\.-]+Update requires: No interruption
Tags-
One or more tag key-value pairs to use when tagging this repository.
Required: No
Type: List of Tag
Update requires: No interruption
Triggers-
The JSON block of configuration information for each trigger.
Required: No
Type: List of RepositoryTrigger
Update requires: Some interruptions
Return values
Ref
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 Reffunction, see Ref.
Fn::GetAtt
The Fn::GetAttintrinsic 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::GetAttintrinsic function, see Fn::GetAtt.
Arn-
When you pass the logical ID of this resource, the function returns the Amazon Resource Name (ARN) of the repository.
CloneUrlHttp-
When you pass the logical ID of this resource, the function returns the URL to use for cloning the repository over HTTPS.
CloneUrlSsh-
When you pass the logical ID of this resource, the function returns the URL to use for cloning the repository over SSH.
Name-
When you pass the logical ID of this resource, the function returns the repository's name.
Examples
The following examples can help you create CodeCommit repositories using Amazon CloudFormation.
Example
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
{ "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
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
The following example creates a CodeCommit repository with a trigger for all events in the development branch.
JSON
{ "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
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