01a: update Linode Terraform for provider v2

- Update all modules to use Linode provider v2 (linode/linode ~> 2.0)
- Replace deprecated cluster attribute with region in all modules
- Update firewall to use ipv4/ipv6 instead of cidrs (TCP/UDP protocols)
- Update LKE endpoint output to use api_endpoints[0] instead of deprecated hostname
- Add OBJECT_STORAGE_CLUSTER variable for object storage configuration
- Update Makefile with new variables and validate target
- Add storage/outputs.tf for standardized object storage outputs
- Update .env and .env.example with clean format (no inline comments)
- Update all terraform.tfvars.example files for consistency
This commit is contained in:
Bobby committed 2026-11-17 22:09:31 -05:00
1 parent 341cd05ac5
commit 494f38c1f3
17 files changed
+285 -203

No files matched your search

+76 -68
View File
@@ -1,89 +1,97 @@
# Networking module for HAPI
# Creates firewall rules for API, PostgreSQL, and Adminer
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "~> 2.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.0"
}
}
}
resource "linode_firewall" "hapi" {
label = "hapi-firewall"
tags = var.tags
label = "hapi-firewall-${var.environment}"
tags = toset([for k, v in var.tags : "${k}=${v}"])
# Inbound policy
inbound_policy = "DROP"
# Outbound policy
outbound_policy = "DROP"
# Inbound rules
inbound = [
{
label = "allow-api"
protocol = "tcp"
ports = "8000"
cidrs = ["0.0.0.0/0", "::/0"]
},
{
label = "allow-postgres"
protocol = "tcp"
ports = "5432"
cidrs = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
},
{
label = "allow-adminer"
protocol = "tcp"
ports = "8080"
cidrs = ["0.0.0.0/0", "::/0"]
},
{
label = "allow-https"
protocol = "tcp"
ports = "443"
cidrs = ["0.0.0.0/0", "::/0"]
},
{
label = "allow-http"
protocol = "tcp"
ports = "80"
cidrs = ["0.0.0.0/0", "::/0"]
}
]
inbound {
action = "ACCEPT"
label = "allow-api-${var.environment}"
protocol = "TCP"
ports = "8000"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
inbound {
action = "ACCEPT"
label = "allow-postgres-${var.environment}"
protocol = "TCP"
ports = "5432"
ipv4 = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
}
inbound {
action = "ACCEPT"
label = "allow-adminer-${var.environment}"
protocol = "TCP"
ports = "8080"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
inbound {
action = "ACCEPT"
label = "allow-https-${var.environment}"
protocol = "TCP"
ports = "443"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
inbound {
action = "ACCEPT"
label = "allow-http-${var.environment}"
protocol = "TCP"
ports = "80"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
# Outbound rules
outbound = [
{
label = "allow-all-outbound"
protocol = "tcp"
ports = "0-65535"
cidrs = ["0.0.0.0/0", "::/0"]
}
]
}
resource "linode_firewall_rule" "api_health" {
for_each = toset(["staging", "production"])
firewall_id = linode_firewall.hapi.id
label = "api-health-${each.key}"
direction = "inbound"
protocol = "tcp"
ports = "8000"
cidrs = ["0.0.0.0/0", "::/0"]
}
resource "linode_firewall_rule" "adminer_access" {
for_each = toset(["staging", "production"])
firewall_id = linode_firewall.hapi.id
label = "adminer-${each.key}"
direction = "inbound"
protocol = "tcp"
ports = "8080"
cidrs = ["0.0.0.0/0", "::/0"]
outbound {
action = "ACCEPT"
label = "allow-all-outbound-${var.environment}"
protocol = "TCP"
ports = "0-65535"
ipv4 = ["0.0.0.0/0"]
ipv6 = ["::/0"]
}
}
# Firewall rule configurations
locals {
firewall_config = {
staging = {
api_port = 8000
api_port = 8000
postgres_port = 5432
adminer_port = 8080
adminer_port = 8080
}
production = {
api_port = 8000
api_port = 8000
postgres_port = 5432
adminer_port = 8080
adminer_port = 8080
}
}
}
+5 -3
View File
@@ -1,3 +1,5 @@
# Network module variables
linode_region = "us-east"
environment = "staging"
# Network module example configuration
linode_region = "us-east"
linode_object_storage_cluster = "us-east-1"
environment = "staging"
+6
View File
@@ -15,6 +15,12 @@ variable "tags" {
}
}
variable "linode_object_storage_cluster" {
description = "Linode Object Storage cluster for backend state storage"
type = string
default = "us-east-1"
}
variable "environment" {
description = "Deployment environment (staging or production)"
type = string