AWS CodeArtifact Domain

This page shows how to write Terraform and CloudFormation for CodeArtifact Domain and write them securely.

aws_codeartifact_domain (Terraform)

The Domain in CodeArtifact can be configured in Terraform with the resource name aws_codeartifact_domain. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "aws_codeartifact_domain" "domain" {
  domain         = var.domain
  encryption_key = var.kms_key_arn
  tags           = var.tags
resource "aws_codeartifact_domain" "test" {
    encryption_key = aws_kms_key.test.arn
resource "aws_codeartifact_domain" "my_domain" {
  domain = "my-domain"
  encryption_key = aws_kms_key.code_artifact_encryption_key.arn

resource "aws_codeartifact_repository" "my_repo_1" {
resource "aws_codeartifact_domain" "codeartifact_domain" {
  domain         = var.codeartifact_domain
  encryption_key = aws_kms_key.codeartifact_key.arn
resource "aws_codeartifact_repository" "codeartifact_upstream" {
  repository = var.codeartifact_upstream
resource "aws_codeartifact_domain" "examplea" {
  domain = var.domain
  tags   = var.common_tags

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


Explanation in Terraform Registry

Provides a CodeArtifact Domain Resource.

AWS::CodeArtifact::Domain (CloudFormation)

The Domain in CodeArtifact can be configured in CloudFormation with the resource name AWS::CodeArtifact::Domain. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.


Explanation in CloudFormation Registry

The AWS::CodeArtifact::Domain resource creates an AWS CodeArtifact domain. CodeArtifact domains make it easier to manage multiple repositories across an organization. You can use a domain to apply permissions across many repositories owned by different AWS accounts. For more information about domains, see the Domain concepts information in the CodeArtifact User Guide. For more information about the CreateDomain API, see CreateDomain in the CodeArtifact API Reference.

Frequently asked questions

What is AWS CodeArtifact Domain?

AWS CodeArtifact Domain is a resource for CodeArtifact of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS CodeArtifact Domain?

For Terraform, the shepherd44/terraform-aws-codeartifact, JamesWoolfenden/check-encrypt and aws-samples/codeartifact-retention-policy source code examples are useful. See the Terraform Example section for further details.