revert to old structure

This commit is contained in:
Maximilian_Schlenz 2025-07-15 12:04:25 +02:00
parent a495f53751
commit bb841ad2a3
15 changed files with 321 additions and 243 deletions

View file

@ -1,66 +1,78 @@
module "project" {
source = "../project"
name = "project-1"
organization_id = var.organization_id
owner_email = "maximilian.schlenz@stackit.cloud"
}
module "security_groups" {
source = "../security-group"
for_each = var.security_groups
project_id = var.project_id
project_id = module.project.project_id
name = each.value.name
description = each.value.description
rules = each.value.rules
}
module "postgres" {
source = "../postgres"
# module "postgres" {
# source = "../postgres"
for_each = var.postgres_instances
# for_each = var.postgres_instances
project_id = var.project_id
name = each.value.name
ver = each.value.version
flavor = each.value.flavor
storage = each.value.storage
replicas = each.value.replicas
acl = each.value.acl
backup_schedule = each.value.backup_schedule
users = each.value.users
databases = each.value.databases
}
# project_id = module.project.project_id
# name = each.value.name
# ver = each.value.version
# flavor = each.value.flavor
# storage = each.value.storage
# replicas = each.value.replicas
# acl = each.value.acl
# backup_schedule = each.value.backup_schedule
# users = each.value.users
# databases = each.value.databases
# }
module "net" {
source = "../network"
depends_on = [module.security_groups]
source = "../network"
for_each = var.networks
project_id = var.project_id
project_id = module.project.project_id
name = each.value.name
ipv4_nameservers = each.value.ipv4_nameservers
labels = each.value.labels
nic_ipv4 = each.value.nic_ipv4
nic_name = each.value.nic_name
nic_allowed_addresses = each.value.nic_allowed_addresses
nic_labels = each.value.nic_labels
nic_security = each.value.nic_security
nic_security_group_ids = each.value.nic_security_group_ids
nic_ipv4 = each.value.nic_ipv4
nic_name = each.value.nic_name
nic_allowed_addresses = each.value.nic_allowed_addresses
nic_labels = each.value.nic_labels
nic_security = each.value.nic_security
nic_security_group_ids = [
module.security_groups["ssh_ingress_group"].security_group_id,
]
}
module "ske" {
source = "../ske"
# module "ske" {
# source = "../ske"
for_each = var.ske_clusters
# for_each = var.ske_clusters
project_id = var.project_id
name = each.value.name
kubernetes_version_min = each.value.kubernetes_version_min
node_pools = each.value.node_pools
}
# project_id = module.project.project_id
# name = each.value.name
# kubernetes_version_min = each.value.kubernetes_version_min
# node_pools = each.value.node_pools
# }
module "observability" {
source = "../observability"
# module "observability" {
# source = "../observability"
for_each = var.observability_instances
project_id = var.project_id
name = each.value.name
plan_name = each.value.plan_name
}
# for_each = var.observability_instances
# project_id = module.project.project_id
# name = each.value.name
# plan_name = each.value.plan_name
# }

View file

@ -1,6 +1,7 @@
region = "eu01"
service_account_token = ""
# project_id = "b25685da-5954-4382-b654-62abd9f0ef77"
region = "eu01"
service_account_token = ""
project_id = ""
organization_id = "03a34540-3c1a-4794-b2c6-7111ecf824ef"
service_account_key_path = "/Users/schlenz/sa-key-dd5fa2c9-1651-4da7-8404-9ac4fe9bc3d5.json"
security_groups = {
@ -23,126 +24,129 @@ security_groups = {
]
},
web_traffic_group = {
name = "web-traffic-group"
description = "ALLOW WEB TRAFFIC ingress"
rules = [
{ description = "ALLOW ALL 80"
direction = "ingress"
ether_type = "IPv4"
ip_range = "0.0.0.0/0"
protocol = {
name = "tcp"
}
port_range = {
min = 80
max = 80
}
},
{ description = "ALLOW ALL 443"
direction = "ingress"
ether_type = "IPv4"
ip_range = "0.0.0.0/0"
protocol = {
name = "tcp"
}
port_range = {
min = 443
max = 443
}
},
]
},
# web_traffic_group = {
# name = "web-traffic-group"
# description = "ALLOW WEB TRAFFIC ingress"
# rules = [
# { description = "ALLOW ALL 80"
# direction = "ingress"
# ether_type = "IPv4"
# ip_range = "0.0.0.0/0"
# protocol = {
# name = "tcp"
# }
# port_range = {
# min = 80
# max = 80
# }
# },
# { description = "ALLOW ALL 443"
# direction = "ingress"
# ether_type = "IPv4"
# ip_range = "0.0.0.0/0"
# protocol = {
# name = "tcp"
# }
# port_range = {
# min = 443
# max = 443
# }
# },
# ]
# },
}
postgres_instances = {
dev = {
name = "pg-test-instance"
version = 17
flavor = {
cpu = 2,
ram = 4
}
storage = {
class = "premium-perf6-stackit",
size = 20
}
replicas = 1
acl = ["0.0.0.0/0"]
backup_schedule = "00 00 * * *"
# postgres_instances = {
# dev = {
# name = "pg-test-instance"
# version = 17
# flavor = {
# cpu = 2,
# ram = 4
# }
# storage = {
# class = "premium-perf6-stackit",
# size = 20
# }
# replicas = 1
# acl = ["0.0.0.0/0"]
# backup_schedule = "00 00 * * *"
users = [
{ username = "admin",
roles = ["login", "createdb"]
},
{ username = "testusr",
roles = ["login"]
}
]
# users = [
# { username = "admin",
# roles = ["login", "createdb"]
# },
# { username = "testusr",
# roles = ["login"]
# }
# ]
databases = [
{
name = "test_db",
owner = "admin"
}
]
}
}
# databases = [
# {
# name = "test_db",
# owner = "admin"
# }
# ]
# }
# }
networks = {
web = {
name = "web-net"
ipv4_nameservers = ["1.1.1.1", "8.8.8.8"]
labels = {
env = "prod"
}
}
# web = {
# name = "web-net"
# ipv4_nameservers = ["1.1.1.1", "8.8.8.8"]
# labels = {
# env = "prod"
# }
# }
db = {
name = "db-net"
nic_ipv4 = "10.0.2.120"
nic_security = false
nic_ipv4 = "10.0.0.126"
nic_security = true
security_groups = {
}
}
}
ske_clusters = {
dev = {
name = "dev-cluster"
kubernetes_version_min = "1.31"
node_pools = [
{ name = "default"
machine_type = "c2.1"
availability_zones = ["eu01-1", "eu01-2"]
volume_size = 40
minimum = 1
maximum = 3
}
]
}
# ske_clusters = {
# dev = {
# name = "dev-cluster"
# kubernetes_version_min = "1.31"
# node_pools = [
# { name = "default"
# machine_type = "c2.1"
# availability_zones = ["eu01-1", "eu01-2"]
# volume_size = 40
# minimum = 1
# maximum = 3
# }
# ]
# }
staging = {
name = "staging-cluster"
kubernetes_version_min = "1.31"
node_pools = [
{ name = "general"
machine_type = "c2.2"
availability_zones = ["eu03-1", "eu03-2"]
volume_size = 80
minimum = 2
maximum = 4
}
]
}
}
# staging = {
# name = "staging-cluster"
# kubernetes_version_min = "1.31"
# node_pools = [
# { name = "general"
# machine_type = "c2.2"
# availability_zones = ["eu03-1", "eu03-2"]
# volume_size = 80
# minimum = 2
# maximum = 4
# }
# ]
# }
# }
observability_instances = {
starter = {
name = "Observability-1"
plan_name = "Observability-Starter-EU01"
}
# observability_instances = {
# starter = {
# name = "Observability-1"
# plan_name = "Observability-Starter-EU01"
# }
prod = {
name = "Observability-2"
plan_name = "Observability-Large-EU01"
}
}
# prod = {
# name = "Observability-2"
# plan_name = "Observability-Large-EU01"
# }
# }

View file

@ -20,6 +20,17 @@ variable "service_account_key_path" {
default = ""
}
variable "organization_id" {
description = "Organization ID"
type = string
}
variable "owner_email" {
description = "Email of the project owner"
type = string
default = null
}
variable "security_groups" {
type = map(object({
name = optional(string)
@ -46,25 +57,25 @@ variable "security_groups" {
}))
}
variable "postgres_instances" {
type = map(object({
name = string
version = number
flavor = object({ cpu = number, ram = number })
storage = object({ class = string, size = number })
replicas = number
acl = list(string)
backup_schedule = string
users = list(object({
username = string
roles = set(string)
}))
databases = list(object({
name = string
owner = string
}))
}))
}
# variable "postgres_instances" {
# type = map(object({
# name = string
# version = number
# flavor = object({ cpu = number, ram = number })
# storage = object({ class = string, size = number })
# replicas = number
# acl = list(string)
# backup_schedule = string
# users = list(object({
# username = string
# roles = set(string)
# }))
# databases = list(object({
# name = string
# owner = string
# }))
# }))
# }
variable "networks" {
type = map(object({
@ -74,7 +85,7 @@ variable "networks" {
labels = optional(map(string))
nic_ipv4 = optional(string)
nic_name = optional(string)
nic_name = optional(string)
nic_allowed_addresses = optional(list(string))
nic_labels = optional(map(string))
@ -83,24 +94,24 @@ variable "networks" {
}))
}
variable "ske_clusters" {
type = map(object({
name = string
kubernetes_version_min = string
node_pools = list(object({
name = string
machine_type = string
availability_zones = list(string)
volume_size = number
minimum = number
maximum = number
}))
}))
}
# variable "ske_clusters" {
# type = map(object({
# name = string
# kubernetes_version_min = string
# node_pools = list(object({
# name = string
# machine_type = string
# availability_zones = list(string)
# volume_size = number
# minimum = number
# maximum = number
# }))
# }))
# }
variable "observability_instances" {
type = map(object({
name = string
plan_name = string
}))
}
# variable "observability_instances" {
# type = map(object({
# name = string
# plan_name = string
# }))
# }