Skip to content
GitHubXDiscordRSS

Domain

Learn how to create, update, and manage AWS CodeArtifact Domains using Alchemy Cloud Control.

The Domain resource allows you to manage AWS CodeArtifact Domains which serve as a central repository for your software packages.

Create a basic CodeArtifact Domain with a specified name and a permissions policy document.

import AWS from "alchemy/aws/control";
const codeArtifactDomain = await AWS.CodeArtifact.Domain("myCodeArtifactDomain", {
DomainName: "my-domain",
PermissionsPolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: {
AWS: "*"
},
Action: "codeartifact:GetDomain",
Resource: "*"
}
]
}
});

Configure a CodeArtifact Domain with additional properties such as an encryption key and tags.

const secureCodeArtifactDomain = await AWS.CodeArtifact.Domain("secureDomain", {
DomainName: "secure-domain",
PermissionsPolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: {
AWS: "*"
},
Action: "codeartifact:GetDomain",
Resource: "*"
}
]
},
EncryptionKey: "arn:aws:kms:us-west-2:123456789012:key/my-key-id",
Tags: [
{ Key: "Environment", Value: "Production" },
{ Key: "Project", Value: "MyProject" }
]
});

Use the adoption feature to create a domain only if it does not already exist.

const adoptedCodeArtifactDomain = await AWS.CodeArtifact.Domain("adoptedDomain", {
DomainName: "adopted-domain",
adopt: true // Adopt existing resource if it already exists
});

Create a CodeArtifact Domain with detailed tagging for better resource management and organization.

const taggedCodeArtifactDomain = await AWS.CodeArtifact.Domain("taggedDomain", {
DomainName: "tagged-domain",
Tags: [
{ Key: "Team", Value: "Development" },
{ Key: "CostCenter", Value: "CC12345" },
{ Key: "Project", Value: "CodeArtifactProject" }
]
});