AWS::CodeGuruReviewer::RepositoryAssociation - AWS CloudFormation

AWS::CodeGuruReviewer::RepositoryAssociation

This resource configures how Amazon CodeGuru Reviewer retrieves the source code to be reviewed. You can use an AWS 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 AWS 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

Not currently supported by AWS CloudFormation.

Required: No

Type: String

Update requires: Replacement

ConnectionArn

The Amazon Resource Name (ARN) of an AWS 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 AWS 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 AWS CodeCommit repository.

Required: No

Type: String

Minimum: 0

Maximum: 256

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

Update requires: Replacement

Name

The name of the repository.

Required: Yes

Type: String

Minimum: 1

Maximum: 100

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

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 AWS CodeCommit repository.

Required: No

Type: String

Minimum: 1

Maximum: 100

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

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: List of Tag

Update requires: Replacement

Type

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

  • CodeCommit

  • Bitbucket

  • GitHubEnterpriseServer

Required: Yes

Type: String

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 AWS 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 AWS CodeCommit repository association using an existing CodeCommit repository

The following example creates an Amazon CodeGuru Reviewer repository association using an existing AWS 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 AWS CodeCommit repository association with a new CodeCommit repository

The following example creates an AWS 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 AWS 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" } ] } } } }