Skip to content

Commit

Permalink
fix(cloudrun): update cloud run services names to unique values
Browse files Browse the repository at this point in the history
fixes #164
  • Loading branch information
glasnt committed Sep 24, 2024
1 parent 94a27ca commit cbc5075
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion run/access_control/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# [START cloudrun_access_control_parent_tag]
# [START cloudrun_service_access_control_run_service]
resource "google_cloud_run_v2_service" "default" {
name = "cloud-run-srv"
name = "public-service"
location = "us-central1"

deletion_protection = false # set to "true" in production
Expand Down
6 changes: 3 additions & 3 deletions run/add_tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# [START cloudrun_service_add_tag]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {}
Expand All @@ -26,14 +26,14 @@ resource "google_cloud_run_v2_service" "default" {
traffic {
percent = 100
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

traffic {
# Deploy new revision with 0% traffic
percent = 0
revision = "cloudrun-srv-blue"
revision = "blue"
tag = "tag-name"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}
Expand Down
2 changes: 1 addition & 1 deletion run/custom_domain_mapping/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# [START cloudrun_custom_domain_mapping_parent_tag]
# [START cloudrun_custom_domain_mapping_run_service]
resource "google_cloud_run_v2_service" "default" {
name = "cloud-run-srv"
name = "custom-domain"
location = "us-central1"
template {
containers {
Expand Down
8 changes: 4 additions & 4 deletions run/deploy_tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# [START cloudrun_service_deploy_tag]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

deletion_protection = false # set to "true" in production
Expand All @@ -26,22 +26,22 @@ resource "google_cloud_run_v2_service" "default" {
# image or tag must be different from previous revision
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
revision = "cloudrun-srv-blue"
revision = "blue"
}

# Define the traffic split for each revision
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_service#traffic
traffic {
percent = 100
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

traffic {
# Deploy new revision with 0% traffic
percent = 0
revision = "cloudrun-srv-blue"
revision = "blue"
tag = "tag-name"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}
Expand Down
2 changes: 1 addition & 1 deletion run/identity/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "google_service_account" "cloudrun_service_identity" {

# [START cloudrun_service_identity_run_service]
resource "google_cloud_run_v2_service" "default" {
name = "cloud-run-srv"
name = "id-service"
location = "us-central1"

deletion_protection = false # set to "true" in production
Expand Down
2 changes: 1 addition & 1 deletion run/noauth/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# [START cloudrun_noauth_parent_tag]
# [START cloudrun_service_noauth]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-public-service"
location = "us-central1"

deletion_protection = false # set to "true" in production
Expand Down
6 changes: 3 additions & 3 deletions run/remove_tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# [START cloudrun_service_remove_tag]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {}
Expand All @@ -26,7 +26,7 @@ resource "google_cloud_run_v2_service" "default" {
traffic {
percent = 100
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

Expand All @@ -35,7 +35,7 @@ resource "google_cloud_run_v2_service" "default" {
# Keep revision at 0% traffic
percent = 0
# This revision needs to already exist
revision = "cloudrun-srv-blue"
revision = "blue"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}
}
Expand Down
4 changes: 2 additions & 2 deletions run/secret_manager/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "google_secret_manager_secret_iam_member" "default" {

# [START cloudrun_secret_manager_mounted]
resource "google_cloud_run_v2_service" "mounted_secret" {
name = "cloudrun-srv-mounted-secret"
name = "service-with-mounted-secret"
location = "us-central1"
ingress = "INGRESS_TRAFFIC_ALL"

Expand Down Expand Up @@ -94,7 +94,7 @@ resource "google_cloud_run_v2_service" "mounted_secret" {

# [START cloudrun_secret_manager_env_variable]
resource "google_cloud_run_v2_service" "env_variable_secret" {
name = "cloudrun-srv-env-var-secret"
name = "service-with-env-var-secret"
location = "us-central1"
ingress = "INGRESS_TRAFFIC_ALL"

Expand Down
4 changes: 2 additions & 2 deletions run/traffic_gradual_rollout/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# [START cloudrun_service_traffic_gradual_rollout]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {
Expand All @@ -31,7 +31,7 @@ resource "google_cloud_run_v2_service" "default" {
traffic {
percent = 100
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

Expand Down
2 changes: 1 addition & 1 deletion run/traffic_latest_revision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# [START cloudrun_traffic_latest_revision_parent_tag]
# [START cloudrun_service_traffic_latest]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {}
Expand Down
4 changes: 2 additions & 2 deletions run/traffic_rollback/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

# [START cloudrun_service_traffic_rollback]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {}

traffic {
percent = 100
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"

}
Expand Down
8 changes: 4 additions & 4 deletions run/traffic_split/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@

# [START cloudrun_service_traffic_split]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
revision = "cloudrun-srv-green"
revision = "green"
}

# Define the traffic split for each revision
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_service#traffic
traffic {
percent = 25
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

traffic {
percent = 75
# This revision needs to already exist
revision = "cloudrun-srv-blue"
revision = "blue"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}
}
Expand Down
4 changes: 2 additions & 2 deletions run/traffic_split_tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# [START cloudrun_service_traffic_split_tag]
resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-srv"
name = "my-service"
location = "us-central1"

template {}
Expand All @@ -27,7 +27,7 @@ resource "google_cloud_run_v2_service" "default" {
# Update revision to 50% traffic
percent = 50
# This revision needs to already exist
revision = "cloudrun-srv-green"
revision = "green"
type = "TRAFFIC_TARGET_ALLOCATION_TYPE_REVISION"
}

Expand Down

0 comments on commit cbc5075

Please sign in to comment.