Skip to content

Commit 8d42798

Browse files
authored
chore(terraform): update example Terraform to use direct VPC access (#67)
1 parent 0e0a937 commit 8d42798

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

examples/terraform/network.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@
1515
#
1616
###############################################################################
1717

18-
# Serverless VPC access
19-
resource "google_vpc_access_connector" "eps_vpc_access" {
20-
name = "${var.app_name_short}-vpc-access"
21-
region = var.region
22-
ip_cidr_range = var.eps_vpc_access_cidr
23-
network = module.eps-network.network_id
24-
min_throughput = var.eps_vpc_access_min_throughput
25-
max_throughput = var.eps_vpc_access_max_throughput
26-
# min_instances = 2
27-
# max_instances = 10
28-
}
29-
3018
#
3119
# Private services access
3220
#

examples/terraform/run.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ resource "google_cloud_run_v2_service" "eps" {
4343
service_account = google_service_account.eps.account_id
4444

4545
vpc_access {
46-
connector = google_vpc_access_connector.eps_vpc_access.id
47-
egress = "PRIVATE_RANGES_ONLY" # Route only internal traffic through the connector
46+
network_interfaces {
47+
network = module.eps-network.network_id
48+
subnetwork = module.eps-network.subnets["${var.region}/${var.app_name_short}-${var.region}"].id
49+
}
50+
egress = "PRIVATE_RANGES_ONLY" # Route only internal traffic through the connector
4851
}
4952

5053
containers {
@@ -167,7 +170,6 @@ resource "google_cloud_run_v2_service" "eps" {
167170
}
168171

169172
depends_on = [
170-
google_vpc_access_connector.eps_vpc_access,
171173
google_service_account_iam_policy.terraform,
172174
google_secret_manager_secret_iam_policy.eps-db-pass
173175
]

examples/terraform/variables.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ variable "superusers" {
180180
}
181181

182182
variable "worker_pool_name" {
183-
description = "Name of the private worker pool."
184-
type = string
185-
default = "eps-private-pool" # Or make it required by removing default
183+
description = "Name of the private worker pool."
184+
type = string
185+
default = "eps-private-pool" # Or make it required by removing default
186186
}
187187

188188
variable "db_password_key" {
@@ -229,9 +229,9 @@ variable "app_image_name" {
229229
# Note: _DB_HOST uses another substitution, so we pass the template string
230230
# It could be made more dynamic if needed, but this keeps the Cloud Build logic
231231
variable "db_host_template" {
232-
description = "Template for DB host using Cloud Build substitution for instance connection name."
233-
type = string
234-
default = "/cloudsql/$${_INSTANCE_CONNECTION_NAME}" # Note the $$ to escape Terraform interpolation
232+
description = "Template for DB host using Cloud Build substitution for instance connection name."
233+
type = string
234+
default = "/cloudsql/$${_INSTANCE_CONNECTION_NAME}" # Note the $$ to escape Terraform interpolation
235235
}
236236

237237

@@ -257,9 +257,9 @@ variable "git_user_name" {
257257
}
258258

259259
variable "git_host" {
260-
description = "Hostname of the Git provider (e.g., github.com)."
261-
type = string
262-
default = "github.com"
260+
description = "Hostname of the Git provider (e.g., github.com)."
261+
type = string
262+
default = "github.com"
263263
}
264264

265265

@@ -270,13 +270,13 @@ variable "source_branch_name" {
270270
}
271271

272272
variable "trigger_service_account_email" {
273-
description = "Email of the service account for the trigger."
274-
type = string
273+
description = "Email of the service account for the trigger."
274+
type = string
275275
}
276276

277277
variable "github_app_id" {
278278
description = "Cloud build app id for your github organisation"
279279
type = number # Using number type as it's an ID. String would also work.
280280
nullable = false # Make it mandatory to provide a value
281-
default = {your github cloudbuild app id}
281+
default = null # {your github cloudbuild app id}"
282282
}

0 commit comments

Comments
 (0)