Skip to content

Commit

Permalink
Added optional Terraform GCS backend example (#78)
Browse files Browse the repository at this point in the history
* Added optional Terraform GCS backend

* Re-ordered README

* Fixed Heading Sizes

* Convert backend tasks to a task list

* Additional README corrections
  • Loading branch information
abmarcum authored Feb 27, 2023
1 parent b4f2814 commit 755438b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
!.gitignore
*.iml
terraform.tfstate*
backend.tf
*.tfvars

deploy/base/charts/
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PROJECT_ID>
### Edit terraform.tfvars, especially <PROJECT_ID>
```

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
Expand All @@ -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.

Expand Down
24 changes: 24 additions & 0 deletions infrastructure/backend.tf.sample
Original file line number Diff line number Diff line change
@@ -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 = "<Terraform State Backend Storage Bucket>"
prefix = "global-game-terraform-state"
}
}

0 comments on commit 755438b

Please sign in to comment.