- Integrated additional Zod validation schemas for improved input validation across various API routes. - Updated existing services to utilize the new validation middleware, ensuring better request integrity. - Improved error handling mechanisms in key services to provide clearer feedback on request failures. - Conducted code cleanup to enhance readability and maintainability of the API services.
369 lines
8.8 KiB
HCL
369 lines
8.8 KiB
HCL
# Terraform configuration for Cloudflare DNS records
|
|
#
|
|
# Prerequisites:
|
|
# - Terraform installed (https://www.terraform.io/)
|
|
# - Cloudflare provider configured
|
|
# - Cloudflare API token with DNS:Edit permissions
|
|
#
|
|
# Usage:
|
|
# terraform init
|
|
# terraform plan
|
|
# terraform apply
|
|
#
|
|
|
|
terraform {
|
|
required_providers {
|
|
cloudflare = {
|
|
source = "cloudflare/cloudflare"
|
|
version = "~> 4.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Configure the Cloudflare Provider
|
|
provider "cloudflare" {
|
|
api_token = var.cloudflare_api_token
|
|
}
|
|
|
|
# Get zone ID
|
|
data "cloudflare_zones" "d_bis_org" {
|
|
filter {
|
|
name = "d-bis.org"
|
|
}
|
|
}
|
|
|
|
# Variables
|
|
variable "cloudflare_api_token" {
|
|
description = "Cloudflare API token"
|
|
type = string
|
|
sensitive = true
|
|
}
|
|
|
|
variable "production_api_ip" {
|
|
description = "Production REST API IPv4 address"
|
|
type = string
|
|
default = "192.0.2.1"
|
|
}
|
|
|
|
variable "production_api_ipv6" {
|
|
description = "Production REST API IPv6 address"
|
|
type = string
|
|
default = "2001:db8::1"
|
|
}
|
|
|
|
variable "production_mappings_ip" {
|
|
description = "Production Mapping Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.2"
|
|
}
|
|
|
|
variable "production_mappings_ipv6" {
|
|
description = "Production Mapping Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::2"
|
|
}
|
|
|
|
variable "production_webhooks_ip" {
|
|
description = "Production Webhook Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.3"
|
|
}
|
|
|
|
variable "production_webhooks_ipv6" {
|
|
description = "Production Webhook Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::3"
|
|
}
|
|
|
|
variable "production_orchestrator_ip" {
|
|
description = "Production Orchestrator Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.4"
|
|
}
|
|
|
|
variable "production_orchestrator_ipv6" {
|
|
description = "Production Orchestrator Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::4"
|
|
}
|
|
|
|
variable "production_packets_ip" {
|
|
description = "Production Packet Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.5"
|
|
}
|
|
|
|
variable "production_packets_ipv6" {
|
|
description = "Production Packet Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::5"
|
|
}
|
|
|
|
variable "staging_api_ip" {
|
|
description = "Staging REST API IPv4 address"
|
|
type = string
|
|
default = "192.0.2.10"
|
|
}
|
|
|
|
variable "staging_api_ipv6" {
|
|
description = "Staging REST API IPv6 address"
|
|
type = string
|
|
default = "2001:db8::10"
|
|
}
|
|
|
|
variable "staging_mappings_ip" {
|
|
description = "Staging Mapping Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.11"
|
|
}
|
|
|
|
variable "staging_mappings_ipv6" {
|
|
description = "Staging Mapping Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::11"
|
|
}
|
|
|
|
variable "staging_webhooks_ip" {
|
|
description = "Staging Webhook Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.12"
|
|
}
|
|
|
|
variable "staging_webhooks_ipv6" {
|
|
description = "Staging Webhook Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::12"
|
|
}
|
|
|
|
variable "staging_orchestrator_ip" {
|
|
description = "Staging Orchestrator Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.13"
|
|
}
|
|
|
|
variable "staging_orchestrator_ipv6" {
|
|
description = "Staging Orchestrator Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::13"
|
|
}
|
|
|
|
variable "staging_packets_ip" {
|
|
description = "Staging Packet Service IPv4 address"
|
|
type = string
|
|
default = "192.0.2.14"
|
|
}
|
|
|
|
variable "staging_packets_ipv6" {
|
|
description = "Staging Packet Service IPv6 address"
|
|
type = string
|
|
default = "2001:db8::14"
|
|
}
|
|
|
|
# Production DNS Records
|
|
# ======================
|
|
|
|
# Production REST API
|
|
resource "cloudflare_record" "api_production_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "api"
|
|
type = "A"
|
|
value = var.production_api_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "api_production_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "api"
|
|
type = "AAAA"
|
|
value = var.production_api_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Production Mapping Service
|
|
resource "cloudflare_record" "mappings_production_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "mappings.api"
|
|
type = "A"
|
|
value = var.production_mappings_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "mappings_production_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "mappings.api"
|
|
type = "AAAA"
|
|
value = var.production_mappings_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Production Webhook Service
|
|
resource "cloudflare_record" "webhooks_production_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "webhooks.api"
|
|
type = "A"
|
|
value = var.production_webhooks_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "webhooks_production_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "webhooks.api"
|
|
type = "AAAA"
|
|
value = var.production_webhooks_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Production Orchestrator Service
|
|
resource "cloudflare_record" "orchestrator_production_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "orchestrator.api"
|
|
type = "A"
|
|
value = var.production_orchestrator_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "orchestrator_production_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "orchestrator.api"
|
|
type = "AAAA"
|
|
value = var.production_orchestrator_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Production Packet Service
|
|
resource "cloudflare_record" "packets_production_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "packets.api"
|
|
type = "A"
|
|
value = var.production_packets_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "packets_production_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "packets.api"
|
|
type = "AAAA"
|
|
value = var.production_packets_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Staging DNS Records
|
|
# ===================
|
|
|
|
# Staging REST API
|
|
resource "cloudflare_record" "api_staging_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "api-staging"
|
|
type = "A"
|
|
value = var.staging_api_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "api_staging_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "api-staging"
|
|
type = "AAAA"
|
|
value = var.staging_api_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Staging Mapping Service
|
|
resource "cloudflare_record" "mappings_staging_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "mappings.api-staging"
|
|
type = "A"
|
|
value = var.staging_mappings_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "mappings_staging_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "mappings.api-staging"
|
|
type = "AAAA"
|
|
value = var.staging_mappings_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Staging Webhook Service
|
|
resource "cloudflare_record" "webhooks_staging_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "webhooks.api-staging"
|
|
type = "A"
|
|
value = var.staging_webhooks_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "webhooks_staging_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "webhooks.api-staging"
|
|
type = "AAAA"
|
|
value = var.staging_webhooks_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Staging Orchestrator Service
|
|
resource "cloudflare_record" "orchestrator_staging_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "orchestrator.api-staging"
|
|
type = "A"
|
|
value = var.staging_orchestrator_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "orchestrator_staging_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "orchestrator.api-staging"
|
|
type = "AAAA"
|
|
value = var.staging_orchestrator_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Staging Packet Service
|
|
resource "cloudflare_record" "packets_staging_a" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "packets.api-staging"
|
|
type = "A"
|
|
value = var.staging_packets_ip
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "packets_staging_aaaa" {
|
|
zone_id = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
name = "packets.api-staging"
|
|
type = "AAAA"
|
|
value = var.staging_packets_ipv6
|
|
ttl = 1 # Auto
|
|
proxied = true
|
|
}
|
|
|
|
# Outputs
|
|
output "zone_id" {
|
|
description = "Cloudflare Zone ID"
|
|
value = data.cloudflare_zones.d_bis_org.zones[0].id
|
|
}
|
|
|
|
output "zone_name" {
|
|
description = "Cloudflare Zone Name"
|
|
value = data.cloudflare_zones.d_bis_org.zones[0].name
|
|
}
|
|
|