Skip to content

Commit

Permalink
Added labels/tags to resources that support labels (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
abmarcum authored Mar 1, 2023
1 parent 89a4efd commit f4a2373
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 7 deletions.
4 changes: 4 additions & 0 deletions infrastructure/agones-gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions infrastructure/allocation-endpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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]
}

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/artifact-registry.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
24 changes: 18 additions & 6 deletions infrastructure/pipelines.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/services-gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
4 changes: 4 additions & 0 deletions infrastructure/spanner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
3 changes: 2 additions & 1 deletion infrastructure/terraform.tfvars.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit f4a2373

Please sign in to comment.