updated Terraform providers and modules

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-01-22 19:24:32 +01:00
parent e6c3784613
commit 5ba796b17d
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
4 changed files with 66 additions and 45 deletions

View File

@ -55,12 +55,12 @@ secrets:
pass services/consul/client-key > ansible/files/consul-client.key
pass cloud/GoogleCloud/json > google-cloud.json
echo "Saving secrets to: terraform.tfvars"
@echo "\
@echo -e "\
# secrets extracted from password-store\n\
digitalocean_token = \"$(shell pass cloud/DigitalOcean/token)\"\n\
cloudflare_token = \"$(shell pass cloud/Cloudflare/token)\"\n\
cloudflare_email = \"$(shell pass cloud/Cloudflare/email)\"\n\
cloudflare_org_id = \"$(shell pass cloud/Cloudflare/org_id)\"\n\
cloudflare_account = \"$(shell pass cloud/Cloudflare/account)\"\n\
digitalocean_token = \"$(shell pass cloud/DigitalOcean/token)\"\n\
alicloud_access_key = \"$(shell pass cloud/Alibaba/access-key)\"\n\
alicloud_secret_key = \"$(shell pass cloud/Alibaba/secret-key)\"\n\
" > terraform.tfvars

21
main.tf
View File

@ -6,8 +6,8 @@ provider "digitalocean" {
provider "cloudflare" {
email = var.cloudflare_email
token = var.cloudflare_token
org_id = var.cloudflare_org_id
api_key = var.cloudflare_token
account_id = var.cloudflare_account
}
provider "google" {
@ -43,6 +43,21 @@ locals {
ws = merge(local.env["defaults"], local.env[terraform.workspace])
}
/* CF Zones ------------------------------------*/
/* CloudFlare Zone IDs required for records */
data "cloudflare_zones" "active" {
filter { status = "active" }
}
/* For easier access to zone ID by domain name */
locals {
zones = {
for zone in data.cloudflare_zones.active.zones:
zone.name => zone.id
}
}
/* RESOURCES --------------------------------------*/
module "swarm" {
@ -111,7 +126,7 @@ resource "cloudflare_load_balancer_pool" "main" {
// This might work, not sure yet
resource "cloudflare_load_balancer" "main" {
zone = "status.im"
zone_id = local.zones["status.im"]
name = "${terraform.workspace}-${var.env}.status.im"
description = "Load balancing of Swarm fleet."
proxied = true

View File

@ -1,3 +1,41 @@
/* PROVIDERS ------------------------------------*/
variable "cloudflare_token" {
description = "Token for interacting with Cloudflare API."
type = string
}
variable "cloudflare_email" {
description = "Email address of Cloudflare account."
type = string
}
variable "cloudflare_account" {
description = "ID of the CloudFlare organization."
type = string
}
variable "digitalocean_token" {
description = "Token for interacting with DigitalOcean API."
type = string
}
variable "alicloud_access_key" {
description = "Alibaba Cloud API access key."
type = string
}
variable "alicloud_secret_key" {
description = "Alibaba Cloud API secret key."
type = string
}
variable "alicloud_region" {
description = "Alibaba Cloud hosting region."
type = string
default = "cn-hongkong"
}
/* CONFIG ----------------------------------------*/
variable "ssh_keys" {
@ -24,41 +62,3 @@ variable "ssh_user" {
type = string
default = "root"
}
/* PROVIDERS ------------------------------------*/
variable "cloudflare_token" {
description = "Token for interacting with Cloudflare API."
type = string
}
variable "digitalocean_token" {
description = "Token for interacting with DigitalOcean API."
type = string
}
variable "cloudflare_email" {
description = "Email address of Cloudflare account."
type = string
}
variable "cloudflare_org_id" {
description = "ID of the CloudFlare organization."
type = string
}
variable "alicloud_access_key" {
description = "Alibaba Cloud API access key."
type = string
}
variable "alicloud_secret_key" {
description = "Alibaba Cloud API secret key."
type = string
}
variable "alicloud_region" {
description = "Alibaba Cloud hosting region."
type = string
default = "cn-hongkong"
}

View File

@ -1,3 +1,9 @@
terraform {
required_version = ">= 0.12"
required_providers {
alicloud = " = 1.68.0"
cloudflare = " = 2.3.0"
digitalocean = " = 1.12.0"
google = " = 3.4.0"
}
}