Skip to content

Terraform module that provisions AWS Code Artifact repositories and access to them

License

Notifications You must be signed in to change notification settings

catalystcommunity/terraform-aws-codeartifact

Repository files navigation

terraform-aws-codeartifact

The terraform-aws-codeartifact module optionally creates all resources necessary for creating an AWS CodeArtifact repository, including creating a domain and KMS key for encryption.

Additionally, this module can provision a role for use by CICD systems to upload to CodeArtifact. It includes upload access to ECR as well, as these systems are often used together.

By default, the module will create an NPM repository with the public NPM repository as an external connection.

Example Implementations

Basic

The most basic implementation creates all necessary resources for managing an NPM repository.

module "codeartifact" {
  source = "github.com/catalystcommunity/terraform-aws-codeartifact"

  enable_codeartifact_domain_kms_key = true
  codeartifact_domain_name           = "mydomain"
}

CICD Role

module "codeartifact" {
  source = "github.com/catalystcommunity/terraform-aws-codeartifact"

  enable_codeartifact_domain_kms_key = true
  codeartifact_domain_name           = "mydomain"
  enable_cicd_role                   = true
  cicd_role_trust_arns               = ["arn:aws:iam::123456789999:user/my-cicd-user"]
}

Requirements

Name Version
terraform >= 0.13.1
aws ~> 5.0

Inputs

Name Description Type Default Required
codeartifact_domain_name Name of CodeArtifact domain to create or reference based on var.enable_codeartifact_domain string n/a yes
cicd_role_description Description of the CICD role to create string "Role assumed by CICD pipelines" no
cicd_role_name Name of the CICD role to create string "cicd" no
cicd_role_trust_arns ARNs to trust for assume role list(string) [] no
codeartifact_domain_kms_key_arn CodeArtifact domain KMS key to use if var.enable_codeartifact_domain_kms_key is disabled string null no
codeartifact_domain_kms_key_description Description of KMS key to create if enabled string "" no
codeartifact_repositories List of repositories to create. Defaults to NPM with public NPM external connection
list(object({
name = string
description = string
external_connections = list(object({
external_connection_name = string
}))
upstreams = optional(list(object({
upstream_repository_name = string
})))
}))
[
{
"description": "NPM repository",
"external_connections": [
{
"external_connection_name": "public:npmjs"
}
],
"name": "npm"
}
]
no
enable_cicd_role Enables creation of a CICD role which grants access to Code Artifact and ECR bool false no
enable_codeartifact_domain Whether to enable creation of a CodeArtifact domain bool true no
enable_codeartifact_domain_kms_key Whether to enable creation of a KMS key for the CodeArtifact domain bool false no
tags n/a map(string) {} no

Outputs

No outputs.

Resources

Name Type
aws_codeartifact_domain.domain resource
aws_codeartifact_repository.repository resource
aws_iam_role.cicd_role resource
aws_kms_key.codeartifact_domain resource
aws_iam_policy_document.cicd_assume_role_policy data source
aws_iam_policy_document.cicd_codeartifact data source
aws_iam_policy_document.cicd_codeartifact_sts data source
aws_iam_policy_document.cicd_ecr data source

Modules

No modules.

About

Terraform module that provisions AWS Code Artifact repositories and access to them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages