feat: general refactor

main
Ricard Illa 2023-07-04 16:03:41 +02:00
parent d9ffa00b03
commit d237e56a02
7 changed files with 45 additions and 89 deletions

58
main.tf
View File

@ -9,23 +9,51 @@ terraform {
skip_metadata_api_check = true
skip_region_validation = true
}
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.20.0"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.9.0"
}
minio = {
source = "aminueza/minio"
version = ">= 1.15.2"
}
linode = {
source = "linode/linode"
version = ">= 1.29.0"
}
hetznerdns = {
source = "timohirt/hetznerdns"
version = ">=2.2.0"
}
postgresql = {
source = "cyrilgdn/postgresql"
version = ">= 1.19.0"
}
}
}
#module "cert-manager" {
# source = "./modules/cert-manager"
# hetzner_token = var.hetzner_token
# email = var.email
# zone_name = var.zone_name
# dns_common_name = var.dns_common_name
# dns_names = var.dns_names
#}
provider "kubernetes" {
config_path = "~/.kube/config"
}
module "postgresql" {
source = "./modules/postgresql"
host = "pg.monotremata.xyz"
password = var.pg_passwd
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
}
}
provider "minio" {
minio_ssl = true
}
provider "postgresql" {
username = "terraform"
db_owner = "rilla"
password = var.pg_passwd
}
module "dns" {
@ -82,4 +110,8 @@ module "minio" {
module "minio_buckets" {
source = "./modules/minio_buckets"
providers = {
minio = minio
}
depends_on = [module.minio]
}

View File

@ -11,16 +11,6 @@ terraform {
}
}
provider "kubernetes" {
config_path = "~/.kube/config"
}
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
}
}
resource "helm_release" "cert-manager" {
name = "cert-manager"
chart = "cert-manager"
@ -56,40 +46,6 @@ resource "kubernetes_secret" "hetzner-token" {
}
}
#resource "kubernetes_manifest" "clusterissuer_letsencrypt_staging" {
# manifest = {
# apiVersion = "cert-manager.io/v1"
# kind = "ClusterIssuer"
# metadata = {
# name = "letsencrypt-staging"
# }
# spec = {
# acme = {
# email = var.email
# privateKeySecretRef = {
# name = "letsencrypt-staging-account-key"
# }
# server = var.letsencrypt_servers.staging
# solvers = [
# {
# dns01 = {
# webhook = {
# config = {
# apiUrl = var.hetzner_dns_api
# secretName = kubernetes_secret.hetzner-token.metadata[0].name
# zoneName = var.zone_name
# }
# groupName = var.group_name
# solverName = "hetzner"
# }
# }
# }
# ]
# }
# }
# }
#}
resource "kubernetes_manifest" "clusterissuer_letsencrypt" {
manifest = {
apiVersion = "cert-manager.io/v1"

View File

@ -7,10 +7,6 @@ terraform {
}
}
provider "kubernetes" {
config_path = "~/.kube/config"
}
# terraform import module.minio.kubernetes_namespace.minio_namespace minio
resource "kubernetes_namespace" "minio_namespace" {
metadata {

View File

@ -7,10 +7,6 @@ terraform {
}
}
provider "minio" {
minio_ssl = true
}
resource "minio_s3_bucket" "state_terraform_s3" {
bucket = "terraform"
acl = "private"

View File

@ -7,13 +7,6 @@ terraform {
}
}
provider "postgresql" {
host = var.host
port = var.port
username = var.username
password = var.password
}
resource "postgresql_database" "terraform_backend_db" {
name = "terraform_backend"
owner = var.db_owner

View File

@ -1,14 +1,3 @@
variable "host" {
type = string
description = "postgresql host"
}
variable "port" {
type = number
description = "postgresql post"
default = 5432
}
variable "password" {
type = string
description = "postgresql password"

View File

@ -1,9 +1,3 @@
#variable "hetzner_token" {
# type = string
# description = "hetzner dns token"
# sensitive = true
#}
variable "email" {
type = string
description = "email for letsencrypt registration"