Skip to content

Resource: awsCodeartifactRepository

Provides a CodeArtifact Repository Resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsKmsKeyExample = new aws.kmsKey.KmsKey(this, "example", {
  description: "domain key",
});
const awsCodeartifactDomainExample =
  new aws.codeartifactDomain.CodeartifactDomain(this, "example_1", {
    domain: "example",
    encryptionKey: awsKmsKeyExample.arn,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsCodeartifactDomainExample.overrideLogicalId("example");
new aws.codeartifactRepository.CodeartifactRepository(this, "test", {
  domain: awsCodeartifactDomainExample.domain,
  repository: "example",
});

Example Usage with upstream repository

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsCodeartifactRepositoryUpstream =
  new aws.codeartifactRepository.CodeartifactRepository(this, "upstream", {
    domain: "${aws_codeartifact_domain.test.domain}",
    repository: "upstream",
  });
new aws.codeartifactRepository.CodeartifactRepository(this, "test", {
  domain: "${aws_codeartifact_domain.example.domain}",
  repository: "example",
  upstream: [
    {
      repositoryName: awsCodeartifactRepositoryUpstream.repository,
    },
  ],
});

Example Usage with external connection

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.codeartifactRepository.CodeartifactRepository(this, "test", {
  domain: "${aws_codeartifact_domain.example.domain}",
  externalConnections: {
    externalConnectionName: "public:npmjs",
  },
  repository: "example",
});
new aws.codeartifactRepository.CodeartifactRepository(this, "upstream", {
  domain: "${aws_codeartifact_domain.test.domain}",
  repository: "upstream",
});

Argument Reference

The following arguments are supported:

  • domain - (Required) The domain that contains the created repository.
  • repository - (Required) The name of the repository to create.
  • domainOwner - (Optional) The account number of the AWS account that owns the domain.
  • description - (Optional) The description of the repository.
  • upstream - (Optional) 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. see Upstream
  • externalConnections - An array of external connections associated with the repository. Only one external connection can be set per repository. see External Connections.
  • tags - (Optional) Key-value map of resource tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Upstream

  • repositoryName - (Required) The name of an upstream repository.

External Connections

  • externalConnectionName - (Required) The name of the external connection associated with a repository.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ARN of the repository.
  • arn - The ARN of the repository.
  • administratorAccount - The account number of the AWS account that manages the repository.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

CodeArtifact Repository can be imported using the CodeArtifact Repository ARN, e.g.,

$ terraform import aws_codeartifact_repository.example arn:aws:codeartifact:us-west-2:012345678912:repository/tf-acc-test-6968272603913957763/tf-acc-test-6968272603913957763