agones.dev/agones@v1.54.0/examples/terraform-submodules/gke/module.tf (about)

     1  // Copyright 2019 Google LLC All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  
    16  // Run:
    17  //  terraform apply -var project="<YOUR_GCP_ProjectID>" [-var agones_version="1.17.0"]
    18  
    19  terraform {
    20    required_version = ">= 1.0.0"
    21    required_providers {
    22      google = {
    23        source = "hashicorp/google"
    24        version = "~> 4.25.0"
    25      }
    26    }
    27  }
    28  
    29  variable "project" {
    30    default = ""
    31  }
    32  
    33  variable "name" {
    34    default = "agones-terraform-example"
    35  }
    36  
    37  // Install latest version of agones
    38  variable "agones_version" {
    39    default = ""
    40  }
    41  
    42  variable "machine_type" {
    43    default = "e2-standard-4"
    44  }
    45  
    46  // Note: This is the number of gameserver nodes. The Agones module will automatically create an additional
    47  // two node pools with 1 node each for "agones-system" and "agones-metrics".
    48  variable "node_count" {
    49    default = "4"
    50  }
    51  
    52  variable "enable_image_streaming" {
    53    default = "true"
    54  }
    55  
    56  variable "location" {
    57    default     = "us-west1-c"
    58    description = "The GCP location to create the cluster in"
    59  }
    60  
    61  variable "zone" {
    62    default     = ""
    63    description = "The GCP zone to create the cluster in (deprecated, use `location`)"
    64  }
    65  
    66  variable "network" {
    67    default     = "default"
    68    description = "The name of the VPC network to attach the cluster and firewall rule to"
    69  }
    70  
    71  variable "subnetwork" {
    72    default     = ""
    73    description = "The subnetwork to host the cluster in. Required field if network value isn't 'default'."
    74  }
    75  
    76  variable "log_level" {
    77    default = "info"
    78  }
    79  
    80  variable "feature_gates" {
    81    default = ""
    82  }
    83  
    84  variable "windows_node_count" {
    85    default = "0"
    86  }
    87  
    88  variable "windows_machine_type" {
    89    default = "e2-standard-4"
    90  }
    91  
    92  variable "autoscale" {
    93    default = "false"
    94  }
    95  
    96  variable "min_node_count" {
    97    default = "1"
    98  }
    99  
   100  variable "max_node_count" {
   101    default = "5"
   102  }
   103  
   104  module "gke_cluster" {
   105    // ***************************************************************************************************
   106    // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.17.0 corresponds
   107    // to Agones version 1.17.0
   108    // ***************************************************************************************************
   109    source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/gke/?ref=main"
   110  
   111    cluster = {
   112      "name"                    = var.name
   113      "location"		      = var.location
   114      "zone"                    = var.zone
   115      "machineType"             = var.machine_type
   116      "initialNodeCount"        = var.node_count
   117      "enableImageStreaming"    = var.enable_image_streaming
   118      "project"                 = var.project
   119      "network"                 = var.network
   120      "subnetwork"              = var.subnetwork
   121      "windowsInitialNodeCount" = var.windows_node_count
   122      "windowsMachineType"      = var.windows_machine_type
   123      "autoscale"		      = var.autoscale
   124      "mindNodeCount"	      = var.min_node_count
   125      "maxNodeCount"	      = var.max_node_count
   126    }
   127  }
   128  
   129  module "helm_agones" {
   130    // ***************************************************************************************************
   131    // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.17.0 corresponds
   132    // to Agones version 1.17.0
   133    // ***************************************************************************************************
   134    source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/helm3/?ref=main"
   135  
   136    agones_version         = var.agones_version
   137    values_file            = ""
   138    feature_gates          = var.feature_gates
   139    host                   = module.gke_cluster.host
   140    token                  = module.gke_cluster.token
   141    cluster_ca_certificate = module.gke_cluster.cluster_ca_certificate
   142    log_level              = var.log_level
   143  }
   144  
   145  output "host" {
   146    value = module.gke_cluster.host
   147  }
   148  output "token" {
   149    value     = module.gke_cluster.token
   150    sensitive = true
   151  }
   152  output "cluster_ca_certificate" {
   153    value = module.gke_cluster.cluster_ca_certificate
   154  }