Google Artifact Registry Repository

This page shows how to write Terraform for Artifact Registry Repository and write them securely.

google_artifact_registry_repository (Terraform)

The Repository in Artifact Registry can be configured in Terraform with the resource name google_artifact_registry_repository. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "google_artifact_registry_repository" "artifact-registry" {

  provider = google-beta

  location      = var.region
  repository_id = "web-app"
resource "google_artifact_registry_repository" "container-images-repo" {
    provider = google-beta

    location = var.location
    repository_id = "container-images"
    format = "DOCKER"
resource "google_artifact_registry_repository" "jobs_api_images_registry" {
  provider = google-beta

  repository_id = "jobs-api-images"
  project = var.gcp_project_id
  location = var.gcp_region

Review your Terraform file for Google best practices

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


The following arguments are supported:

  • repository_id - (Required) The last part of the repository name, for example: "repo1"

  • format - (Required) The format of packages that are stored in the repository. You can only create alpha formats if you are a member of the alpha user group.

  • location - (Optional) The name of the location this repository is located in.

  • description - (Optional) The user-provided description of the repository.

  • labels - (Optional) Labels with user-defined metadata. This field may contain up to 64 entries. Label keys and values may be no longer than 63 characters. Label keys must begin with a lowercase letter and may only contain lowercase letters, numeric characters, underscores, and dashes.

  • kms_key_name - (Optional) The Cloud KMS resource name of the customer managed encryption key that’s used to encrypt the contents of the Repository. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. This value may not be changed after the Repository has been created.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

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

  • id - an identifier for the resource with format projects/[[project]]/locations/[[location]]/repositories/[[repository_id]]

  • name - The name of the repository, for example: "projects/p1/locations/us-central1/repositories/repo1"

  • create_time - The time when the repository was created.

  • update_time - The time when the repository was last updated.

Explanation in Terraform Registry

A repository for storing artifacts

Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources. To get more information about Repository, see:

Frequently asked questions

What is Google Artifact Registry Repository?

Google Artifact Registry Repository is a resource for Artifact Registry of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Artifact Registry Repository?

For Terraform, the GoogleCloudPlatform/cloud-deploy-tutorials, mathieu-benoit/mygkecluster and JohannaGoergen/job-lib source code examples are useful. See the Terraform Example section for further details.


Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.