This repo contains Terraform modules for building various resources on Google Cloud Platform (GCP)
This repo has the following folder structure:
- root: The root folder contains the main implementation code for the modules, broken down into multiple standalone submodules.
- test: Automated tests for the submodules and examples. TODO
A Module is a canonical, reusable, best-practices definition for how to run a single piece of infrastructure, such as a database or server cluster. Each module is written using a combination of Terraform resources and bash scripts and include automated tests, documentation, and examples.
Modules are called from within other modules using module blocks:
module "servers" {
source = "./app-cluster"
#Note: If modules are located on differrent repo or registries, you can call that repo by using address scheme:
# source = "git@github.com:team/example.git"
servers = 5
}
- Install Terraform v0.12.0 or later.
- Open
variables.tf, and fill any required variables that don't have a default. You can also use environment variables to define your Terraform variables. Please see Terraform CLIfor more information. - Run
terraform init. - Run
terraform plan. - If the plan looks good, run
terraform applyto apply your change. - To destroy what you have applied, run
terraform destroy# terraform-modules