AWS::CodeGuruReviewer::RepositoryAssociation - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::CodeGuruReviewer::RepositoryAssociation

This resource configures how Amazon CodeGuru Reviewer retrieves the source code to be reviewed. You can use an Amazon CloudFormation template to create an association with the following repository types:

Note

You cannot use a CloudFormation template to create an association with a GitHub repository.

Syntax

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

JSON

{ "Type" : "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties" : { "BucketName" : String, "ConnectionArn" : String, "Name" : String, "Owner" : String, "Tags" : [ Tag, ... ], "Type" : String } }

YAML

Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: BucketName: String ConnectionArn: String Name: String Owner: String Tags: - Tag Type: String

Properties

BucketName

The name of the bucket. This is required for your S3Bucket repository. The name must start with the prefix codeguru-reviewer-*.

Required: No

Type: String

Pattern: ^\S(.*\S)?$

Minimum: 3

Maximum: 63

Update requires: Replacement

ConnectionArn

The Amazon Resource Name (ARN) of an Amazon CodeStar Connections connection. Its format is arn:aws:codestar-connections:region-id:aws-account_id:connection/connection-id. For more information, see Connection in the Amazon CodeStar Connections API Reference.

ConnectionArn must be specified for Bitbucket and GitHub Enterprise Server repositories. It has no effect if it is specified for an Amazon CodeCommit repository.

Required: No

Type: String

Pattern: arn:aws(-[\w]+)*:.+:.+:[0-9]{12}:.+

Minimum: 0

Maximum: 256

Update requires: Replacement

Name

The name of the repository.

Required: Yes

Type: String

Pattern: ^\S[\w.-]*$

Minimum: 1

Maximum: 100

Update requires: Replacement

Owner

The owner of the repository. For a GitHub Enterprise Server or Bitbucket repository, this is the username for the account that owns the repository.

Owner must be specified for Bitbucket and GitHub Enterprise Server repositories. It has no effect if it is specified for an Amazon CodeCommit repository.

Required: No

Type: String

Pattern: ^\S(.*\S)?$

Minimum: 1

Maximum: 100

Update requires: Replacement

Tags

An array of key-value pairs used to tag an associated repository. A tag is a custom attribute label with two parts:

  • A tag key (for example, CostCenter, Environment, Project, or Secret). Tag keys are case sensitive.

  • An optional field known as a tag value (for example, 111122223333, Production, or a team name). Omitting the tag value is the same as using an empty string. Like tag keys, tag values are case sensitive.

Required: No

Type: Array of Tag

Maximum: 50

Update requires: Replacement

Type

The type of repository that contains the source code to be reviewed. The valid values are:

  • CodeCommit

  • Bitbucket

  • GitHubEnterpriseServer

  • S3Bucket

Required: Yes

Type: String

Allowed values: CodeCommit | Bitbucket | GitHubEnterpriseServer | S3Bucket

Update requires: Replacement

Return values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the Amazon Resource Name (ARN) of the Amazon CodeGuru Reviewer RepositoryAssociation, such as arn:aws:codeguru-reviewer:region:123456789012:association/universally-unique-identifier.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following is the available sample return values. For more information about using Fn::GetAtt, see Fn::GetAtt.

AssociationArn

The Amazon Resource Name (ARN) of the RepositoryAssociation object. You can retrieve this ARN by calling ListRepositories.

Examples

Create an Amazon CodeCommit repository association using an existing CodeCommit repository

The following example creates an Amazon CodeGuru Reviewer repository association using an existing Amazon CodeCommit repository named MyRepository.

YAML

Resources: MyRepositoryAssociation: Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: Name: MyRepository Type: CodeCommit

JSON

{ "Resources": { "MyRepositoryAssociation": { "Type": "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties": { "Name": "MyRepository", "Type": "CodeCommit" } } } }

Create an Amazon CodeCommit repository association with a new CodeCommit repository

The following example creates an Amazon CodeCommit repository named MyRepositoryName. Next, it creates an Amazon CodeGuru Reviewer repository association using the CodeCommit repository. The DependsOn property in the RepositoryAssociation specifies the CodeCommit repository. This is because the repository association can be created only after the CodeCommit repository is created.

YAML

Resources: MyRepository: Type: AWS::CodeCommit::Repository Properties: RepositoryName: MyRepositoryName MyRepositoryAssociation: Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: Name: MyRepositoryName Type: CodeCommit

JSON

{ "Resources": { "MyRepository": { "Type": "AWS::CodeCommit::Repository", "Properties": { "RepositoryName": "MyRepositoryName" } }, "MyRepositoryAssociation": { "Type": "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties": { "Name": "MyRepositoryName", "Type": "CodeCommit" } } } }

Create a Bitbucket repository association

The following example creates an Amazon CodeGuru Reviewer repository association using a Bitbucket repository.

YAML

Resources: MyRepositoryAssociation: Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: Name: MyBitbucketRepoName Type: Bitbucket ConnectionArn: arn:aws:codestar-connections:us-west-2:123456789012:connection/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee Owner: MyOwnerName

JSON

{ "Resources": { "MyRepositoryAssociation": { "Type": "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties": { "Name": "MyBitbucketRepoName", "Type": "Bitbucket", "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Owner": "MyOwnerName" } } } }

Create a GitHub Enterprise Server repository association

The following example creates an Amazon CodeGuru Reviewer repository association using a GitHub Enterprise Server repository.

YAML

Resources: MyRepositoryAssociation: Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: Name: MyGitHubEnterpriseRepoName Type: GitHubEnterpriseServer ConnectionArn: arn:aws:codestar-connections:us-west-2:123456789012:connection/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee Owner: MyOwnerName

JSON

{ "Resources": { "MyRepositoryAssociation": { "Type": "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties": { "Name": "MyGitHubEnterpriseRepoName", "Type": "GitHubEnterpriseServer", "ConnectionArn": "arn:aws:codestar-connections:us-west-2:123456789012:connection/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Owner": "MyOwnerName" } } } }

Create a repository association with tags

The following example creates an Amazon CodeGuru Reviewer repository association that has two tags. The repository is an Amazon CodeCommit repository. Use the Tags property the same way to add tags when you create a BitBucket or GitHub Enterprise repository association.

YAML

Resources: MyRepositoryAssociation: Type: AWS::CodeGuruReviewer::RepositoryAssociation Properties: Name: MyRepository Type: CodeCommit Tags: - Key: tag1-key Value: tag1-value - Key: tag2-key Value: tag2-value

JSON

{ "Resources": { "MyRepositoryAssociation": { "Type": "AWS::CodeGuruReviewer::RepositoryAssociation", "Properties": { "Name": "MyRepository", "Type": "CodeCommit", "Tags": [ { "Key": "tag1-key", "Value": "tag1-value" }, { "Key": "tag2-key", "Value": "tag2-value" } ] } } } }