[WIP] Add actual server values to nginx conf

This commit is contained in:
Jeremy Dormitzer 2021-10-04 09:28:06 -04:00
parent 2c645d94c6
commit aec886064a
4 changed files with 107 additions and 2 deletions

View File

@ -0,0 +1,59 @@
data "terraform_remote_state" "gitea" {
backend = "s3"
config = {
skip_credentials_validation = true
skip_metadata_api_check = true
access_key = var.spaces_access_id
secret_key = var.spaces_secret_key
region = "us-east-1"
endpoint = "nyc3.digitaloceanspaces.com"
bucket = "jdormit-tf-state"
key = "prod/gitea.tfstate"
}
}
data "terraform_remote_state" "syncthing" {
backend = "s3"
config = {
skip_credentials_validation = true
skip_metadata_api_check = true
access_key = var.spaces_access_id
secret_key = var.spaces_secret_key
region = "us-east-1"
endpoint = "nyc3.digitaloceanspaces.com"
bucket = "jdormit-tf-state"
key = "prod/syncthing.tfstate"
}
}
data "terraform_remote_state" "wallabag" {
backend = "s3"
config = {
skip_credentials_validation = true
skip_metadata_api_check = true
access_key = var.spaces_access_id
secret_key = var.spaces_secret_key
region = "us-east-1"
endpoint = "nyc3.digitaloceanspaces.com"
bucket = "jdormit-tf-state"
key = "prod/wallabag.tfstate"
}
}
data "terraform_remote_state" "freshrss" {
backend = "s3"
config = {
skip_credentials_validation = true
skip_metadata_api_check = true
access_key = var.spaces_access_id
secret_key = var.spaces_secret_key
region = "us-east-1"
endpoint = "nyc3.digitaloceanspaces.com"
bucket = "jdormit-tf-state"
key = "prod/freshrss.tfstate"
}
}

View File

@ -1,4 +1,30 @@
resource "local_file" "nginx_config" {
filename = "${path.module}/../tmp/nginx.conf"
content = templatefile("${path.module}/templates/nginx.conf.template", {})
content = templatefile(
"${path.module}/templates/nginx.conf.template",
{
"servers" : [
{
"domain" : "git.jeremydormitzer.com",
"ip" : "${data.terraform_remote_state.gitea.outputs.gitea_ip_address}",
"port" : "3000"
},
{
"domain" : "wallabag.jeremydormitzer.com",
"ip" : "${data.terraform_remote_state.wallabag.outputs.ip_address}",
"port" : "80"
},
{
"domain" : "rss.jeremydormitzer.com",
"ip" : "${data.terraform_remote_state.freshrss.outputs.ip_address}",
"port" : "80"
},
{
"domain" : "syncthing.jeremydormitzer.com",
"ip" : "${data.terraform_remote_state.syncthing.outputs.ip_address}",
"port" : "8384"
}
]
}
)
}

View File

@ -1 +1,10 @@
test
%{ for server in servers ~}
server {
server_name ${server.domain}
location / {
proxy_pass http://${server.ip}:${server.port}
}
}
%{ endfor ~}

View File

@ -0,0 +1,11 @@
variable "do_token" {
type = string
}
variable "spaces_access_id" {
type = string
}
variable "spaces_secret_key" {
type = string
}