From 755438bd7d71f6893b8b0637d67d3588a824d6a5 Mon Sep 17 00:00:00 2001 From: Andrew Marcum <123010092+abmarcum@users.noreply.github.com> Date: Mon, 27 Feb 2023 10:50:36 -0600 Subject: [PATCH] Added optional Terraform GCS backend example (#78) * Added optional Terraform GCS backend * Re-ordered README * Fixed Heading Sizes * Convert backend tasks to a task list * Additional README corrections --- .gitignore | 1 + README.md | 24 +++++++++++++++++------- infrastructure/backend.tf.sample | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 infrastructure/backend.tf.sample diff --git a/.gitignore b/.gitignore index c56df6c..04bf1bf 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ !.gitignore *.iml terraform.tfstate* +backend.tf *.tfvars deploy/base/charts/ diff --git a/README.md b/README.md index 086bdcf..726af62 100644 --- a/README.md +++ b/README.md @@ -38,30 +38,40 @@ cd global-multiplayer-demo export GAME_DEMO_HOME=$(pwd) ``` -### Provision +## Provision -Initialize Terraform & configure variables +### Optional: GCS Backend + +Normally Terraform stores the current state in the `terraform.tfstate` file locally. However, if you would like to have Terraform store the state file in a GCS Bucket, you can: + +- [ ] Edit `backend.tf.sample` +- [ ] Change the `bucket =` line to an already created GCS bucket +- [ ] Rename `backend.tf.sample` to `backend.tf`. + +NOTE: The GCS bucket does not have to exist in the same Google project as the Global Game but the Google user/service account running Terraform must have write & read access to that bucket. + +### Initialize Terraform & configure variables ```shell cd $GAME_DEMO_HOME/infrastructure terraform init cp terraform.tfvars.sample terraform.tfvars -# Edit terraform.tfvars, especially +### Edit terraform.tfvars, especially ``` -Provision the infrastructure. +### Provision the infrastructure. ```shell terraform apply ``` -#### Deploy Agones To Agones GKE Clusters +### Deploy Agones To Agones GKE Clusters The Agones deployment is in two steps: The Initial Install and the Allocation Endpoint Patch. -#### Initial Install +### Initial Install Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Agones using Cloud Deploy. ```shell @@ -80,7 +90,7 @@ Continue the promotion until Agones has been deployed to all clusters. You can monitor the status of the deployment through the Cloud Logging URL returned by the `gcloud builds` command as well as the Kubernetes Engine/Worloads panel in the GCP Console. Once the Worloads have been marked as OK, you can proceed to apply the Allocation Endpoint Patch. -#### Deploy Open Match to Services GKE Cluster +### Deploy Open Match to Services GKE Cluster Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Open Match using Cloud Deploy. diff --git a/infrastructure/backend.tf.sample b/infrastructure/backend.tf.sample new file mode 100644 index 0000000..188a4de --- /dev/null +++ b/infrastructure/backend.tf.sample @@ -0,0 +1,24 @@ +// Copyright 2023 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +##---------------------------------------## +## Google Terraform: Backend Declaration ## +##---------------------------------------## + +terraform { + backend "gcs" { + bucket = "" + prefix = "global-game-terraform-state" + } +}