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

     1  // Copyright 2023 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.30.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  /////////////////////
    30  // Cluster parameters
    31  
    32  variable "name" {
    33    default = "agones-terraform-example"
    34  }
    35  
    36  variable "project" {
    37    default = ""
    38  }
    39  
    40  variable "location" {
    41    default     = "us-west1-c"
    42    description = "The GCP location to create the cluster in"
    43  }
    44  
    45  variable "network" {
    46    default     = "default"
    47    description = "The name of the VPC network to attach the cluster and firewall rule to"
    48  }
    49  
    50  variable "subnetwork" {
    51    default     = ""
    52    description = "The subnetwork to host the cluster in. Required field if network value isn't 'default'."
    53  }
    54  
    55  ////////////////////
    56  // Agones parameters
    57  
    58  // Install latest version of agones
    59  variable "agones_version" {
    60    default = ""
    61  }
    62  
    63  variable "log_level" {
    64    default = "info"
    65  }
    66  
    67  variable "feature_gates" {
    68    default = ""
    69  }
    70  
    71  module "gke_cluster" {
    72    // ***************************************************************************************************
    73    // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.17.0 corresponds
    74    // to Agones version 1.17.0
    75    // ***************************************************************************************************
    76    source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/gke/?ref=main"
    77  
    78    cluster = {
    79      "name"       = var.name
    80      "project"    = var.project
    81      "location"   = var.location
    82      "network"    = var.network
    83      "subnetwork" = var.subnetwork
    84    }
    85  }
    86  
    87  module "helm_agones" {
    88    // ***************************************************************************************************
    89    // Update ?ref= to the agones release you are installing. For example, ?ref=release-1.17.0 corresponds
    90    // to Agones version 1.17.0
    91    // ***************************************************************************************************
    92    source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/helm3/?ref=main"
    93  
    94    agones_version         = var.agones_version
    95    values_file            = ""
    96    feature_gates          = var.feature_gates
    97    host                   = module.gke_cluster.host
    98    token                  = module.gke_cluster.token
    99    cluster_ca_certificate = module.gke_cluster.cluster_ca_certificate
   100    log_level              = var.log_level
   101  }
   102  
   103  output "host" {
   104    value = module.gke_cluster.host
   105  }
   106  output "token" {
   107    value     = module.gke_cluster.token
   108    sensitive = true
   109  }
   110  output "cluster_ca_certificate" {
   111    value = module.gke_cluster.cluster_ca_certificate
   112  }