infra-faucet/main.tf

89 lines
2.1 KiB
HCL

provider "cloudflare" {
email = var.cloudflare_email
api_key = var.cloudflare_token
account_id = var.cloudflare_account
}
provider "google" {
credentials = file("google-cloud.json")
project = "russia-servers"
region = "us-central1"
}
/* DATA -----------------------------------------*/
terraform {
backend "consul" {
address = "https://consul.statusim.net:8400"
lock = true
/* KV store has a limit of 512KB */
gzip = true
/* WARNING This needs to be changed for every repo. */
path = "terraform/faucet/"
ca_file = "ansible/files/consul-ca.crt"
cert_file = "ansible/files/consul-client.crt"
key_file = "ansible/files/consul-client.key"
}
}
/* PLUMBING -------------------------------------*/
/* CloudFlare Zone IDs required for records */
data "cloudflare_zones" "active" {
filter {
name = "status.im"
status = "active"
}
}
/* RESOURCES ------------------------------------*/
module "main" {
source = "github.com/status-im/infra-tf-google-cloud"
name = "master"
env = "faucet"
group = "faucet-master"
type = "n1-standard-2"
host_count = 1
root_vol_size = 30
domain = var.domain
open_tcp_ports = [
"80", /* HTTP */
"443", /* HTTPS */
"30303", /* GETH */
]
}
/* DNS Entries for faucet APIs */
resource "cloudflare_record" "main-ropsten" {
zone_id = data.cloudflare_zones.active.zones[0].id
name = "faucet-ropsten"
type = "A"
proxied = true
value = module.main.public_ips[count.index]
count = length(module.main.public_ips)
}
resource "cloudflare_record" "main-rinkeby" {
zone_id = data.cloudflare_zones.active.zones[0].id
name = "faucet-rinkeby"
type = "A"
proxied = true
value = module.main.public_ips[count.index]
count = length(module.main.public_ips)
}
resource "cloudflare_record" "main-goerli" {
zone_id = data.cloudflare_zones.active.zones[0].id
name = "faucet-goerli"
type = "A"
proxied = true
value = module.main.public_ips[count.index]
count = length(module.main.public_ips)
}