Loading main.tf +15 −13 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ resource "google_cloud_run_v2_service" "webapp" { ingress = local.ingress launch_stage = var.launch_stage annotations = var.service_annotations deletion_protection = var.deletion_protection template { revision = var.revision Loading Loading @@ -308,6 +309,7 @@ resource "google_cloud_run_v2_job" "pre_deploy" { location = var.region project = var.project launch_stage = var.pre_deploy_job_launch_stage deletion_protection = var.deletion_protection template { labels = var.pre_deploy_job_labels Loading static_egress_ip.tf +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ resource "google_vpc_access_connector" "main" { project = var.project region = var.region max_throughput = var.vpc_access_connector_max_throughput min_throughput = var.vpc_access_connector_min_throughput subnet { name = google_compute_subnetwork.vpc_connector[0].name Loading tests/cloud_run_service.tftest.hcl +17 −5 Original line number Diff line number Diff line Loading @@ -174,19 +174,31 @@ run "test_env_vars_and_secrets" { } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[0].name == "HELLO" condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.name if env_var.name == "HELLO" ]) > 0 error_message = "A standard environment variable with the name 'HELLO' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[0].value == "WORLD!" error_message = "A standard environment variable with the value 'WORLD!' should be created." condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.value if env_var.value == "WORLD!" ]) > 0 error_message = "A standard environment variable with the name 'WORLD!' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[1].name == "SECRET" condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.name if env_var.name == "SECRET" ]) > 0 error_message = "A secret-backed environment variable with the name 'SECRET' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[1].value_source[0].secret_key_ref[0].secret == run.setup.secret_ids[0] condition = [ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.value_source if length(env_var.value_source) > 0 ][0][0].secret_key_ref[0].secret == run.setup.secret_ids[0] error_message = "A secret-backed environment variable referencing the 'run.setup.secret_ids[0]' secret should be created." } assert { Loading tests/pre_deploy_job.tftest.hcl +17 −5 Original line number Diff line number Diff line Loading @@ -87,19 +87,31 @@ run "test_pre_deploy_job_env_vars_and_secrets" { } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[0].name == "HELLO" condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.name if env_var.name == "HELLO" ]) > 0 error_message = "A standard environment variable with the name 'HELLO' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[0].value == "WORLD!" error_message = "A standard environment variable with the value 'WORLD!' should be created." condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.value if env_var.value == "WORLD!" ]) > 0 error_message = "A standard environment variable with the name 'WORLD!' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[1].name == "SECRET" condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.name if env_var.name == "SECRET" ]) > 0 error_message = "A secret-backed environment variable with the name 'SECRET' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[1].value_source[0].secret_key_ref[0].secret == run.setup.secret_ids[0] condition = [ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.value_source if length(env_var.value_source) > 0 ][0][0].secret_key_ref[0].secret == run.setup.secret_ids[0] error_message = "A secret-backed environment variable referencing the 'run.setup.secret_ids[0]' secret should be created." } assert { Loading tests/setup/main.tf +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ resource "google_compute_subnetwork" "test" { resource "google_vpc_access_connector" "test" { count = var.create_vpc_connector ? 1 : 0 min_throughput = 200 max_throughput = 300 name = "${random_id.name.hex}-setup" project = var.project region = var.region Loading Loading
main.tf +15 −13 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ resource "google_cloud_run_v2_service" "webapp" { ingress = local.ingress launch_stage = var.launch_stage annotations = var.service_annotations deletion_protection = var.deletion_protection template { revision = var.revision Loading Loading @@ -308,6 +309,7 @@ resource "google_cloud_run_v2_job" "pre_deploy" { location = var.region project = var.project launch_stage = var.pre_deploy_job_launch_stage deletion_protection = var.deletion_protection template { labels = var.pre_deploy_job_labels Loading
static_egress_ip.tf +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ resource "google_vpc_access_connector" "main" { project = var.project region = var.region max_throughput = var.vpc_access_connector_max_throughput min_throughput = var.vpc_access_connector_min_throughput subnet { name = google_compute_subnetwork.vpc_connector[0].name Loading
tests/cloud_run_service.tftest.hcl +17 −5 Original line number Diff line number Diff line Loading @@ -174,19 +174,31 @@ run "test_env_vars_and_secrets" { } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[0].name == "HELLO" condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.name if env_var.name == "HELLO" ]) > 0 error_message = "A standard environment variable with the name 'HELLO' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[0].value == "WORLD!" error_message = "A standard environment variable with the value 'WORLD!' should be created." condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.value if env_var.value == "WORLD!" ]) > 0 error_message = "A standard environment variable with the name 'WORLD!' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[1].name == "SECRET" condition = length([ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.name if env_var.name == "SECRET" ]) > 0 error_message = "A secret-backed environment variable with the name 'SECRET' should be created." } assert { condition = google_cloud_run_v2_service.webapp.template[0].containers[0].env[1].value_source[0].secret_key_ref[0].secret == run.setup.secret_ids[0] condition = [ for env_var in google_cloud_run_v2_service.webapp.template[0].containers[0].env : env_var.value_source if length(env_var.value_source) > 0 ][0][0].secret_key_ref[0].secret == run.setup.secret_ids[0] error_message = "A secret-backed environment variable referencing the 'run.setup.secret_ids[0]' secret should be created." } assert { Loading
tests/pre_deploy_job.tftest.hcl +17 −5 Original line number Diff line number Diff line Loading @@ -87,19 +87,31 @@ run "test_pre_deploy_job_env_vars_and_secrets" { } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[0].name == "HELLO" condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.name if env_var.name == "HELLO" ]) > 0 error_message = "A standard environment variable with the name 'HELLO' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[0].value == "WORLD!" error_message = "A standard environment variable with the value 'WORLD!' should be created." condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.value if env_var.value == "WORLD!" ]) > 0 error_message = "A standard environment variable with the name 'WORLD!' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[1].name == "SECRET" condition = length([ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.name if env_var.name == "SECRET" ]) > 0 error_message = "A secret-backed environment variable with the name 'SECRET' should be created." } assert { condition = google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env[1].value_source[0].secret_key_ref[0].secret == run.setup.secret_ids[0] condition = [ for env_var in google_cloud_run_v2_job.pre_deploy[0].template[0].template[0].containers[0].env : env_var.value_source if length(env_var.value_source) > 0 ][0][0].secret_key_ref[0].secret == run.setup.secret_ids[0] error_message = "A secret-backed environment variable referencing the 'run.setup.secret_ids[0]' secret should be created." } assert { Loading
tests/setup/main.tf +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ resource "google_compute_subnetwork" "test" { resource "google_vpc_access_connector" "test" { count = var.create_vpc_connector ? 1 : 0 min_throughput = 200 max_throughput = 300 name = "${random_id.name.hex}-setup" project = var.project region = var.region Loading