Skip to content
GitHubXDiscord

Repository

The Repository resource lets you manage AWS CodeArtifact Repositorys for storing and retrieving packages.

Create a basic CodeArtifact repository with required properties.

import AWS from "alchemy/aws/control";
const basicRepository = await AWS.CodeArtifact.Repository("basic-repo", {
DomainName: "my-domain",
RepositoryName: "my-repo",
Description: "A basic repository for storing npm packages.",
Tags: [
{ Key: "Environment", Value: "Development" }
]
});

Configure a repository with external connections and permissions policy.

const advancedRepository = await AWS.CodeArtifact.Repository("advanced-repo", {
DomainName: "my-domain",
RepositoryName: "advanced-repo",
Description: "An advanced repository with external connections.",
ExternalConnections: ["public:npm"],
PermissionsPolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { AWS: "*" },
Action: "codeartifact:GetPackageVersion",
Resource: "*"
}
]
},
Upstreams: ["public:npm"]
});

Create a repository that includes multiple upstream repositories for package resolution.

const multiUpstreamRepo = await AWS.CodeArtifact.Repository("multi-upstream-repo", {
DomainName: "my-domain",
RepositoryName: "multi-upstream-repo",
Description: "Repository with multiple upstreams for package resolution.",
Upstreams: ["public:pypi", "public:npm"],
Tags: [
{ Key: "Project", Value: "MultiRepoIntegration" }
]
});

Set up a repository specifying a domain owner for better control and management.

const ownerRepo = await AWS.CodeArtifact.Repository("owner-repo", {
DomainName: "my-domain",
RepositoryName: "owner-repo",
DomainOwner: "123456789012", // Example AWS Account ID
Description: "A repository owned by a specific AWS account.",
Tags: [
{ Key: "Owner", Value: "MyAccount" }
]
});