Limit Osaka test to public network
This commit is contained in:
+8
-15
@@ -1,6 +1,5 @@
|
|||||||
# This file is intentionally outside the default tests/ directory.
|
# This file is intentionally outside the default tests/ directory.
|
||||||
# Do not run it without the required approval and an existing Marketplace
|
# Do not run it without confirmation of the standing B4 approval conditions.
|
||||||
# subscription for the selected VyOS AMI.
|
|
||||||
|
|
||||||
provider "aws" {
|
provider "aws" {
|
||||||
region = var.region
|
region = var.region
|
||||||
@@ -18,32 +17,26 @@ override_resource {
|
|||||||
|
|
||||||
variables {
|
variables {
|
||||||
region = "ap-northeast-3"
|
region = "ap-northeast-3"
|
||||||
name_prefix = "tftest-g34-8c2f"
|
name_prefix = "tftest-g3-8c2f"
|
||||||
web_ami_id = "ami-0d82c759aab529d2d"
|
web_ami_id = "ami-0d82c759aab529d2d"
|
||||||
vyos_ami_id = "ami-096d9368e5980d5fb"
|
test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g3-8c2f"
|
||||||
test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g34-8c2f"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run "apply_network_group3_4_osaka" {
|
run "apply_network_group3_osaka" {
|
||||||
command = apply
|
command = apply
|
||||||
|
|
||||||
assert {
|
|
||||||
condition = !output.vyos_source_dest_check
|
|
||||||
error_message = "The Osaka VyOS instance must disable source/destination checking."
|
|
||||||
}
|
|
||||||
|
|
||||||
assert {
|
assert {
|
||||||
condition = length(output.vyos_route_network_interface_ids) == 5 && alltrue([
|
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 {
|
assert {
|
||||||
condition = length(output.vyos_source_security_group_ids) == 6 && alltrue([
|
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 {
|
assert {
|
||||||
@@ -40,8 +40,8 @@ module "network_public" {
|
|||||||
private_network_b = "198.51.100.0/24"
|
private_network_b = "198.51.100.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
vyos_network_interface_id = module.network_vyos.primary_network_interface_id
|
vyos_network_interface_id = aws_network_interface.route_target.id
|
||||||
vyos_security_group_id = module.network_vyos.security_group_id
|
vyos_security_group_id = aws_security_group.vyos_source.id
|
||||||
|
|
||||||
dhcp_options = {
|
dhcp_options = {
|
||||||
domain_name = "${var.region}.compute.internal"
|
domain_name = "${var.region}.compute.internal"
|
||||||
@@ -191,80 +191,21 @@ module "network_public" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module "network_vyos" {
|
resource "aws_security_group" "vyos_source" {
|
||||||
source = "../../modules/network_vyos"
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
security_group = {
|
tags = { Name = "${var.name_prefix}-vyos-source" }
|
||||||
description = "${var.name_prefix} VyOS test security group"
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ingress_rules = {
|
resource "aws_network_interface" "route_target" {
|
||||||
vpc_all = {
|
region = var.region
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
instance = {
|
subnet_id = module.network_public.subnet_ids["dmz"]
|
||||||
ami = var.vyos_ami_id
|
security_groups = [aws_security_group.vyos_source.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 = {
|
tags = { Name = "${var.name_prefix}-route-target" }
|
||||||
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" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
+11
-19
@@ -18,52 +18,44 @@ override_resource {
|
|||||||
# Stable computed IDs let plan-mode assertions verify the eleven links without
|
# Stable computed IDs let plan-mode assertions verify the eleven links without
|
||||||
# creating resources. The apply-mode file intentionally does not override these.
|
# creating resources. The apply-mode file intentionally does not override these.
|
||||||
override_resource {
|
override_resource {
|
||||||
target = module.network_vyos.aws_security_group.unprotected[0]
|
target = aws_security_group.vyos_source
|
||||||
override_during = plan
|
override_during = plan
|
||||||
values = {
|
values = {
|
||||||
id = "sg-00000000000000000"
|
id = "sg-00000000000000000"
|
||||||
name = "tftest-g34-8c2f-vyos-router"
|
name = "tftest-g3-8c2f-vyos-source"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override_resource {
|
override_resource {
|
||||||
target = module.network_vyos.aws_instance.unprotected[0]
|
target = aws_network_interface.route_target
|
||||||
override_during = plan
|
override_during = plan
|
||||||
values = {
|
values = {
|
||||||
id = "i-00000000000000000"
|
id = "eni-00000000000000000"
|
||||||
primary_network_interface_id = "eni-00000000000000000"
|
|
||||||
source_dest_check = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variables {
|
variables {
|
||||||
region = "ap-northeast-3"
|
region = "ap-northeast-3"
|
||||||
name_prefix = "tftest-g34-8c2f"
|
name_prefix = "tftest-g3-8c2f"
|
||||||
web_ami_id = "ami-0d82c759aab529d2d"
|
web_ami_id = "ami-0d82c759aab529d2d"
|
||||||
vyos_ami_id = "ami-096d9368e5980d5fb"
|
test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g3-8c2f"
|
||||||
test_public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHSftYPnELJxLgR9G8ftBeCIYo57KmlEc8A8BmqAHSLP tftest-g34-8c2f"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run "plan_network_group3_4_osaka" {
|
run "plan_network_group3_osaka" {
|
||||||
command = plan
|
command = plan
|
||||||
|
|
||||||
assert {
|
|
||||||
condition = !output.vyos_source_dest_check
|
|
||||||
error_message = "The Osaka VyOS instance must disable source/destination checking."
|
|
||||||
}
|
|
||||||
|
|
||||||
assert {
|
assert {
|
||||||
condition = length(output.vyos_route_network_interface_ids) == 5 && alltrue([
|
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 {
|
assert {
|
||||||
condition = length(output.vyos_source_security_group_ids) == 6 && alltrue([
|
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 {
|
assert {
|
||||||
@@ -17,7 +17,7 @@ variable "region" {
|
|||||||
variable "name_prefix" {
|
variable "name_prefix" {
|
||||||
description = "Dedicated prefix for every named test resource."
|
description = "Dedicated prefix for every named test resource."
|
||||||
type = string
|
type = string
|
||||||
default = "tftest-g34-8c2f"
|
default = "tftest-g3-8c2f"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "web_ami_id" {
|
variable "web_ami_id" {
|
||||||
@@ -25,11 +25,6 @@ variable "web_ami_id" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vyos_ami_id" {
|
|
||||||
description = "VyOS AMI available in the test region."
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "test_public_key" {
|
variable "test_public_key" {
|
||||||
description = "Public-only test key. No private key is committed or used for a connection."
|
description = "Public-only test key. No private key is committed or used for a connection."
|
||||||
type = string
|
type = string
|
||||||
@@ -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
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user