add basic main.tf and workpaces.tf

This commit is contained in:
Jakub Sokołowski 2018-08-01 14:20:09 -04:00
parent 1f51df9315
commit a4ea13c7c2
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 78 additions and 0 deletions

58
main.tf Normal file
View File

@ -0,0 +1,58 @@
/* PROVIDERS --------------------------------------*/
provider "digitalocean" {
token = "${var.digitalocean_token}"
}
provider "cloudflare" {
email = "${var.cloudflare_email}"
token = "${var.cloudflare_token}"
}
provider "google" {
credentials = "${file("google-cloud.json")}"
project = "russia-servers"
region = "us-central1"
}
provider "alicloud" {
access_key = "${var.alicloud_access_key}"
secret_key = "${var.alicloud_secret_key}"
region = "${var.alicloud_region}"
}
/* BACKEND ----------------------------------------*/
terraform {
backend "consul" {
address = "https://consul.statusim.net:8400"
lock = true
/* WARNING This needs to be changed for every repo. */
path = "terraform/swarm/"
ca_file = "ansible/files/consul-ca.crt"
cert_file = "ansible/files/consul-client.crt"
key_file = "ansible/files/consul-client.key"
}
}
/* WORKSPACES -----------------------------------*/
locals {
ws = "${merge(local.env["defaults"], local.env[terraform.workspace])}"
}
/* RESOURCES --------------------------------------*/
module "swarm" {
source = "modules/multi-provider"
/* node type */
name = "swarm"
group = "swarm"
/* scaling options */
count = "${local.ws["hosts_count"]}"
/* general */
env = "${var.env}"
domain = "${var.domain}"
eth_network = "${var.eth_network}"
/* firewall */
open_ports = [
"30404-30410", /* discovery */
]
}

20
workspaces.tf Normal file
View File

@ -0,0 +1,20 @@
/* WORKSPACES ---------------------------------------------*/
/**
* This is a hacky way of binding specific variable
* values to different Terraform workspaces.
*
* Details:
* https://github.com/hashicorp/terraform/issues/15966
*/
locals {
env = {
defaults = {
hosts_count = 1
}
# For testing infra changes before rollout to other fleets
test = {}
}
}
/*---------------------------------------------------------*/