Skip to content

Commit a179a8e

Browse files
authored
fix: minor terraform changes (#3721)
Couple of small changes to our terraform config: - Added a couple of required GCP APIs that were missing - Added a `--gcs-log-dir` arg to the Cloud Build command that is run to build the ESPv2 image (required with some internal policies) - updated ESPv2 version to latest
1 parent b87e0fd commit a179a8e

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

deployment/terraform/environments/oss-vdb-test/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ module "osv_test" {
3232
backups_bucket_retention_days = 5
3333
affected_commits_backups_bucket = "osv-test-affected-commits"
3434
affected_commits_backups_bucket_retention_days = 2
35+
gcs_log_dir = "gs://oss-vdb-tf/apply-logs"
3536

3637
website_domain = "test.osv.dev"
3738
api_url = "api.test.osv.dev"
38-
esp_version = "2.51.0"
39+
esp_version = "2.53.0"
3940
}
4041

4142
module "k8s_cron_alert" {

deployment/terraform/environments/oss-vdb/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ module "osv" {
3232
backups_bucket_retention_days = 60
3333
affected_commits_backups_bucket = "osv-affected-commits"
3434
affected_commits_backups_bucket_retention_days = 3
35+
gcs_log_dir = "gs://oss-vdb-tf/apply-logs"
3536

3637
website_domain = "osv.dev"
3738
api_url = "api.osv.dev"
38-
esp_version = "2.51.0"
39+
esp_version = "2.53.0"
3940
}
4041

4142
module "k8s_cron_alert" {

deployment/terraform/modules/osv/gcp_apis.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,15 @@ resource "google_project_service" "cloud_build" {
9191
service = "cloudbuild.googleapis.com"
9292
disable_on_destroy = false
9393
}
94+
95+
resource "google_project_service" "cloud_firestore" {
96+
project = var.project_id
97+
service = "firestore.googleapis.com"
98+
disable_on_destroy = false
99+
}
100+
101+
resource "google_project_service" "certificate_manager" {
102+
project = var.project_id
103+
service = "certificatemanager.googleapis.com"
104+
disable_on_destroy = false
105+
}

deployment/terraform/modules/osv/osv_api.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ variable "_api_descriptor_file" {
5959
default = "api/api_descriptor.pb"
6060
}
6161

62+
variable "gcs_log_dir" {
63+
type = string
64+
description = "GCS directory to store cloud build logs."
65+
default = ""
66+
}
67+
6268
resource "google_endpoints_service" "grpc_service" {
6369
project = var.project_id
6470
service_name = var.api_url
@@ -97,7 +103,8 @@ resource "null_resource" "grpc_proxy_image" {
97103
-s ${var.api_url} \
98104
-c ${google_endpoints_service.grpc_service.config_id} \
99105
-p ${var.project_id} \
100-
-v ${var.esp_version}
106+
-v ${var.esp_version} \
107+
${var.gcs_log_dir != "" ? format("-l %s", var.gcs_log_dir) : ""}
101108
EOS
102109
}
103110
}

deployment/terraform/modules/osv/scripts/gcloud_build_image

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function error_exit() {
3838
# IMAGE_REPOSITORY as following:
3939
# 'LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY'
4040

41-
while getopts :c:s:p:v:z:g:i: arg; do
41+
GCS_LOG_DIR=""
42+
while getopts :c:s:p:v:z:g:i:l: arg; do
4243
case ${arg} in
4344
c) CONFIG_ID="${OPTARG}";;
4445
s) SERVICE="${OPTARG}";;
@@ -50,6 +51,7 @@ while getopts :c:s:p:v:z:g:i: arg; do
5051
BASE_IMAGE="${OPTARG}"
5152
ESP_FULL_VERSION="custom"
5253
;;
54+
l) GCS_LOG_DIR="${OPTARG}";;
5355
\?) error_exit "Unrecognized argument -${OPTARG}";;
5456
esac
5557
done
@@ -122,7 +124,11 @@ ENTRYPOINT ["/env_start_proxy.py"]
122124
EOF
123125

124126
NEW_IMAGE="${IMAGE_REPOSITORY}/endpoints-runtime-serverless:${ESP_FULL_VERSION}-${SERVICE}-${CONFIG_ID}"
125-
gcloud builds submit --tag "${NEW_IMAGE}" . --project="${PROJECT}"
127+
GCLOUD_BUILD_ARGS=("--tag" "${NEW_IMAGE}" "." "--project=${PROJECT}")
128+
if [[ -n "${GCS_LOG_DIR}" ]]; then
129+
GCLOUD_BUILD_ARGS+=("--gcs-log-dir=${GCS_LOG_DIR}")
130+
fi
131+
gcloud builds submit "${GCLOUD_BUILD_ARGS[@]}"
126132
)
127133

128134
# Delete the temporary directory we created earlier.

0 commit comments

Comments
 (0)