Move terraform files into modules
This commit is contained in:
		
							parent
							
								
									4e495dbc51
								
							
						
					
					
						commit
						bae9fe9e0f
					
				
					 14 changed files with 286 additions and 104 deletions
				
			
		
							
								
								
									
										93
									
								
								main.tf
									
										
									
									
									
								
							
							
						
						
									
										93
									
								
								main.tf
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,31 +1,4 @@
 | 
			
		|||
terraform {
 | 
			
		||||
  required_providers {
 | 
			
		||||
    authentik = {
 | 
			
		||||
      source = "goauthentik/authentik"
 | 
			
		||||
      version = "~> 2024.8.0"
 | 
			
		||||
    }
 | 
			
		||||
    hcloud = {
 | 
			
		||||
      source = "hetznercloud/hcloud"
 | 
			
		||||
      version = "~> 1.45.0"
 | 
			
		||||
    }
 | 
			
		||||
    ovh = {
 | 
			
		||||
      source = "ovh/ovh"
 | 
			
		||||
      version = "~> 0.48.0"
 | 
			
		||||
    }
 | 
			
		||||
    postgresql = {
 | 
			
		||||
      source = "cyrilgdn/postgresql"
 | 
			
		||||
      version = "~> 1.23.0"
 | 
			
		||||
    }
 | 
			
		||||
    scaleway = {
 | 
			
		||||
      source = "scaleway/scaleway"
 | 
			
		||||
      version = "~> 2.43.0"
 | 
			
		||||
    }
 | 
			
		||||
    tailscale = {
 | 
			
		||||
      source = "tailscale/tailscale"
 | 
			
		||||
      version = "~> 0.16.0"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  backend "s3" {
 | 
			
		||||
    bucket         = var.backend_bucket
 | 
			
		||||
    access_key     = var.backend_access_key
 | 
			
		||||
| 
						 | 
				
			
			@ -45,49 +18,39 @@ terraform {
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
provider "authentik" {
 | 
			
		||||
  url   = "${var.authentik_url}"
 | 
			
		||||
  token = "${var.authentik_token}"
 | 
			
		||||
module "services" {
 | 
			
		||||
  source = "./modules/services"
 | 
			
		||||
 | 
			
		||||
  authentik_url = "${var.authentik_url}"
 | 
			
		||||
  authentik_token = "${var.authentik_token}"
 | 
			
		||||
 | 
			
		||||
  postgresql_host = "${var.postgresql_host}"
 | 
			
		||||
  postgresql_port = "${var.postgresql_port}"
 | 
			
		||||
  postgresql_username = "${var.postgresql_username}"
 | 
			
		||||
  postgresql_password = "${var.postgresql_password}"
 | 
			
		||||
 | 
			
		||||
  services = var.services
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
provider "hcloud" {
 | 
			
		||||
  token = "${var.hcloud_token}"
 | 
			
		||||
}
 | 
			
		||||
module "infrastructure" {
 | 
			
		||||
  source = "./modules/infrastructure"
 | 
			
		||||
 | 
			
		||||
provider "ovh" {
 | 
			
		||||
  endpoint = "ovh-eu"
 | 
			
		||||
  application_key = "${var.ovh_application_key}"
 | 
			
		||||
  application_secret = "${var.ovh_application_secret}"
 | 
			
		||||
  consumer_key = "${var.ovh_consumer_key}"
 | 
			
		||||
}
 | 
			
		||||
  hcloud_token = "${var.hcloud_token}"
 | 
			
		||||
 | 
			
		||||
provider "postgresql" {
 | 
			
		||||
  host            = "${var.postgresql_host}"
 | 
			
		||||
  port            = "${var.postgresql_port}"
 | 
			
		||||
  database        = "postgres"
 | 
			
		||||
  username        = "${var.postgresql_username}"
 | 
			
		||||
  password        = "${var.postgresql_password}"
 | 
			
		||||
  sslmode         = "verify-full"
 | 
			
		||||
  connect_timeout = 15
 | 
			
		||||
}
 | 
			
		||||
  ovh_application_key = "${var.ovh_application_key}"
 | 
			
		||||
  ovh_application_secret = "${var.ovh_application_secret}"
 | 
			
		||||
  ovh_consumer_key = "${var.ovh_consumer_key}"
 | 
			
		||||
 | 
			
		||||
provider "scaleway" {
 | 
			
		||||
  organization_id = "${var.scaleway_organization_id}"
 | 
			
		||||
  project_id = "${var.scaleway_project_id}"
 | 
			
		||||
  access_key = "${var.scaleway_access_key}"
 | 
			
		||||
  secret_key = "${var.scaleway_secret_key}"
 | 
			
		||||
  region = "nl-ams"
 | 
			
		||||
  zone = "nl-ams-1"
 | 
			
		||||
}
 | 
			
		||||
  scaleway_access_key = "${var.scaleway_access_key}"
 | 
			
		||||
  scaleway_secret_key = "${var.scaleway_secret_key}"
 | 
			
		||||
  scaleway_project_id = "${var.scaleway_project_id}"
 | 
			
		||||
  scaleway_organization_id = "${var.scaleway_organization_id}"
 | 
			
		||||
 | 
			
		||||
provider "tailscale" {
 | 
			
		||||
  api_key = "${var.tailscale_api_key}"
 | 
			
		||||
  tailnet = "${var.tailscale_tailnet}"
 | 
			
		||||
}
 | 
			
		||||
  tailscale_api_key = "${var.tailscale_api_key}"
 | 
			
		||||
  tailscale_tailnet = "${var.tailscale_tailnet}"
 | 
			
		||||
 | 
			
		||||
locals {
 | 
			
		||||
  services_auth = {for key, val in var.services : key => val if val.auth}
 | 
			
		||||
  services_database = {for key, val in var.services : key => val if val.database}
 | 
			
		||||
  services_s3 = {for key, val in var.services : key => val if val.s3}
 | 
			
		||||
}
 | 
			
		||||
  default_ssh_key = "${var.default_ssh_key}"
 | 
			
		||||
 | 
			
		||||
  hosts = var.hosts
 | 
			
		||||
  services = var.services
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue