AWS::CodeArtifact::Repository - AWS CloudFormation

AWS::CodeArtifact::Repository

The AWS::CodeArtifact::Repository resource creates an AWS CodeArtifact repository. CodeArtifact repositories contain a set of package versions. For more information about repositories, see the Repository concepts information in the CodeArtifact User Guide. For more information about the CreateRepository API, see CreateRepository in the CodeArtifact API Reference.

Syntax

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

JSON

{ "Type" : "AWS::CodeArtifact::Repository", "Properties" : { "Description" : String, "DomainName" : String, "DomainOwner" : String, "ExternalConnections" : [ String, ... ], "PermissionsPolicyDocument" : Json, "RepositoryName" : String, "Tags" : [ Tag, ... ], "Upstreams" : [ String, ... ] } }

YAML

Type: AWS::CodeArtifact::Repository Properties: Description: String DomainName: String DomainOwner: String ExternalConnections: - String PermissionsPolicyDocument: Json RepositoryName: String Tags: - Tag Upstreams: - String

Properties

Description

A text description of the repository.

Required: No

Type: String

Maximum: 1000

Pattern: \P{C}+

Update requires: No interruption

DomainName

The name of the domain that contains the repository.

Required: Yes

Type: String

Minimum: 2

Maximum: 50

Pattern: [a-z][a-z0-9\-]{0,48}[a-z0-9]

Update requires: Replacement

DomainOwner

The 12-digit account number of the AWS account that owns the domain that contains the repository. It does not include dashes or spaces.

Required: No

Type: String

Minimum: 12

Maximum: 12

Pattern: [0-9]{12}

Update requires: Replacement

ExternalConnections

An array of external connections associated with the repository.

Required: No

Type: List of String

Update requires: No interruption

PermissionsPolicyDocument

The document that defines the resource policy that is set on a repository.

Required: No

Type: Json

Update requires: No interruption

RepositoryName

The name of an upstream repository.

Required: Yes

Type: String

Minimum: 2

Maximum: 100

Pattern: [A-Za-z0-9][A-Za-z0-9._\-]{1,99}

Update requires: Replacement

Tags

A list of tags to be applied to the repository.

Required: No

Type: List of Tag

Update requires: No interruption

Upstreams

A list of upstream repositories to associate with the repository. The order of the upstream repositories in the list determines their priority order when AWS CodeArtifact looks for a requested package version. For more information, see Working with upstream repositories.

Required: No

Type: List of String

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource arn.

Fn::GetAtt

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 Fn::GetAtt.

Arn

When you pass the logical ID of this resource, the function returns the Amazon Resource Name (ARN) of the repository.

DomainName

When you pass the logical ID of this resource, the function returns the domain name that contains the repository.

DomainOwner

When you pass the logical ID of this resource, the function returns the 12-digit account number of the AWS account that owns the domain that contains the repository.

Name

When you pass the logical ID of this resource, the function returns the name of the repository.

Examples

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

Create a domain and repository

The following example creates a CodeArtifact domain named my-domain and a CodeArtifact repository named my-repo inside it.

YAML

Resources: MyCodeArtifactDomain: Type: 'AWS::CodeArtifact::Domain' Properties: DomainName: "my-domain" MyCodeArtifactRepository: Type: 'AWS::CodeArtifact::Repository' Properties: RepositoryName: "my-repo" DomainName: !GetAtt MyCodeArtifactDomain.Name

JSON

{ "Resources": { "MyCodeArtifactDomain": { "Type": "AWS::CodeArtifact::Domain", "Properties": { "DomainName": "my-domain" } }, "MyCodeArtifactRepository": { "Type": "AWS::CodeArtifact::Repository", "Properties": { "RepositoryName": "my-repo", "DomainName": { "Fn::GetAtt": [ "MyCodeArtifactDomain", "Name" ] } } } } }

Create a repository with an upstream repository and external connection

The following example creates a CodeArtifact domain named my-domain to store repositories. It also creates two CodeArtifact repositories: my-repo and my-upstream-repo within the domain. my-repo has my-upstream-repo configured as an upstream repository, and my-upstream-repo has an external connection to the public repository, npmjs.

YAML

Resources: MyCodeArtifactDomain: Type: 'AWS::CodeArtifact::Domain' Properties: DomainName: "my-domain" MyCodeArtifactUpstreamRepository: Type: 'AWS::CodeArtifact::Repository' Properties: RepositoryName: "my-upstream-repo" DomainName: !GetAtt MyCodeArtifactDomain.Name ExternalConnections: - public:npmjs MyCodeArtifactRepository: Type: 'AWS::CodeArtifact::Repository' Properties: RepositoryName: "my-repo" DomainName: !GetAtt MyCodeArtifactDomain.Name Upstreams: - !GetAtt MyCodeArtifactUpstreamRepository.Name

JSON

{ "Resources": { "MyCodeArtifactDomain": { "Type": "AWS::CodeArtifact::Domain", "Properties": { "DomainName": "my-domain" } }, "MyCodeArtifactUpstreamRepository": { "Type": "AWS::CodeArtifact::Repository", "Properties": { "RepositoryName": "my-upstream-repo", "DomainName": { "Fn::GetAtt": [ "MyCodeArtifactDomain", "Name" ] }, "ExternalConnections": [ "public:npmjs" ] } }, "MyCodeArtifactRepository": { "Type": "AWS::CodeArtifact::Repository", "Properties": { "RepositoryName": "my-repo", "DomainName": { "Fn::GetAtt": [ "MyCodeArtifactDomain", "Name" ] }, "Upstreams": [ { "Fn::GetAtt": [ "MyCodeArtifactUpstreamRepository", "Name" ] } ] } } } }