Fix direct variable usage

This commit is contained in:
Tobias Reisinger 2024-09-30 01:26:42 +02:00
parent bae9fe9e0f
commit ed555418e2
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 37 additions and 37 deletions

34
main.tf
View file

@ -21,13 +21,13 @@ terraform {
module "services" { module "services" {
source = "./modules/services" source = "./modules/services"
authentik_url = "${var.authentik_url}" authentik_url = var.authentik_url
authentik_token = "${var.authentik_token}" authentik_token = var.authentik_token
postgresql_host = "${var.postgresql_host}" postgresql_host = var.postgresql_host
postgresql_port = "${var.postgresql_port}" postgresql_port = var.postgresql_port
postgresql_username = "${var.postgresql_username}" postgresql_username = var.postgresql_username
postgresql_password = "${var.postgresql_password}" postgresql_password = var.postgresql_password
services = var.services services = var.services
} }
@ -35,21 +35,21 @@ module "services" {
module "infrastructure" { module "infrastructure" {
source = "./modules/infrastructure" source = "./modules/infrastructure"
hcloud_token = "${var.hcloud_token}" hcloud_token = var.hcloud_token
ovh_application_key = "${var.ovh_application_key}" ovh_application_key = var.ovh_application_key
ovh_application_secret = "${var.ovh_application_secret}" ovh_application_secret = var.ovh_application_secret
ovh_consumer_key = "${var.ovh_consumer_key}" ovh_consumer_key = var.ovh_consumer_key
scaleway_access_key = "${var.scaleway_access_key}" scaleway_access_key = var.scaleway_access_key
scaleway_secret_key = "${var.scaleway_secret_key}" scaleway_secret_key = var.scaleway_secret_key
scaleway_project_id = "${var.scaleway_project_id}" scaleway_project_id = var.scaleway_project_id
scaleway_organization_id = "${var.scaleway_organization_id}" scaleway_organization_id = var.scaleway_organization_id
tailscale_api_key = "${var.tailscale_api_key}" tailscale_api_key = var.tailscale_api_key
tailscale_tailnet = "${var.tailscale_tailnet}" tailscale_tailnet = var.tailscale_tailnet
default_ssh_key = "${var.default_ssh_key}" default_ssh_key = var.default_ssh_key
hosts = var.hosts hosts = var.hosts
services = var.services services = var.services

View file

@ -4,10 +4,10 @@ resource "hcloud_ssh_key" "default" {
} }
data "template_file" "cloud_init" { data "template_file" "cloud_init" {
template = "${file("./tf-templates/cloud-init.yaml.tpl")}" template = file("./tf-templates/cloud-init.yaml.tpl")
vars = { vars = {
tailscale_authkey = "${tailscale_tailnet_key.cloud_init_key.key}" tailscale_authkey = tailscale_tailnet_key.cloud_init_key.key
default_ssh_key = var.default_ssh_key.public_key default_ssh_key = var.default_ssh_key.public_key
} }
} }
@ -42,7 +42,7 @@ resource "hcloud_server" "nodes" {
image = each.value.image image = each.value.image
server_type = each.value.server_type server_type = each.value.server_type
ssh_keys = [hcloud_ssh_key.default.id] ssh_keys = [hcloud_ssh_key.default.id]
user_data = "${data.template_file.cloud_init.rendered}" user_data = data.template_file.cloud_init.rendered
public_net { public_net {
ipv4 = hcloud_primary_ip.node_ipv4_addresses[each.key].id ipv4 = hcloud_primary_ip.node_ipv4_addresses[each.key].id
ipv6 = hcloud_primary_ip.node_ipv6_addresses[each.key].id ipv6 = hcloud_primary_ip.node_ipv6_addresses[each.key].id

View file

@ -21,28 +21,28 @@ terraform {
provider "hcloud" { provider "hcloud" {
token = "${var.hcloud_token}" token = var.hcloud_token
} }
provider "ovh" { provider "ovh" {
endpoint = "ovh-eu" endpoint = "ovh-eu"
application_key = "${var.ovh_application_key}" application_key = var.ovh_application_key
application_secret = "${var.ovh_application_secret}" application_secret = var.ovh_application_secret
consumer_key = "${var.ovh_consumer_key}" consumer_key = var.ovh_consumer_key
} }
provider "scaleway" { provider "scaleway" {
organization_id = "${var.scaleway_organization_id}" organization_id = var.scaleway_organization_id
project_id = "${var.scaleway_project_id}" project_id = var.scaleway_project_id
access_key = "${var.scaleway_access_key}" access_key = var.scaleway_access_key
secret_key = "${var.scaleway_secret_key}" secret_key = var.scaleway_secret_key
region = "nl-ams" region = "nl-ams"
zone = "nl-ams-1" zone = "nl-ams-1"
} }
provider "tailscale" { provider "tailscale" {
api_key = "${var.tailscale_api_key}" api_key = var.tailscale_api_key
tailnet = "${var.tailscale_tailnet}" tailnet = var.tailscale_tailnet
} }

View file

@ -1,5 +1,5 @@
data "scaleway_account_project" "project" { data "scaleway_account_project" "project" {
project_id = "${var.scaleway_project_id}" project_id = var.scaleway_project_id
} }
resource "scaleway_account_ssh_key" "default" { resource "scaleway_account_ssh_key" "default" {

View file

@ -12,16 +12,16 @@ terraform {
} }
provider "authentik" { provider "authentik" {
url = "${var.authentik_url}" url = var.authentik_url
token = "${var.authentik_token}" token = var.authentik_token
} }
provider "postgresql" { provider "postgresql" {
host = "${var.postgresql_host}" host = var.postgresql_host
port = "${var.postgresql_port}" port = var.postgresql_port
database = "postgres" database = "postgres"
username = "${var.postgresql_username}" username = var.postgresql_username
password = "${var.postgresql_password}" password = var.postgresql_password
sslmode = "verify-full" sslmode = "verify-full"
connect_timeout = 15 connect_timeout = 15
} }