Files

204 lines
6.8 KiB
Terraform

variable "region" {
description = "AWS region for the managed network and public path."
type = string
}
variable "name_prefix" {
description = "Prefix used for isolated copies when an explicit production name is omitted."
type = string
}
variable "protect_from_destroy" {
description = "Protect VPC, subnets, internet gateway, route tables, and web instance from destroy. prod は true 固定。既存 workspace で true→false に反転しない。"
type = bool
default = true
}
variable "vpc" {
description = "Existing VPC configuration."
type = object({
cidr_block = string
enable_dns_support = optional(bool, true)
enable_dns_hostnames = optional(bool, true)
tags = optional(map(string), {})
})
}
variable "subnets" {
description = "Subnets keyed by a stable logical name."
type = map(object({
cidr_block = string
availability_zone = string
map_public_ip_on_launch = optional(bool, false)
assign_ipv6_address_on_creation = optional(bool, false)
enable_dns64 = optional(bool, false)
private_dns_hostname_type_on_launch = optional(string, "ip-name")
enable_resource_name_dns_a_record_on_launch = optional(bool, false)
enable_resource_name_dns_aaaa_record_on_launch = optional(bool, false)
tags = optional(map(string), {})
}))
}
variable "route_table_tags" {
description = "Tags for the main DMZ and custom intra route tables."
type = object({
dmz = optional(map(string), {})
intra = optional(map(string), {})
})
default = {}
}
variable "internet_gateway_tags" {
description = "Tags on the existing internet gateway."
type = map(string)
default = {}
}
variable "route_destinations" {
description = "Existing route destinations. Values must stay aligned with the production route tables."
type = object({
private_network_a = string
private_network_b = string
default_ipv4 = optional(string, "0.0.0.0/0")
})
}
variable "vyos_network_interface_id" {
description = "Existing VyOS primary ENI referenced by routes. The VyOS instance itself is managed separately."
type = string
}
variable "vyos_security_group_id" {
description = "Existing VyOS security group referenced as a source. The group itself is managed separately."
type = string
}
variable "dhcp_options" {
description = "Existing VPC DHCP options."
type = object({
domain_name = string
domain_name_servers = list(string)
tags = optional(map(string), {})
})
}
variable "ssh_security_group" {
description = "Existing security group used by the public web instance."
type = object({
name = optional(string)
description = string
tags = optional(map(string), {})
})
}
variable "ssh_ingress_rules" {
description = "Ingress rules for the web security group, one source per resource."
type = map(object({
description = optional(string)
ip_protocol = string
from_port = optional(number)
to_port = optional(number)
cidr_ipv4 = optional(string)
use_vyos_security_group = optional(bool, false)
}))
}
variable "web_egress_policy" {
description = "Restricted outbound ports for the public web instance. Homelab destinations are the two VyOS route CIDRs; public TCP destinations use IPv4 any-address."
type = object({
homelab_tcp_ports = set(number)
homelab_udp_ports = set(number)
public_tcp_ports = set(number)
})
validation {
condition = alltrue([
for port in setunion(
var.web_egress_policy.homelab_tcp_ports,
var.web_egress_policy.homelab_udp_ports,
var.web_egress_policy.public_tcp_ports,
) : port >= 1 && port <= 65535 && port == floor(port)
])
error_message = "Every web egress port must be an integer from 1 through 65535."
}
}
variable "web_egress_service_rules" {
description = "Additional public-web egress rules for services on a single explicit destination CIDR."
type = map(object({
description = string
ip_protocol = string
port = number
cidr_ipv4 = string
}))
validation {
condition = alltrue([
for rule in values(var.web_egress_service_rules) :
contains(["tcp", "udp"], rule.ip_protocol) &&
rule.port >= 1 && rule.port <= 65535 && rule.port == floor(rule.port) &&
trimspace(rule.description) != "" &&
can(cidrnetmask(rule.cidr_ipv4))
])
error_message = "Every service egress rule must have a description, TCP or UDP protocol, an integer port from 1 through 65535, and a valid IPv4 CIDR."
}
}
variable "web_instance" {
description = "Existing public web EC2 instance. user_data is intentionally absent."
type = object({
name = optional(string)
ami = string
instance_type = string
subnet_key = string
associate_public_ip_address = optional(bool, true)
source_dest_check = optional(bool, true)
ebs_optimized = optional(bool, false)
monitoring = optional(bool, false)
metadata_options = object({
http_endpoint = string
http_tokens = string
http_put_response_hop_limit = number
http_protocol_ipv6 = string
instance_metadata_tags = string
})
root_block_device = object({
delete_on_termination = bool
encrypted = bool
volume_size = number
volume_type = string
iops = optional(number)
throughput = optional(number)
})
tags = optional(map(string), {})
})
}
variable "key_pair" {
description = "Existing EC2 key pair. Public key material is not secret; private key material is never handled."
type = object({
name = optional(string)
public_key = string
tags = optional(map(string), {})
})
}
variable "flow_logs" {
description = "Existing VPC Flow Log destinations managed by previously imported modules."
type = object({
s3 = object({
destination_arn = string
traffic_type = optional(string, "ALL")
max_aggregation_interval = optional(number, 60)
tags = optional(map(string), {})
})
cloudwatch = object({
log_group_arn = string
iam_role_arn = string
traffic_type = optional(string, "ALL")
max_aggregation_interval = optional(number, 600)
tags = optional(map(string), {})
})
})
}