Skip to content

Enable Artifact Registry in GCP CI Conformance Terraform #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions deployment/live/gcp/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export GOOGLE_REGION={VALUE} # e.g: us-central1
unset TESSERA_BASE_NAME
```

TODO: Add the Artifact Registry which is in the Cloud Build pull request. The expected repository is `${GOOGLE_REGION}-docker.pkg.dev/${GOOGLE_PROJECT}/docker-ci`.

Build and push the Docker image to Artifact Registry repository:

```sh
Expand All @@ -45,4 +43,3 @@ docker push ${GOOGLE_REGION}-docker.pkg.dev/${GOOGLE_PROJECT}/docker-ci/conforma
Terraforming the project can be done by:
1. `cd` to the relevant directory (deployment/live/gcp/ci/) for the environment to deploy/change.
2. Run `terragrunt apply`.

1 change: 1 addition & 0 deletions deployment/live/gcp/ci/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ terraform {

locals {
env = "ci"
docker_env = local.env
base_name = "${local.env}-conformance"
server_docker_image = "us-central1-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/conformance-gcp:latest"
}
Expand Down
25 changes: 25 additions & 0 deletions deployment/modules/gcp/artifactregistry/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
terraform {
required_providers {
google = {
source = "registry.terraform.io/hashicorp/google"
version = "6.1.0"
}
}
}

# Artifact Registry

resource "google_project_service" "artifact_registry_api" {
service = "artifactregistry.googleapis.com"
disable_on_destroy = false
}

resource "google_artifact_registry_repository" "docker" {
repository_id = "docker-${var.docker_env}"
location = var.location
description = "Static CT docker images"
format = "DOCKER"
depends_on = [
google_project_service.artifact_registry_api,
]
}
9 changes: 9 additions & 0 deletions deployment/modules/gcp/artifactregistry/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "location" {
description = "Location in which to create resources"
type = string
}

variable "docker_env" {
description = "Unique identifier for the Docker env, e.g. dev or ci or prod"
type = string
}
16 changes: 4 additions & 12 deletions deployment/modules/gcp/cloudbuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ terraform {

# Artifact Registry

resource "google_project_service" "artifact_registry_api" {
service = "artifactregistry.googleapis.com"
disable_on_destroy = false
}
module "artifactregistry" {
source = "../artifactregistry"

resource "google_artifact_registry_repository" "docker" {
repository_id = "docker-${var.docker_env}"
location = var.location
description = "Static CT docker images"
format = "DOCKER"
depends_on = [
google_project_service.artifact_registry_api,
]
location = var.location
docker_env = var.docker_env
}

# Cloud Build
Expand Down
7 changes: 7 additions & 0 deletions deployment/modules/gcp/conformance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ terraform {
backend "gcs" {}
}

module "artifactregistry" {
source = "../artifactregistry"

location = var.location
docker_env = var.docker_env
}

module "storage" {
source = "../storage"

Expand Down
5 changes: 5 additions & 0 deletions deployment/modules/gcp/conformance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ variable "env" {
type = string
}

variable "docker_env" {
description = "Unique identifier for the Docker env, e.g. dev or ci or prod"
type = string
}

variable "server_docker_image" {
description = "The full image URL (path & tag) for the Docker image to deploy in Cloud Run"
type = string
Expand Down
Loading