Skip to content

Commit

Permalink
Refactor cloud run module to use optionals and support all features (#…
Browse files Browse the repository at this point in the history
…1293)

* refactor cloud run resource and variables

* vpc connector variables and resource

* refactor env variable, combine and fix env examples

* fix volume example

* fix traffic split example

* fix eventarc/pubsub example

* fix eventarc/audit log example

* fix SA examples, fix examples formatting

* refactor eventarc variable

* tfdoc

* add IAM to example

* add examples for revision annotations and serverless connector

* fix new examples

* remove legacy module tests

* blueprint tests

* Add tests to cloud-run module

---------

Co-authored-by: Julio Castillo <jccb@google.com>
  • Loading branch information
2 people authored and lcaggio committed May 5, 2023
1 parent 6a9fb7b commit dd38a8c
Show file tree
Hide file tree
Showing 16 changed files with 821 additions and 455 deletions.
59 changes: 33 additions & 26 deletions blueprints/serverless/cloud-run-corporate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ locals {
cloud_run_domain = "run.app."
service_name_cr1 = "cart"
service_name_cr2 = "checkout"
tf_id = (var.tf_identity == null ? null :
length(regexall("iam.gserviceaccount.com", var.tf_identity)) > 0 ?
"serviceAccount:${var.tf_identity}" : "user:${var.tf_identity}")
vpc_sc_create = (length(module.project_prj1) > 0 &&
(var.access_policy != null || var.access_policy_create != null)) ? 1 : 0
tf_id = (
var.tf_identity == null
? null
: (
length(regexall("iam.gserviceaccount.com", var.tf_identity)) > 0
? "serviceAccount:${var.tf_identity}"
: "user:${var.tf_identity}"
)
)
vpc_sc_create = (
(
length(module.project_prj1) > 0
&&
(var.access_policy != null || var.access_policy_create != null)
)
? 1
: 0
)
}

###############################################################################
Expand Down Expand Up @@ -109,13 +122,11 @@ module "cloud_run_hello" {
project_id = module.project_main.project_id
name = "hello"
region = var.region
containers = [{
image = var.image
options = null
ports = null
resources = null
volume_mounts = null
}]
containers = {
default = {
image = var.image
}
}
iam = {
"roles/run.invoker" = ["allUsers"]
}
Expand All @@ -129,13 +140,11 @@ module "cloud_run_cart" {
project_id = module.project_svc1[0].project_id
name = local.service_name_cr1 # "cart"
region = var.region
containers = [{
image = var.image
options = null
ports = null
resources = null
volume_mounts = null
}]
containers = {
default = {
image = var.image
}
}
iam = {
"roles/run.invoker" = ["allUsers"]
}
Expand All @@ -149,13 +158,11 @@ module "cloud_run_checkout" {
project_id = module.project_svc1[0].project_id
name = local.service_name_cr2 # "checkout"
region = var.region
containers = [{
image = var.image
options = null
ports = null
resources = null
volume_mounts = null
}]
containers = {
default = {
image = var.image
}
}
iam = {
"roles/run.invoker" = ["allUsers"]
}
Expand Down
12 changes: 5 additions & 7 deletions blueprints/serverless/cloud-run-explore/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ module "cloud_run" {
project_id = module.project.project_id
name = var.run_svc_name
region = var.region
containers = [{
image = var.image
options = null
ports = null
resources = null
volume_mounts = null
}]
containers = {
default = {
image = var.image
}
}
iam = {
"roles/run.invoker" = ["allUsers"]
}
Expand Down

0 comments on commit dd38a8c

Please sign in to comment.