Terraplay is a combination of a Discord bot (written in Go) and Terraform, designed to automate and manage game server provisioning and related infrastructure. It uses Terraform workspaces to create isolated environments for different game sessions, ensuring that infrastructure for each session is managed separately. There are two main infrastructure layers: global infrastructure and keeper infrastructure, which manage the underlying systems for Terraplay.
This is the foundational infrastructure for setting up a remote Terraform backend. You need a storage solution to save the state file and a database to lock the Terraform sessions, preventing errors or race conditions.
This situation often presents a "chicken-and-egg" problem: which comes first? There are two ways to resolve this:
For secure authentication, you can configure OpenID Connect (OIDC) for GitHub Actions, along with an appropriate role. This eliminates the need to use access keys like access_id and secret_access_key, making the setup more secure.


This part of the infrastructure includes the core resources, session management, and control mechanisms necessary for running game servers smoothly.
game.yml file, which contains important details about each game, including its firewall configuration, volume paths, and other customizable properties. Currently, only the firewall is being configured, but in the future, this YAML file will enable users to have more control over their game server configurations. After parsing the game.yml, we create the necessary security groups (firewall rules) to control network traffic.access_key_id and secret_access_key, opting instead for roles that provide secure and temporary access. A secret manager is set up to store the environment variables required by the bot.Though the Discord bot is currently the primary interface for managing game servers, a CLI or web interface could be created in the future to offer alternatives. However, Discord was chosen initially for ease of use.
we create a global Terraform workspace. All infrastructure state related to the global setup is managed in this workspace, ensuring that changes and resources are tracked properly. Terraform also locks the state to prevent multiple processes from making changes simultaneously, which helps avoid errors or conflicts.