AWS::CodeArtifact::Repository - 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::CodeArtifact::Repository

The AWS::CodeArtifact::Repository resource creates an Amazon 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 Amazon CloudFormation template, use the following syntax:

JSON

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

YAML

Type: AWS::CodeArtifact::Repository Properties: Description: String DomainName: 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

Update requires: No interruption

DomainName

The name of the domain that contains the repository.

Required: Yes

Type: String

Pattern: ^([a-z][a-z0-9\-]{0,48}[a-z0-9])$

Minimum: 2

Maximum: 50

Update requires: Replacement

ExternalConnections

An array of external connections associated with the repository. For more information, see Supported external connection repositories in the CodeArtifact user guide.

Required: No

Type: Array of String

Update requires: No interruption

PermissionsPolicyDocument

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

Required: No

Type: Json

Minimum: 2

Maximum: 5120

Update requires: No interruption

RepositoryName

The name of an upstream repository.

Required: Yes

Type: String

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

Minimum: 2

Maximum: 100

Update requires: Replacement

Tags

A list of tags to be applied to the repository.

Required: No

Type: Array 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 Amazon CodeArtifact looks for a requested package version. For more information, see Working with upstream repositories.

Required: No

Type: Array 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 Amazon Web Services 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" ] } ] } } } }

Create a domain and repository with tags

The following example creates a CodeArtifact domain named my-domain and a CodeArtifact repository named my-repo inside it with two tags. One tag consists of a key named keyname1 and a value of value1. The other consists of a key named keyname2 and a value of value2.

YAML

Resources: MyCodeArtifactDomain: Type: 'AWS::CodeArtifact::Domain' Properties: DomainName: "my-domain" MyCodeArtifactRepository: Type: 'AWS::CodeArtifact::Repository' Properties: RepositoryName: "my-repo" DomainName: !GetAtt MyCodeArtifactDomain.Name Tags: - Key: "keyname1" Value: "value1" - Key: "keyname2" Value: "value2"

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" ] }, "Tags" : [ { "Key" : "keyname1", "Value" : "value1" }, { "Key" : "keyname2", "Value" : "value2" } ] } } } }