module "network_public" { source = "../../modules/network_public" region = var.region name_prefix = var.name_prefix protect_from_destroy = false vpc = { cidr_block = "10.254.0.0/16" tags = { Name = "${var.name_prefix}-vpc" } } subnets = { intra_a = { cidr_block = "10.254.110.0/24" availability_zone = "ap-northeast-3a" tags = { Name = "${var.name_prefix}-intra-a" } } dmz = { cidr_block = "10.254.1.0/24" availability_zone = "ap-northeast-3b" tags = { Name = "${var.name_prefix}-dmz" } } intra_d = { cidr_block = "10.254.120.0/24" availability_zone = "ap-northeast-3c" tags = { Name = "${var.name_prefix}-intra-c" } } } route_table_tags = { dmz = { Name = "${var.name_prefix}-dmz-routes" } intra = { Name = "${var.name_prefix}-intra-routes" } } internet_gateway_tags = { Name = "${var.name_prefix}-igw" } route_destinations = { private_network_a = "192.0.2.0/24" private_network_b = "198.51.100.0/24" } vyos_network_interface_id = aws_network_interface.route_target.id vyos_security_group_id = aws_security_group.vyos_source.id dhcp_options = { domain_name = "${var.region}.compute.internal" domain_name_servers = ["AmazonProvidedDNS"] tags = { Name = "${var.name_prefix}-dhcp" } } ssh_security_group = { description = "${var.name_prefix} public test security group" } ssh_ingress_rules = { icmp_private = { description = "ICMP test network" ip_protocol = "icmp" cidr_ipv4 = "203.0.113.0/24" } icmp_vyos = { description = "ICMP from VyOS" ip_protocol = "icmp" use_vyos_security_group = true } ssh_vyos = { description = "SSH from VyOS" ip_protocol = "tcp" from_port = 22 to_port = 22 use_vyos_security_group = true } http = { description = "HTTP" ip_protocol = "tcp" from_port = 80 to_port = 80 cidr_ipv4 = "0.0.0.0/0" } https = { description = "HTTPS" ip_protocol = "tcp" from_port = 443 to_port = 443 cidr_ipv4 = "0.0.0.0/0" } http3 = { description = "HTTP/3" ip_protocol = "udp" from_port = 443 to_port = 443 cidr_ipv4 = "0.0.0.0/0" } consul_server = { description = "Consul server from VyOS" ip_protocol = "tcp" from_port = 8300 to_port = 8300 use_vyos_security_group = true } consul_lan_tcp = { description = "Consul LAN TCP from VyOS" ip_protocol = "tcp" from_port = 8301 to_port = 8301 use_vyos_security_group = true } consul_lan_udp = { description = "Consul LAN UDP from VyOS" ip_protocol = "udp" from_port = 8301 to_port = 8301 use_vyos_security_group = true } ssh_admin = { description = "SSH test network" ip_protocol = "tcp" from_port = 22 to_port = 22 cidr_ipv4 = "203.0.113.0/24" } ssh_git = { description = "SSH alternate port test network" ip_protocol = "tcp" from_port = 3843 to_port = 3843 cidr_ipv4 = "203.0.113.0/24" } wireguard = { description = "WireGuard" ip_protocol = "udp" from_port = 51820 to_port = 51820 cidr_ipv4 = "0.0.0.0/0" } prometheus = { description = "Prometheus from VyOS" ip_protocol = "tcp" from_port = 60000 to_port = 60000 use_vyos_security_group = true } } web_instance = { ami = var.web_ami_id instance_type = "t3.small" subnet_key = "dmz" associate_public_ip_address = true source_dest_check = true ebs_optimized = true monitoring = false metadata_options = { http_endpoint = "enabled" http_tokens = "required" http_put_response_hop_limit = 2 http_protocol_ipv6 = "disabled" instance_metadata_tags = "disabled" } root_block_device = { delete_on_termination = true encrypted = true volume_size = 8 volume_type = "gp3" iops = 3000 throughput = 125 } tags = { Purpose = "${var.name_prefix}-web-test" } } key_pair = { public_key = var.test_public_key } # These syntactically valid, isolated ARNs are never used by AWS in tests: # both Flow Log resources are explicitly overridden in each test file. flow_logs = { s3 = { destination_arn = "arn:aws:s3:::${var.name_prefix}-flow-logs" tags = { Name = "${var.name_prefix}-s3-flow-log" } } cloudwatch = { log_group_arn = "arn:aws:logs:${var.region}:${var.account_id}:log-group:/${var.name_prefix}/flowlogs" iam_role_arn = "arn:aws:iam::${var.account_id}:role/${var.name_prefix}-flow-logs" tags = { Name = "${var.name_prefix}-cloudwatch-flow-log" } } } } resource "aws_security_group" "vyos_source" { region = var.region name = "${var.name_prefix}-vyos-source" description = "Empty substitute for VyOS source references" vpc_id = module.network_public.vpc_id tags = { Name = "${var.name_prefix}-vyos-source" } } resource "aws_network_interface" "route_target" { region = var.region subnet_id = module.network_public.subnet_ids["dmz"] security_groups = [aws_security_group.vyos_source.id] tags = { Name = "${var.name_prefix}-route-target" } }