diff --git a/infrastructure/agones-gke.tf b/infrastructure/agones-gke.tf index 8092041..655d8bf 100644 --- a/infrastructure/agones-gke.tf +++ b/infrastructure/agones-gke.tf @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +##------------------------------## +## Google Terraform: Agones GKE ## +##------------------------------## + data "google_container_engine_versions" "regions" { for_each = var.game_gke_clusters diff --git a/infrastructure/allocation-endpoint.tf b/infrastructure/allocation-endpoint.tf index e96b17f..512ef03 100644 --- a/infrastructure/allocation-endpoint.tf +++ b/infrastructure/allocation-endpoint.tf @@ -134,6 +134,9 @@ resource "google_cloud_run_service" "aep_cloud_run" { "autoscaling.knative.dev/maxScale" = "1000" "autoscaling.knative.dev/minScale" = "0" } + labels = { + "environment" = var.resource_env_label + } } } @@ -172,6 +175,11 @@ resource "google_secret_manager_secret" "ae-sa-key" { replication { automatic = true } + + labels = { + "environment" = var.resource_env_label + } + depends_on = [google_project_service.project] } @@ -195,10 +203,16 @@ resource "google_project_service" "allocator-service" { } resource "google_compute_address" "allocation-endpoint" { + project = var.project for_each = var.game_gke_clusters region = each.value.region + provider = google-beta name = "allocator-endpoint-ip-${each.key}" + + labels = { + "environment" = var.resource_env_label + } } # Make Skaffold file for Cloud Deploy into each GKE Cluster diff --git a/infrastructure/artifact-registry.tf b/infrastructure/artifact-registry.tf index e46978d..e9f4840 100644 --- a/infrastructure/artifact-registry.tf +++ b/infrastructure/artifact-registry.tf @@ -17,4 +17,8 @@ resource "google_artifact_registry_repository" "container_registry" { location = var.artifact_registry_config.location description = "Repository for container images for the global game" format = "Docker" + + labels = { + "environment" = var.resource_env_label + } } diff --git a/infrastructure/pipelines.tf b/infrastructure/pipelines.tf index cf7e647..9864905 100644 --- a/infrastructure/pipelines.tf +++ b/infrastructure/pipelines.tf @@ -26,6 +26,10 @@ resource "google_clouddeploy_target" "services_deploy_target" { project = var.project require_approval = false + labels = { + "environment" = var.resource_env_label + } + depends_on = [google_project_service.project] } @@ -37,6 +41,10 @@ resource "google_clouddeploy_delivery_pipeline" "services_pipeline" { project = var.project + labels = { + "environment" = var.resource_env_label + } + serial_pipeline { stages { target_id = google_clouddeploy_target.services_deploy_target.target_id @@ -66,9 +74,7 @@ resource "google_clouddeploy_target" "agones" { } labels = { - my_first_label = "global-game-demo" - - my_second_label = "agones" + "environment" = var.resource_env_label } project = var.project @@ -90,9 +96,7 @@ resource "google_clouddeploy_delivery_pipeline" "agones" { description = "Global Game: Agones Deploy Pipeline" labels = { - my_first_label = "global-game-demo" - - my_second_label = "agones" + "environment" = var.resource_env_label } project = var.project @@ -120,6 +124,10 @@ resource "google_clouddeploy_target" "open-match-target" { cluster = data.google_container_cluster.services-gke.id } + labels = { + "environment" = var.resource_env_label + } + project = var.project require_approval = false @@ -133,6 +141,10 @@ resource "google_clouddeploy_delivery_pipeline" "open-match" { description = "Global Game: Open Match Deploy Pipeline" project = var.project + labels = { + "environment" = var.resource_env_label + } + serial_pipeline { stages { target_id = google_clouddeploy_target.open-match-target.target_id diff --git a/infrastructure/services-gke.tf b/infrastructure/services-gke.tf index 026e5b3..24bc52b 100644 --- a/infrastructure/services-gke.tf +++ b/infrastructure/services-gke.tf @@ -31,6 +31,10 @@ resource "google_container_cluster" "services-gke" { enable_private_endpoint = false } + resource_labels = { + "environment" = var.resource_env_label + } + depends_on = [google_compute_subnetwork.subnet, google_project_service.project] } diff --git a/infrastructure/spanner.tf b/infrastructure/spanner.tf index 0ce82e6..d032dbe 100644 --- a/infrastructure/spanner.tf +++ b/infrastructure/spanner.tf @@ -17,6 +17,10 @@ resource "google_spanner_instance" "global-game-spanner" { display_name = var.spanner_config.instance_name num_nodes = var.spanner_config.num_nodes + labels = { + "environment" = var.resource_env_label + } + depends_on = [google_project_service.project] } diff --git a/infrastructure/terraform.tfvars.sample b/infrastructure/terraform.tfvars.sample index 8a48007..14ea271 100644 --- a/infrastructure/terraform.tfvars.sample +++ b/infrastructure/terraform.tfvars.sample @@ -13,7 +13,8 @@ # limitations under the License. # Project Specific Variables -project = "PROJECT_ID" +project = "PROJECT_ID" +resource_env_label = "demo-global-game" # Cloud Deploy Configuration platform_directory = "../platform" # Relative to Terraform directory diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index f00653f..011c81a 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -25,6 +25,11 @@ variable "gcp_project_services" { default = [] } +variable "resource_env_label" { + type = string + description = "Label/Tag to apply to resources" +} + ### VPC Variables ### variable "vpc_name" {