diff --git a/tests/network_group3_4/.terraform.lock.hcl b/tests/network_group3/.terraform.lock.hcl similarity index 100% rename from tests/network_group3_4/.terraform.lock.hcl rename to tests/network_group3/.terraform.lock.hcl diff --git a/tests/network_group3_4/apply-tests/osaka_apply.tftest.hcl b/tests/network_group3/apply-tests/osaka_apply.tftest.hcl similarity index 67% rename from tests/network_group3_4/apply-tests/osaka_apply.tftest.hcl rename to tests/network_group3/apply-tests/osaka_apply.tftest.hcl index f23d0dc..2488160 100644 --- a/tests/network_group3_4/apply-tests/osaka_apply.tftest.hcl +++ b/tests/network_group3/apply-tests/osaka_apply.tftest.hcl @@ -1,6 +1,5 @@ # This file is intentionally outside the default tests/ directory. -# Do not run it without the required approval and an existing Marketplace -# subscription for the selected VyOS AMI. +# Do not run it without confirmation of the standing B4 approval conditions. provider "aws" { region = var.region @@ -18,32 +17,26 @@ override_resource { variables { region = "ap-northeast-3" - name_prefix = "tftest-g34-8c2f" + name_prefix = "tftest-g3-8c2f" web_ami_id = "ami-0d82c759aab529d2d" - vyos_ami_id = "ami-096d9368e5980d5fb" - test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g34-8c2f" + test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g3-8c2f" } -run "apply_network_group3_4_osaka" { +run "apply_network_group3_osaka" { command = apply - assert { - condition = !output.vyos_source_dest_check - error_message = "The Osaka VyOS instance must disable source/destination checking." - } - assert { condition = length(output.vyos_route_network_interface_ids) == 5 && alltrue([ - for id in values(output.vyos_route_network_interface_ids) : id == output.vyos_primary_network_interface_id + for id in values(output.vyos_route_network_interface_ids) : id == output.route_target_network_interface_id ]) - error_message = "All five VyOS routes must target the created VyOS primary ENI." + error_message = "All five VyOS routes must target the created substitute network interface." } assert { condition = length(output.vyos_source_security_group_ids) == 6 && alltrue([ - for id in values(output.vyos_source_security_group_ids) : id == output.vyos_security_group_id + for id in values(output.vyos_source_security_group_ids) : id == output.vyos_source_security_group_id ]) - error_message = "All six public ingress rules must reference the created VyOS security group." + error_message = "All six public ingress rules must reference the created substitute security group." } assert { diff --git a/tests/network_group3_4/main.tf b/tests/network_group3/main.tf similarity index 71% rename from tests/network_group3_4/main.tf rename to tests/network_group3/main.tf index ee9b638..6a2e329 100644 --- a/tests/network_group3_4/main.tf +++ b/tests/network_group3/main.tf @@ -40,8 +40,8 @@ module "network_public" { private_network_b = "198.51.100.0/24" } - vyos_network_interface_id = module.network_vyos.primary_network_interface_id - vyos_security_group_id = module.network_vyos.security_group_id + 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" @@ -191,80 +191,21 @@ module "network_public" { } } -module "network_vyos" { - source = "../../modules/network_vyos" +resource "aws_security_group" "vyos_source" { + region = var.region - region = var.region - name_prefix = var.name_prefix - protect_from_destroy = false + name = "${var.name_prefix}-vyos-source" + description = "Empty substitute for VyOS source references" + vpc_id = module.network_public.vpc_id - vpc_id = module.network_public.vpc_id - subnet_id = module.network_public.subnet_ids["dmz"] - key_name = module.network_public.key_pair_name + tags = { Name = "${var.name_prefix}-vyos-source" } +} - security_group = { - description = "${var.name_prefix} VyOS test security group" - } +resource "aws_network_interface" "route_target" { + region = var.region - ingress_rules = { - vpc_all = { - ip_protocol = "-1" - cidr_ipv4 = "10.254.0.0/16" - } - mosh = { - description = "Allow mosh" - ip_protocol = "udp" - from_port = 60000 - to_port = 61000 - cidr_ipv4 = "0.0.0.0/0" - } - home_all = { - description = "Test network" - ip_protocol = "-1" - cidr_ipv4 = "203.0.113.0/24" - } - ssh = { - description = "Allow SSH" - ip_protocol = "tcp" - from_port = 22 - to_port = 22 - cidr_ipv4 = "203.0.113.0/24" - } - wireguard = { - description = "Allow WireGuard" - ip_protocol = "udp" - from_port = 51820 - to_port = 51820 - cidr_ipv4 = "0.0.0.0/0" - } - } + subnet_id = module.network_public.subnet_ids["dmz"] + security_groups = [aws_security_group.vyos_source.id] - instance = { - ami = var.vyos_ami_id - instance_type = "t3.small" - private_ip = "10.254.1.10" - associate_public_ip_address = true - source_dest_check = false - ebs_optimized = true - monitoring = false - - metadata_options = { - http_endpoint = "enabled" - http_tokens = "required" - http_put_response_hop_limit = 1 - http_protocol_ipv6 = "disabled" - instance_metadata_tags = "disabled" - } - - root_block_device = { - delete_on_termination = true - encrypted = true - volume_size = 4 - volume_type = "gp3" - iops = 3000 - throughput = 125 - } - - tags = { Purpose = "${var.name_prefix}-vyos-test" } - } + tags = { Name = "${var.name_prefix}-route-target" } } diff --git a/tests/network_group3/outputs.tf b/tests/network_group3/outputs.tf new file mode 100644 index 0000000..0337003 --- /dev/null +++ b/tests/network_group3/outputs.tf @@ -0,0 +1,25 @@ +output "route_target_network_interface_id" { + value = aws_network_interface.route_target.id +} + +output "vyos_source_security_group_id" { + value = aws_security_group.vyos_source.id +} + +output "vyos_route_network_interface_ids" { + value = module.network_public.vyos_route_network_interface_ids +} + +output "vyos_source_security_group_ids" { + value = module.network_public.vyos_source_security_group_ids +} + +output "named_resources" { + value = merge( + module.network_public.named_resource_names, + { + route_target_network_interface = aws_network_interface.route_target.tags["Name"] + vyos_source_security_group = aws_security_group.vyos_source.name + }, + ) +} diff --git a/tests/network_group3_4/tests/osaka_plan.tftest.hcl b/tests/network_group3/tests/osaka_plan.tftest.hcl similarity index 64% rename from tests/network_group3_4/tests/osaka_plan.tftest.hcl rename to tests/network_group3/tests/osaka_plan.tftest.hcl index e84b201..5f22152 100644 --- a/tests/network_group3_4/tests/osaka_plan.tftest.hcl +++ b/tests/network_group3/tests/osaka_plan.tftest.hcl @@ -18,52 +18,44 @@ override_resource { # Stable computed IDs let plan-mode assertions verify the eleven links without # creating resources. The apply-mode file intentionally does not override these. override_resource { - target = module.network_vyos.aws_security_group.unprotected[0] + target = aws_security_group.vyos_source override_during = plan values = { id = "sg-00000000000000000" - name = "tftest-g34-8c2f-vyos-router" + name = "tftest-g3-8c2f-vyos-source" } } override_resource { - target = module.network_vyos.aws_instance.unprotected[0] + target = aws_network_interface.route_target override_during = plan values = { - id = "i-00000000000000000" - primary_network_interface_id = "eni-00000000000000000" - source_dest_check = false + id = "eni-00000000000000000" } } variables { region = "ap-northeast-3" - name_prefix = "tftest-g34-8c2f" + name_prefix = "tftest-g3-8c2f" web_ami_id = "ami-0d82c759aab529d2d" - vyos_ami_id = "ami-096d9368e5980d5fb" - test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g34-8c2f" + test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g3-8c2f" } -run "plan_network_group3_4_osaka" { +run "plan_network_group3_osaka" { command = plan - assert { - condition = !output.vyos_source_dest_check - error_message = "The Osaka VyOS instance must disable source/destination checking." - } - assert { condition = length(output.vyos_route_network_interface_ids) == 5 && alltrue([ - for id in values(output.vyos_route_network_interface_ids) : id == output.vyos_primary_network_interface_id + for id in values(output.vyos_route_network_interface_ids) : id == output.route_target_network_interface_id ]) - error_message = "All five VyOS routes must target the tested VyOS primary ENI." + error_message = "All five VyOS routes must target the substitute network interface." } assert { condition = length(output.vyos_source_security_group_ids) == 6 && alltrue([ - for id in values(output.vyos_source_security_group_ids) : id == output.vyos_security_group_id + for id in values(output.vyos_source_security_group_ids) : id == output.vyos_source_security_group_id ]) - error_message = "All six public ingress rules must reference the tested VyOS security group." + error_message = "All six public ingress rules must reference the substitute security group." } assert { diff --git a/tests/network_group3_4/variables.tf b/tests/network_group3/variables.tf similarity index 84% rename from tests/network_group3_4/variables.tf rename to tests/network_group3/variables.tf index e318d49..1361902 100644 --- a/tests/network_group3_4/variables.tf +++ b/tests/network_group3/variables.tf @@ -17,7 +17,7 @@ variable "region" { variable "name_prefix" { description = "Dedicated prefix for every named test resource." type = string - default = "tftest-g34-8c2f" + default = "tftest-g3-8c2f" } variable "web_ami_id" { @@ -25,11 +25,6 @@ variable "web_ami_id" { type = string } -variable "vyos_ami_id" { - description = "VyOS AMI available in the test region." - type = string -} - variable "test_public_key" { description = "Public-only test key. No private key is committed or used for a connection." type = string diff --git a/tests/network_group3_4/versions.tf b/tests/network_group3/versions.tf similarity index 100% rename from tests/network_group3_4/versions.tf rename to tests/network_group3/versions.tf diff --git a/tests/network_group3_4/outputs.tf b/tests/network_group3_4/outputs.tf deleted file mode 100644 index 6cad27b..0000000 --- a/tests/network_group3_4/outputs.tf +++ /dev/null @@ -1,29 +0,0 @@ -output "vyos_primary_network_interface_id" { - value = module.network_vyos.primary_network_interface_id -} - -output "vyos_security_group_id" { - value = module.network_vyos.security_group_id -} - -output "vyos_source_dest_check" { - value = module.network_vyos.source_dest_check -} - -output "vyos_route_network_interface_ids" { - value = module.network_public.vyos_route_network_interface_ids -} - -output "vyos_source_security_group_ids" { - value = module.network_public.vyos_source_security_group_ids -} - -output "named_resources" { - value = merge( - module.network_public.named_resource_names, - { - vyos_instance = module.network_vyos.instance_name - vyos_security_group = module.network_vyos.security_group_name - }, - ) -}