From XennisWiki
Jump to: navigation, search

Terraform is an infrastructure as code software by HashiCorp. It allows users to define a datacenter infrastructure in a high-level configuration language, from which it can create an execution plan to build the infrastructure such as OpenStack or in a service provider such as AWS, IBM Cloud (formerly Bluemix), Google Cloud Platform, Linode, Microsoft Azure, Oracle Cloud Infrastructure, or VMware vSphere. Infrastructure is defined in a HCL Terraform syntax or JSON format. (Wikipedia)


Arch Linux

Install the terraform package.

Auto completion

terraform -install-autocomplete


Google Cloud Platform


terraform {
  backend "gcs" {
    bucket = "<my-project>-terraform-state"
    #credentials = ".credentials.json"

variable "project" {
  description = "Project ID"
  default     = "<my-project>"

variable "region" {
  description = "Region"
  default     = "europe-west1"

variable "zone" {
  description = "Zone"
  default     = "europe-west1-c"

provider "google" {
  #credentials = "${file(".credentials.json")}"
  project = var.project
  region  = var.region

resource "google_project_services" "gps_main" {
  project = var.project

  services = [

Initialize Terraform

export GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json
terraform init

Apply the changes

terraform apply


Format and validate files

terraform fmt
terraform validate

External links