Skip to content

Commit f7a3741

Browse files
authored
Enable Artifact Registry in GCP CI Conformance Terraform (#63)
1 parent 0b9000c commit f7a3741

File tree

7 files changed

+51
-15
lines changed

7 files changed

+51
-15
lines changed

deployment/live/gcp/ci/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export GOOGLE_REGION={VALUE} # e.g: us-central1
3030
unset TESSERA_BASE_NAME
3131
```
3232

33-
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`.
34-
3533
Build and push the Docker image to Artifact Registry repository:
3634

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

deployment/live/gcp/ci/terragrunt.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ terraform {
44

55
locals {
66
env = "ci"
7+
docker_env = local.env
78
base_name = "${local.env}-conformance"
89
server_docker_image = "us-central1-docker.pkg.dev/${include.root.locals.project_id}/docker-${local.env}/conformance-gcp:latest"
910
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
terraform {
2+
required_providers {
3+
google = {
4+
source = "registry.terraform.io/hashicorp/google"
5+
version = "6.1.0"
6+
}
7+
}
8+
}
9+
10+
# Artifact Registry
11+
12+
resource "google_project_service" "artifact_registry_api" {
13+
service = "artifactregistry.googleapis.com"
14+
disable_on_destroy = false
15+
}
16+
17+
resource "google_artifact_registry_repository" "docker" {
18+
repository_id = "docker-${var.docker_env}"
19+
location = var.location
20+
description = "Static CT docker images"
21+
format = "DOCKER"
22+
depends_on = [
23+
google_project_service.artifact_registry_api,
24+
]
25+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "location" {
2+
description = "Location in which to create resources"
3+
type = string
4+
}
5+
6+
variable "docker_env" {
7+
description = "Unique identifier for the Docker env, e.g. dev or ci or prod"
8+
type = string
9+
}

deployment/modules/gcp/cloudbuild/main.tf

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@ terraform {
1111

1212
# Artifact Registry
1313

14-
resource "google_project_service" "artifact_registry_api" {
15-
service = "artifactregistry.googleapis.com"
16-
disable_on_destroy = false
17-
}
14+
module "artifactregistry" {
15+
source = "../artifactregistry"
1816

19-
resource "google_artifact_registry_repository" "docker" {
20-
repository_id = "docker-${var.docker_env}"
21-
location = var.location
22-
description = "Static CT docker images"
23-
format = "DOCKER"
24-
depends_on = [
25-
google_project_service.artifact_registry_api,
26-
]
17+
location = var.location
18+
docker_env = var.docker_env
2719
}
2820

2921
# Cloud Build

deployment/modules/gcp/conformance/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ terraform {
22
backend "gcs" {}
33
}
44

5+
module "artifactregistry" {
6+
source = "../artifactregistry"
7+
8+
location = var.location
9+
docker_env = var.docker_env
10+
}
11+
512
module "storage" {
613
source = "../storage"
714

deployment/modules/gcp/conformance/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ variable "env" {
1818
type = string
1919
}
2020

21+
variable "docker_env" {
22+
description = "Unique identifier for the Docker env, e.g. dev or ci or prod"
23+
type = string
24+
}
25+
2126
variable "server_docker_image" {
2227
description = "The full image URL (path & tag) for the Docker image to deploy in Cloud Run"
2328
type = string

0 commit comments

Comments
 (0)