pati.to/services/cnriv/cnriv.tf
2024-11-20 18:34:28 -06:00

74 lines
1.4 KiB
HCL

terraform {
backend "consul" {
path = "nidito/state/service/cnriv.pati.to"
}
required_providers {
consul = {
source = "hashicorp/consul"
version = "~> 2.21.0"
}
vault = {
source = "hashicorp/vault"
version = "~> 4.4.0"
}
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.29.0"
}
}
required_version = ">= 1.0.0"
}
data "vault_generic_secret" "DO" {
path = "cfg/infra/tree/provider:digitalocean"
}
provider "digitalocean" {
token = data.vault_generic_secret.DO.data.patito
}
data "vault_generic_secret" "backblaze" {
path = "cfg/infra/tree/provider:backblaze"
}
data "terraform_remote_state" "rob_mx" {
backend = "consul"
workspace = "default"
config = {
datacenter = "casa"
path = "nidito/state/rob.mx"
}
}
resource "digitalocean_record" "to_pati_club" {
domain = "pati.to"
type = "A"
ttl = 3600
name = "cnriv"
value = data.terraform_remote_state.rob_mx.outputs.bernal.ip
}
resource "consul_keys" "cdn-config" {
datacenter = "qro0"
key {
path = "cdn/cnriv.pati.to"
value = jsonencode({
cert = "pati.to"
folder = "cnriv.pati.to"
nginx_config = file("${abspath(path.root)}/nginx.conf")
})
}
}
resource "vault_kv_secret" "deploy-config" {
path = "nidito/deploy/cnriv.pati.to"
data_json = jsonencode({
type = "ssh"
host = "bernal"
domain = "cnriv.pati.to"
})
}