Light, fluffy, and always free - The AWS Local Emulator alternative
fix(rds): support IPV6 and DUAL network types on RDS Proxy (#3639)
Priamo Germosenc7b4a393d972
diff --git a/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/main.tf b/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/main.tfnew file mode 100644index 0000000000..4bc7426a92--- /dev/null+++ b/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/main.tf@@ -0,0 +1,148 @@+# Verifies aws_db_proxy's endpoint_network_type/target_connection_network_type round-trip+# through CreateDBProxy/DescribeDBProxies instead of being rejected outright. AWS requires both+# the VPC and every selected subnet to carry an IPv6 CIDR block for IPV6/DUAL (see+# https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-network-prereqs.html), so this+# VPC and its subnets are genuinely dual-stack; see rds_proxy_network_type.bats for the companion+# negative case against an IPv4-only VPC.++resource "aws_vpc" "proxy" {+ cidr_block = "10.80.0.0/16"+ assign_generated_ipv6_cidr_block = true++ tags = {+ Name = "floci-rds-proxy-network-type"+ }+}++resource "aws_subnet" "a" {+ vpc_id = aws_vpc.proxy.id+ cidr_block = "10.80.1.0/24"+ ipv6_cidr_block = cidrsubnet(aws_vpc.proxy.ipv6_cidr_block, 8, 0)+ availability_zone = "us-east-1a"+}++resource "aws_subnet" "b" {+ vpc_id = aws_vpc.proxy.id+ cidr_block = "10.80.2.0/24"+ ipv6_cidr_block = cidrsubnet(aws_vpc.proxy.ipv6_cidr_block, 8, 1)+ availability_zone = "us-east-1b"+}++resource "aws_security_group" "proxy" {+ name = "floci-rds-proxy-network-type"+ vpc_id = aws_vpc.proxy.id+}++resource "aws_secretsmanager_secret" "db" {+ name = "floci-rds-proxy-network-type-secret"+}++resource "aws_secretsmanager_secret_version" "db" {+ secret_id = aws_secretsmanager_secret.db.id+ secret_string = jsonencode({ username = "app", password = "changeme123!" })+}++resource "aws_iam_role" "proxy" {+ name = "floci-rds-proxy-network-type-role"++ assume_role_policy = jsonencode({+ Version = "2012-10-17"+ Statement = [{+ Action = "sts:AssumeRole"+ Effect = "Allow"+ Principal = { Service = "rds.amazonaws.com" }+ }]+ })+}++# IPv4-only sibling VPC/subnets: the negative case in rds_proxy_network_type.bats asserts a+# direct CreateDBProxy against these with EndpointNetworkType=DUAL is rejected, since AWS+# requires the VPC to have an IPv6 CIDR block for that.+resource "aws_vpc" "ipv4_only" {+ cidr_block = "10.90.0.0/16"++ tags = {+ Name = "floci-rds-proxy-network-type-ipv4-only"+ }+}++resource "aws_subnet" "ipv4_only_a" {+ vpc_id = aws_vpc.ipv4_only.id+ cidr_block = "10.90.1.0/24"+ availability_zone = "us-east-1a"+}++resource "aws_subnet" "ipv4_only_b" {+ vpc_id = aws_vpc.ipv4_only.id+ cidr_block = "10.90.2.0/24"+ availability_zone = "us-east-1b"+}++# Dual-stack VPC whose subnets never got an IPv6 CIDR block: the negative case in+# rds_proxy_network_type.bats asserts a direct CreateDBProxy against these with+# EndpointNetworkType=DUAL is still rejected, since AWS requires every selected subnet -- not+# just the VPC -- to carry an IPv6 CIDR block.+resource "aws_vpc" "ipv6_subnets_missing" {+ cidr_block = "10.100.0.0/16"+ assign_generated_ipv6_cidr_block = true++ tags = {+ Name = "floci-rds-proxy-network-type-ipv6-subnets-missing"+ }+}++resource "aws_subnet" "ipv6_subnets_missing_a" {+ vpc_id = aws_vpc.ipv6_subnets_missing.id+ cidr_block = "10.100.1.0/24"+ availability_zone = "us-east-1a"+}++resource "aws_subnet" "ipv6_subnets_missing_b" {+ vpc_id = aws_vpc.ipv6_subnets_missing.id+ cidr_block = "10.100.2.0/24"+ availability_zone = "us-east-1b"+}++resource "aws_db_proxy" "test" {+ name = "floci-rds-proxy-network-type"+ engine_family = "MYSQL"+ role_arn = aws_iam_role.proxy.arn+ vpc_subnet_ids = [aws_subnet.a.id, aws_subnet.b.id]+ vpc_security_group_ids = [aws_security_group.proxy.id]+ endpoint_network_type = "DUAL"+ target_connection_network_type = "IPV6"++ auth {+ auth_scheme = "SECRETS"+ iam_auth = "DISABLED"+ secret_arn = aws_secretsmanager_secret.db.arn+ }+}++output "proxy_arn" {+ value = aws_db_proxy.test.arn+}++output "endpoint_network_type" {+ value = aws_db_proxy.test.endpoint_network_type+}++output "target_connection_network_type" {+ value = aws_db_proxy.test.target_connection_network_type+}++output "role_arn" {+ value = aws_iam_role.proxy.arn+}++output "secret_arn" {+ value = aws_secretsmanager_secret.db.arn+}++output "ipv4_only_subnet_ids" {+ value = [aws_subnet.ipv4_only_a.id, aws_subnet.ipv4_only_b.id]+}++output "ipv6_subnets_missing_subnet_ids" {+ value = [aws_subnet.ipv6_subnets_missing_a.id, aws_subnet.ipv6_subnets_missing_b.id]+}diff --git a/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/provider.tf b/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/provider.tfnew file mode 100644index 0000000000..c616a3d075--- /dev/null+++ b/compatibility-tests/compat-terraform/test/rds-proxy-network-type-tf/provider.tf@@ -0,0 +1,31 @@+terraform {+ required_providers {+ aws = {+ source = "hashicorp/aws"+ version = "~> 6.0"+ }+ }+}++variable "endpoint" {+ type = string+ default = "http://localhost:4566"+}++provider "aws" {+ region = "us-east-1"+ access_key = "test"+ secret_key = "test"++ skip_credentials_validation = true+ skip_metadata_api_check = true+ skip_requesting_account_id = true+ s3_use_path_style = true++ endpoints {+ rds = var.endpoint+ ec2 = var.endpoint+ iam = var.endpoint+ secretsmanager = var.endpoint+ }+}diff --git a/compatibility-tests/compat-terraform/test/rds_proxy_network_type.bats b/compatibility-tests/compat-terraform/test/rds_proxy_network_type.batsnew file mode 100644index 0000000000..484f5f6dce--- /dev/null+++ b/compatibility-tests/compat-terraform/test/rds_proxy_network_type.bats@@ -0,0 +1,116 @@+#!/usr/bin/env bats+# RDS Proxy EndpointNetworkType/TargetConnectionNetworkType Compatibility Test+#+# CreateDBProxy used to reject any EndpointNetworkType/TargetConnectionNetworkType other than+# IPV4 outright. This verifies aws_db_proxy can apply with endpoint_network_type = "DUAL" and+# target_connection_network_type = "IPV6", that DescribeDBProxies reads the values back, and+# that a second plan is clean (no perpetual diff from a default the provider disagrees with).++setup_file() {+ load 'test_helper/common-setup'++ PROXY_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/rds-proxy-network-type-tf" && pwd)"+ cd "$PROXY_TF_DIR"++ echo "# === RDS Proxy Network Type Test ===" >&3+ echo "# Endpoint: $FLOCI_ENDPOINT" >&3+ echo "# Config: $PROXY_TF_DIR" >&3++ rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true++ echo "# --- terraform init ---" >&3+ run terraform init -input=false -no-color+ if [ "$status" -ne 0 ]; then+ echo "# terraform init failed: $output" >&3+ return 1+ fi++ echo "# --- terraform apply ---" >&3+ run terraform apply -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color+ if [ "$status" -ne 0 ]; then+ echo "# terraform apply failed: $output" >&3+ return 1+ fi+}++teardown_file() {+ load 'test_helper/common-setup'++ PROXY_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/rds-proxy-network-type-tf" && pwd)"+ cd "$PROXY_TF_DIR"++ terraform destroy -var="endpoint=${FLOCI_ENDPOINT}" -input=false -auto-approve -no-color || true+ rm -rf .terraform .terraform.lock.hcl terraform.tfstate* 2>/dev/null || true+}++setup() {+ load 'test_helper/common-setup'+ PROXY_TF_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/rds-proxy-network-type-tf" && pwd)"+}++@test "RDS Proxy network type: apply reports DUAL/IPV6 outputs" {+ ENDPOINT_TYPE=$(terraform -chdir="$PROXY_TF_DIR" output -raw endpoint_network_type)+ TARGET_TYPE=$(terraform -chdir="$PROXY_TF_DIR" output -raw target_connection_network_type)+ assert_equal "$ENDPOINT_TYPE" "DUAL"+ assert_equal "$TARGET_TYPE" "IPV6"+}++@test "RDS Proxy network type: DescribeDBProxies reads the values back" {+ run aws_cmd rds describe-db-proxies --db-proxy-name floci-rds-proxy-network-type \+ --query "DBProxies[0].EndpointNetworkType" --output text+ assert_success+ assert_output "DUAL"++ run aws_cmd rds describe-db-proxies --db-proxy-name floci-rds-proxy-network-type \+ --query "DBProxies[0].TargetConnectionNetworkType" --output text+ assert_success+ assert_output "IPV6"+}++@test "RDS Proxy network type: second plan reports no changes" {+ cd "$PROXY_TF_DIR"+ run terraform plan -var="endpoint=${FLOCI_ENDPOINT}" -input=false -no-color -detailed-exitcode+ assert_success+ assert_output --partial "No changes"+}++@test "RDS Proxy network type: CreateDBProxy rejects DUAL against an IPv4-only VPC" {+ ROLE_ARN=$(terraform -chdir="$PROXY_TF_DIR" output -raw role_arn)+ SECRET_ARN=$(terraform -chdir="$PROXY_TF_DIR" output -raw secret_arn)+ SUBNET_A=$(terraform -chdir="$PROXY_TF_DIR" output -json ipv4_only_subnet_ids | jq -r '.[0]')+ SUBNET_B=$(terraform -chdir="$PROXY_TF_DIR" output -json ipv4_only_subnet_ids | jq -r '.[1]')++ run aws_cmd rds create-db-proxy \+ --db-proxy-name floci-rds-proxy-ipv4-only-rejected \+ --engine-family MYSQL \+ --role-arn "$ROLE_ARN" \+ --vpc-subnet-ids "$SUBNET_A" "$SUBNET_B" \+ --auth "AuthScheme=SECRETS,SecretArn=${SECRET_ARN},IAMAuth=DISABLED" \+ --endpoint-network-type DUAL+ assert_failure+ assert_output --partial "IPv6 CIDR block"++ run aws_cmd rds describe-db-proxies --db-proxy-name floci-rds-proxy-ipv4-only-rejected+ assert_failure+}++@test "RDS Proxy network type: CreateDBProxy rejects DUAL when the VPC is dual-stack but the subnets are not" {+ ROLE_ARN=$(terraform -chdir="$PROXY_TF_DIR" output -raw role_arn)+ SECRET_ARN=$(terraform -chdir="$PROXY_TF_DIR" output -raw secret_arn)+ SUBNET_A=$(terraform -chdir="$PROXY_TF_DIR" output -json ipv6_subnets_missing_subnet_ids | jq -r '.[0]')+ SUBNET_B=$(terraform -chdir="$PROXY_TF_DIR" output -json ipv6_subnets_missing_subnet_ids | jq -r '.[1]')++ run aws_cmd rds create-db-proxy \+ --db-proxy-name floci-rds-proxy-ipv6-subnets-missing-rejected \+ --engine-family MYSQL \+ --role-arn "$ROLE_ARN" \+ --vpc-subnet-ids "$SUBNET_A" "$SUBNET_B" \+ --auth "AuthScheme=SECRETS,SecretArn=${SECRET_ARN},IAMAuth=DISABLED" \+ --endpoint-network-type DUAL+ assert_failure+ assert_output --partial "VpcSubnetIds"+ assert_output --partial "IPv6 CIDR block"++ run aws_cmd rds describe-db-proxies --db-proxy-name floci-rds-proxy-ipv6-subnets-missing-rejected+ assert_failure+}diff --git a/docs/services/rds.md b/docs/services/rds.mdindex e12bebfeff..1ba13ca52e 100644--- a/docs/services/rds.md+++ b/docs/services/rds.md@@ -182,8 +182,13 @@ services:Requests to `RegisterDBProxyTargets`, `DeregisterDBProxyTargets`, and`DescribeDBProxyTargets` use the `default` target group when `TargetGroupName` is omitted,matching the RDS API contract.- DB proxies currently support `IPV4` for both endpoint and target connections; `IPV6` and `DUAL`- endpoint networking require additional listener and Docker-network support.+ `CreateDBProxy`/`AWS::RDS::DBProxy` accept `EndpointNetworkType` (`IPV4`, `IPV6`, or `DUAL`) and+ `TargetConnectionNetworkType` (`IPV4` or `IPV6`) and round-trip them like the other proxy+ settings above; the TCP relay itself still only listens on IPv4, so a non-`IPV4` value is+ accepted as control-plane metadata rather than making the relay dual-stack. A non-`IPV4` value+ is rejected with `InvalidParameterValue` unless the proxy's VPC and every subnet in+ `VpcSubnetIds` already carry an associated IPv6 CIDR block, matching AWS's own network+ prerequisites for RDS Proxy.## Aurora Serverless v2 scalingdiff --git a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/RdsCfnProvisioner.java b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/RdsCfnProvisioner.javaindex dbb3a2cecc..8199db611f 100644--- a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/RdsCfnProvisioner.java+++ b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/RdsCfnProvisioner.java@@ -598,9 +598,9 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {String endpointNetworkType = resolveOptional(props, "EndpointNetworkType", engine);String targetConnectionNetworkType = resolveOptional(props, "TargetConnectionNetworkType", engine);- validateIpv4DbProxyNetworkType(endpointNetworkType,+ validateDbProxyNetworkType(endpointNetworkType,"EndpointNetworkType", true, "IPV4, IPV6, or DUAL");- validateIpv4DbProxyNetworkType(targetConnectionNetworkType,+ validateDbProxyNetworkType(targetConnectionNetworkType,"TargetConnectionNetworkType", false, "IPV4 or IPV6");boolean requireTls = parseBoolProp(props, "RequireTLS", engine);boolean debugLogging = parseBoolProp(props, "DebugLogging", engine);@@ -622,9 +622,10 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {var proxy = r.getPhysicalId() == null? rdsService.createDbProxy(name, engineFamily, requireTls, iamAuth,defaultAuthScheme, roleArn, subnetIds, sgIds, auth, idleClientTimeout,- debugLogging, tags, region)+ debugLogging, tags, region, endpointNetworkType, targetConnectionNetworkType): updateDbProxy(r, name, engineFamily, defaultAuthScheme, requireTls,- idleClientTimeout, debugLogging, roleArn, subnetIds, sgIds, auth, tags, region);+ idleClientTimeout, debugLogging, roleArn, subnetIds, sgIds, auth, tags, region,+ endpointNetworkType, targetConnectionNetworkType);r.setPhysicalId(proxy.getDbProxyName()); // Ref -> DBProxyNamer.getAttributes().put("Endpoint", proxy.getEndpoint()); // GetAtt "Endpoint" (bare host)r.getAttributes().put("DBProxyArn", proxy.getDbProxyArn());@@ -637,15 +638,31 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {StackResource resource, String name, String engineFamily, String defaultAuthScheme,boolean requireTls, int idleClientTimeout, boolean debugLogging, String roleArn,List<String> subnetIds, List<String> securityGroupIds, List<DbProxyAuth> auth,- Map<String, String> tags, String region) {+ Map<String, String> tags, String region, String endpointNetworkType,+ String targetConnectionNetworkType) {var existing = rdsService.getDbProxy(resource.getPhysicalId(), region);+ // ModifyDBProxy has no EndpointNetworkType/TargetConnectionNetworkType parameters; AWS+ // documents both as requiring CloudFormation replacement, same as DBProxyName, EngineFamily,+ // and VpcSubnetIds.+ String effectiveEndpointNetworkType = endpointNetworkType != null && !endpointNetworkType.isBlank()+ ? endpointNetworkType.toUpperCase() : "IPV4";+ String effectiveTargetConnectionNetworkType =+ targetConnectionNetworkType != null && !targetConnectionNetworkType.isBlank()+ ? targetConnectionNetworkType.toUpperCase() : "IPV4";+ String existingEndpointNetworkType = existing.getEndpointNetworkType() != null+ ? existing.getEndpointNetworkType() : "IPV4";+ String existingTargetConnectionNetworkType = existing.getTargetConnectionNetworkType() != null+ ? existing.getTargetConnectionNetworkType() : "IPV4";if (!Objects.equals(existing.getDbProxyName(), name)|| engineFamily == null|| !existing.getEngineFamily().equalsIgnoreCase(engineFamily)- || !Set.copyOf(existing.getVpcSubnetIds()).equals(Set.copyOf(subnetIds))) {+ || !Set.copyOf(existing.getVpcSubnetIds()).equals(Set.copyOf(subnetIds))+ || !existingEndpointNetworkType.equalsIgnoreCase(effectiveEndpointNetworkType)+ || !existingTargetConnectionNetworkType.equalsIgnoreCase(effectiveTargetConnectionNetworkType)) {throw new AwsException("UnsupportedOperation",- "Changing DBProxyName, EngineFamily, or VpcSubnetIds requires CloudFormation "- + "replacement, which is not yet supported by Floci.", 400);+ "Changing DBProxyName, EngineFamily, VpcSubnetIds, EndpointNetworkType, or "+ + "TargetConnectionNetworkType requires CloudFormation replacement, "+ + "which is not yet supported by Floci.", 400);}return rdsService.modifyDbProxy(existing.getDbProxyName(), defaultAuthScheme, auth,requireTls, idleClientTimeout, debugLogging, roleArn,@@ -720,12 +737,9 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {return auth;}- private void validateIpv4DbProxyNetworkType(+ private void validateDbProxyNetworkType(String value, String propertyName, boolean dualAllowed, String validValues) {- if (value == null) {- return;- }- if ("IPV4".equalsIgnoreCase(value)) {+ if (value == null || "IPV4".equalsIgnoreCase(value)) {return;}boolean supportedAwsValue = "IPV6".equalsIgnoreCase(value)@@ -734,10 +748,6 @@ public class RdsCfnProvisioner implements CfnResourceProvisioner {throw new AwsException("InvalidParameterValue",propertyName + " must be " + validValues + ".", 400);}- throw new AwsException("UnsupportedOperation",- propertyName + " " + value.toUpperCase()- + " is not supported because Floci currently exposes IPv4 proxy networking only.",- 400);}private void deleteDbProxySafe(String name, String region) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.javaindex d3b3fe4e0d..f49e630303 100644--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java@@ -2817,7 +2817,8 @@ public class Ec2QueryHandler {String cidrBlock = p.getFirst("CidrBlock");String az = p.getFirst("AvailabilityZone");String azId = p.getFirst("AvailabilityZoneId");- Subnet subnet = service.createSubnet(region, vpcId, cidrBlock, az, azId);+ String ipv6CidrBlock = p.getFirst("Ipv6CidrBlock");+ Subnet subnet = service.createSubnet(region, vpcId, cidrBlock, az, azId, ipv6CidrBlock);applyResourceTags(p, region, "subnet", subnet.getSubnetId());XmlBuilder xml = new XmlBuilder().start("CreateSubnetResponse", AwsNamespaces.EC2)@@ -4491,12 +4492,26 @@ public class Ec2QueryHandler {.elem("assignIpv6AddressOnCreation", String.valueOf(s.isAssignIpv6AddressOnCreation())).elem("enableDns64", String.valueOf(s.isEnableDns64())).elem("mapCustomerOwnedIpOnLaunch", String.valueOf(s.isMapCustomerOwnedIpOnLaunch()))- .start("ipv6CidrBlockAssociationSet").end("ipv6CidrBlockAssociationSet")+ .start("ipv6CidrBlockAssociationSet");+ for (VpcIpv6CidrBlockAssociation assoc : s.getIpv6CidrBlockAssociationSet()) {+ xml.start("item").raw(subnetIpv6AssociationXml(assoc)).end("item");+ }+ xml.end("ipv6CidrBlockAssociationSet").elem("ownerId", s.getOwnerId()).raw(tagSetXml(s.getTags()));return xml.build();}+ // Subnet's ipv6CidrBlockAssociationSet item carries only ipv6CidrBlock/associationId/state on+ // the wire, unlike the VPC's own association, which also carries ipv6Pool/networkBorderGroup.+ private String subnetIpv6AssociationXml(VpcIpv6CidrBlockAssociation assoc) {+ return new XmlBuilder()+ .elem("ipv6CidrBlock", assoc.getIpv6CidrBlock())+ .elem("associationId", assoc.getAssociationId())+ .start("ipv6CidrBlockState").elem("state", assoc.getIpv6CidrBlockState()).end("ipv6CidrBlockState")+ .build();+ }+private String sgXml(SecurityGroup sg) {XmlBuilder xml = new XmlBuilder().elem("ownerId", sg.getOwnerId())diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.javaindex 1b76ecf5ed..e30c56a9fc 100644--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java@@ -3456,6 +3456,11 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {return new VpcIpv6CidrBlockAssociation("vpc-cidr-assoc-" + randomHex(8), block, region);}+ private boolean vpcHasAssociatedIpv6CidrBlock(Vpc vpc) {+ return vpc.getIpv6CidrBlockAssociationSet().stream()+ .anyMatch(assoc -> "associated".equalsIgnoreCase(assoc.getIpv6CidrBlockState()));+ }+public void disassociateVpcCidrBlock(String region, String associationId) {ensureDefaultResources(region);for (Vpc vpc : vpcs.scan(k -> true)) {@@ -3852,11 +3857,21 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {public Subnet createSubnet(String region, String vpcId, String cidrBlock, String availabilityZone,String availabilityZoneId) {+ return createSubnet(region, vpcId, cidrBlock, availabilityZone, availabilityZoneId, null);+ }++ public Subnet createSubnet(String region, String vpcId, String cidrBlock, String availabilityZone,+ String availabilityZoneId, String ipv6CidrBlock) {if (vpcId == null || vpcId.isBlank()) {throw new AwsException("MissingParameter", "The request must contain the parameter VpcId", 400);}ensureDefaultResources(region);- getRequiredVpc(region, vpcId);+ Vpc vpc = getRequiredVpc(region, vpcId);+ if (ipv6CidrBlock != null && !ipv6CidrBlock.isBlank() && !vpcHasAssociatedIpv6CidrBlock(vpc)) {+ throw new AwsException("InvalidParameterValue",+ "Ipv6CidrBlock can only be specified for a subnet in a VPC with an associated "+ + "IPv6 CIDR block. VPC " + vpcId + " has none.", 400);+ }String zoneName = resolveSubnetZoneName(region, availabilityZone, availabilityZoneId);@@ -3872,6 +3887,10 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {subnet.setOwnerId(accountId);subnet.setRegion(region);subnet.setSubnetArn(AwsArnUtils.Arn.of("ec2", region, accountId, "subnet/" + subnetId).toString());+ if (ipv6CidrBlock != null && !ipv6CidrBlock.isBlank()) {+ subnet.getIpv6CidrBlockAssociationSet().add(new VpcIpv6CidrBlockAssociation(+ "subnet-cidr-assoc-" + randomHex(17), ipv6CidrBlock, null));+ }// The conflict scan and the store must be one step under the VPC's lock, or two// overlapping creates in flight together both pass the scan before either is stored.synchronized (lockFor(key(region, vpcId))) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/model/Subnet.java b/src/main/java/io/github/hectorvent/floci/services/ec2/model/Subnet.javaindex 34f3eab4b1..9a33f67f4f 100644--- a/src/main/java/io/github/hectorvent/floci/services/ec2/model/Subnet.java+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/model/Subnet.java@@ -26,6 +26,7 @@ public class Subnet {private String region;private String subnetArn;private List<Tag> tags = new ArrayList<>();+ private List<VpcIpv6CidrBlockAssociation> ipv6CidrBlockAssociationSet = new ArrayList<>();public Subnet() {}@@ -76,4 +77,7 @@ public class Subnet {public List<Tag> getTags() { return tags; }public void setTags(List<Tag> tags) { this.tags = tags; }++ public List<VpcIpv6CidrBlockAssociation> getIpv6CidrBlockAssociationSet() { return ipv6CidrBlockAssociationSet; }+ public void setIpv6CidrBlockAssociationSet(List<VpcIpv6CidrBlockAssociation> ipv6CidrBlockAssociationSet) { this.ipv6CidrBlockAssociationSet = ipv6CidrBlockAssociationSet; }}diff --git a/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.javaindex 8e4717051b..f55d6dd4f9 100644--- a/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java+++ b/src/main/java/io/github/hectorvent/floci/services/rds/RdsQueryHandler.java@@ -1162,10 +1162,10 @@ public class RdsQueryHandler {}private Response handleCreateDbProxy(MultivaluedMap<String, String> params, String region) {- validateIpv4NetworkType(params.getFirst("EndpointNetworkType"),- "EndpointNetworkType", true, "IPV4, IPV6, or DUAL");- validateIpv4NetworkType(params.getFirst("TargetConnectionNetworkType"),- "TargetConnectionNetworkType", false, "IPV4 or IPV6");+ String endpointNetworkType = params.getFirst("EndpointNetworkType");+ String targetConnectionNetworkType = params.getFirst("TargetConnectionNetworkType");+ validateDbProxyNetworkType(endpointNetworkType, "EndpointNetworkType", true, "IPV4, IPV6, or DUAL");+ validateDbProxyNetworkType(targetConnectionNetworkType, "TargetConnectionNetworkType", false, "IPV4 or IPV6");String name = params.getFirst("DBProxyName");String engineFamily = params.getFirst("EngineFamily");boolean requireTls = "true".equalsIgnoreCase(params.getFirst("RequireTLS"));@@ -1190,7 +1190,8 @@ public class RdsQueryHandler {iamEnabled = iamEnabled || "IAM_AUTH".equalsIgnoreCase(defaultAuthScheme);DbProxy proxy = service.createDbProxy(name, engineFamily, requireTls, iamEnabled, defaultAuthScheme, roleArn,- subnetIds, sgIds, auth, idleClientTimeout, debugLogging, parseTags(params), region);+ subnetIds, sgIds, auth, idleClientTimeout, debugLogging, parseTags(params), region,+ endpointNetworkType, targetConnectionNetworkType);String result = new XmlBuilder().start("DBProxy").raw(dbProxyInnerXml(proxy)).end("DBProxy").build();return Response.ok(AwsQueryResponse.envelope("CreateDBProxy", AwsNamespaces.RDS, result)).build();}@@ -1378,12 +1379,9 @@ public class RdsQueryHandler {return xml.build();}- private static void validateIpv4NetworkType(+ private static void validateDbProxyNetworkType(String value, String parameterName, boolean dualAllowed, String validValues) {- if (value == null) {- return;- }- if ("IPV4".equalsIgnoreCase(value)) {+ if (value == null || "IPV4".equalsIgnoreCase(value)) {return;}boolean supportedAwsValue = "IPV6".equalsIgnoreCase(value)@@ -1392,10 +1390,6 @@ public class RdsQueryHandler {throw new AwsException("InvalidParameterValue",parameterName + " must be " + validValues + ".", 400);}- throw new AwsException("UnsupportedOperation",- parameterName + " " + value.toUpperCase()- + " is not supported because Floci currently exposes IPv4 proxy networking only.",- 400);}private String dbProxyTargetGroupInnerXml(DbProxyTargetGroup tg) {diff --git a/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java b/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.javaindex 70e54795e9..52f9be0479 100644--- a/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java+++ b/src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java@@ -19,6 +19,7 @@ import io.github.hectorvent.floci.core.storage.StorageBackend;import io.github.hectorvent.floci.core.storage.StorageFactory;import io.github.hectorvent.floci.services.ec2.Ec2Service;import io.github.hectorvent.floci.services.ec2.model.Subnet;+import io.github.hectorvent.floci.services.ec2.model.Vpc;import io.github.hectorvent.floci.services.rds.container.RdsContainerHandle;import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;import io.github.hectorvent.floci.services.rds.model.DatabaseEngine;@@ -2491,17 +2492,33 @@ public class RdsService implements Resettable, ResourceProvider {vpcSubnetIds, vpcSecurityGroupIds, auth, idleClientTimeout, debugLogging, tags, region);}+ public DbProxy createDbProxy(String dbProxyName, String engineFamily, boolean requireTls,+ boolean iamAuth, String defaultAuthScheme, String roleArn,+ List<String> vpcSubnetIds,+ List<String> vpcSecurityGroupIds, List<DbProxyAuth> auth,+ int idleClientTimeout, boolean debugLogging,+ Map<String, String> tags, String region) {+ return createDbProxy(dbProxyName, engineFamily, requireTls, iamAuth, defaultAuthScheme, roleArn,+ vpcSubnetIds, vpcSecurityGroupIds, auth, idleClientTimeout, debugLogging, tags, region,+ null, null);+ }+public synchronized DbProxy createDbProxy(String dbProxyName, String engineFamily, boolean requireTls,boolean iamAuth, String defaultAuthScheme, String roleArn,List<String> vpcSubnetIds,List<String> vpcSecurityGroupIds, List<DbProxyAuth> auth,int idleClientTimeout, boolean debugLogging,- Map<String, String> tags, String region) {+ Map<String, String> tags, String region,+ String endpointNetworkType, String targetConnectionNetworkType) {String effectiveDefaultAuthScheme = normalizeDefaultAuthScheme(defaultAuthScheme);validateDbProxyCreate(dbProxyName, engineFamily, roleArn, vpcSubnetIds, auth,effectiveDefaultAuthScheme, idleClientTimeout);String effectiveRegion = effectiveRegion(region);String vpcId = resolveDbProxyVpc(vpcSubnetIds, effectiveRegion);+ if (requiresIpv6VpcCidrBlock(endpointNetworkType, targetConnectionNetworkType)) {+ validateVpcHasIpv6CidrBlock(vpcId, effectiveRegion);+ validateSubnetsHaveIpv6CidrBlock(vpcSubnetIds, effectiveRegion);+ }String proxyKey = dbProxyKey(effectiveRegion, dbProxyName);String accountId = currentAccountId();if (findDbProxy(dbProxyName, effectiveRegion).isPresent()@@ -2529,6 +2546,12 @@ public class RdsService implements Resettable, ResourceProvider {proxy.setAuth(auth);proxy.setIdleClientTimeout(idleClientTimeout);proxy.setDebugLogging(debugLogging);+ if (endpointNetworkType != null && !endpointNetworkType.isBlank()) {+ proxy.setEndpointNetworkType(endpointNetworkType.toUpperCase());+ }+ if (targetConnectionNetworkType != null && !targetConnectionNetworkType.isBlank()) {+ proxy.setTargetConnectionNetworkType(targetConnectionNetworkType.toUpperCase());+ }proxy.setTags(tags);proxy.setProxyPort(proxyPort);proxy.setEndpointHost(mock ? "localhost" : proxyEndpointHost());@@ -6010,6 +6033,39 @@ public class RdsService implements Resettable, ResourceProvider {return vpcIds.iterator().next();}+ private boolean requiresIpv6VpcCidrBlock(String endpointNetworkType, String targetConnectionNetworkType) {+ return "IPV6".equalsIgnoreCase(endpointNetworkType) || "DUAL".equalsIgnoreCase(endpointNetworkType)+ || "IPV6".equalsIgnoreCase(targetConnectionNetworkType);+ }++ private void validateVpcHasIpv6CidrBlock(String vpcId, String region) {+ List<Vpc> vpcs = ec2Service.describeVpcs(region, List.of(vpcId), Map.of());+ boolean hasIpv6 = !vpcs.isEmpty() && vpcs.get(0).getIpv6CidrBlockAssociationSet().stream()+ .anyMatch(assoc -> "associated".equalsIgnoreCase(assoc.getIpv6CidrBlockState()));+ if (!hasIpv6) {+ throw new AwsException("InvalidParameterValue",+ "EndpointNetworkType/TargetConnectionNetworkType of IPV6 or DUAL requires VPC "+ + vpcId + " to have an associated IPv6 CIDR block.", 400);+ }+ }++ // AWS requires every selected subnet, not just the VPC, to carry an associated IPv6 CIDR block+ // for an IPV6/DUAL proxy endpoint: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-network-prereqs.html+ private void validateSubnetsHaveIpv6CidrBlock(List<String> subnetIds, String region) {+ List<Subnet> subnets = ec2Service.describeSubnets(region, subnetIds, Map.of());+ List<String> missing = subnets.stream()+ .filter(subnet -> subnet.getIpv6CidrBlockAssociationSet().stream()+ .noneMatch(assoc -> "associated".equalsIgnoreCase(assoc.getIpv6CidrBlockState())))+ .map(Subnet::getSubnetId)+ .toList();+ if (!missing.isEmpty()) {+ throw new AwsException("InvalidParameterValue",+ "EndpointNetworkType/TargetConnectionNetworkType of IPV6 or DUAL requires every "+ + "VpcSubnetIds entry to have an associated IPv6 CIDR block; missing on "+ + missing + ".", 400);+ }+ }+private DbSubnetGroup buildSubnetGroup(String name, String description, List<String> subnetIds, String region) {List<Subnet> resolvedSubnets = ec2Service.describeSubnets(region, subnetIds, Map.of());if (resolvedSubnets.size() != subnetIds.size()) {diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/RdsCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/RdsCfnProvisionerTest.javaindex 0494978778..5d837d3672 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/RdsCfnProvisionerTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/RdsCfnProvisionerTest.java@@ -43,6 +43,7 @@ import static org.mockito.ArgumentMatchers.anyInt;import static org.mockito.ArgumentMatchers.anyList;import static org.mockito.ArgumentMatchers.anyMap;import static org.mockito.ArgumentMatchers.eq;+import static org.mockito.ArgumentMatchers.isNull;import static org.mockito.ArgumentMatchers.nullable;import static org.mockito.Mockito.doReturn;import static org.mockito.Mockito.doThrow;@@ -984,13 +985,13 @@ class RdsCfnProvisionerTest {when(proxy.getDbProxyArn()).thenReturn("arn:aws:rds:us-east-1:000000000000:db-proxy:prx-abc");when(proxy.getVpcId()).thenReturn("vpc-default");when(rdsService.createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(),- anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any()))+ anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any())).thenReturn(proxy);StackResource r = provision("Proxy", "AWS::RDS::DBProxy", """{"DBProxyName":"app-proxy","EngineFamily":"POSTGRESQL","RequireTLS":true,"DebugLogging":true,"IdleClientTimeout":120,"DefaultAuthScheme":"IAM_AUTH",- "EndpointNetworkType":"IPV4","TargetConnectionNetworkType":"IPV4",+ "EndpointNetworkType":"DUAL","TargetConnectionNetworkType":"IPV6","RoleArn":"arn:aws:iam::000000000000:role/proxy","VpcSubnetIds":["subnet-a","subnet-b"],"Tags":[{"Key":"owner","Value":"platform"}]}@@ -1005,7 +1006,8 @@ class RdsCfnProvisionerTest {verify(rdsService).createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(true), eq(true),eq("IAM_AUTH"), eq("arn:aws:iam::000000000000:role/proxy"),eq(List.of("subnet-a", "subnet-b")), eq(List.of()), eq(List.of()),- eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-east-1"));+ eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-east-1"),+ eq("DUAL"), eq("IPV6"));}@Test@@ -1025,7 +1027,7 @@ class RdsCfnProvisionerTest {"DefaultAuthScheme must be NONE or IAM_AUTH"));verify(rdsService, never()).createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(),- anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any());+ anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any());}@Test@@ -1034,7 +1036,7 @@ class RdsCfnProvisionerTest {when(proxy.getDbProxyName()).thenReturn("sqlserver-proxy");when(rdsService.createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(),- anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any()))+ anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any())).thenReturn(proxy);StackResource resource = provision("Proxy", "AWS::RDS::DBProxy", """@@ -1054,24 +1056,25 @@ class RdsCfnProvisionerTest {eq("sqlserver-proxy"), eq("SQLSERVER"), eq(false), eq(true), eq("NONE"),eq("arn:aws:iam::000000000000:role/proxy"),eq(List.of("subnet-a", "subnet-b")), eq(List.of()), authCaptor.capture(),- eq(1800), eq(false), eq(Map.of()), eq("us-east-1"));+ eq(1800), eq(false), eq(Map.of()), eq("us-east-1"), isNull(), isNull());assertEquals("database-user", authCaptor.getValue().getFirst().getUserName());assertEquals("ENABLED", authCaptor.getValue().getFirst().getIamAuth());}@Test- void rejectsUnsupportedDbProxyNetworkTypesBeforeMutation() {- StackResource ipv6 = provision("Proxy", "AWS::RDS::DBProxy", """+ void rejectsInvalidDbProxyNetworkTypeValueBeforeMutation() {+ StackResource invalidTarget = provision("Proxy", "AWS::RDS::DBProxy", """{"DBProxyName":"app-proxy","EngineFamily":"POSTGRESQL",- "DefaultAuthScheme":"IAM_AUTH","EndpointNetworkType":"IPV6",+ "DefaultAuthScheme":"IAM_AUTH","TargetConnectionNetworkType":"DUAL","RoleArn":"arn:aws:iam::000000000000:role/proxy","VpcSubnetIds":["subnet-a","subnet-b"]}""");- assertEquals("CREATE_FAILED", ipv6.getStatus());- assertTrue(ipv6.getStatusReason().contains("IPv4 proxy networking only"));+ assertEquals("CREATE_FAILED", invalidTarget.getStatus());+ assertTrue(invalidTarget.getStatusReason().contains("TargetConnectionNetworkType must be"));verify(rdsService, never()).createDbProxy(any(), any(), anyBoolean(), anyBoolean(),- any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any());+ any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(),+ any(), any());}@Test@@ -1112,7 +1115,8 @@ class RdsCfnProvisionerTest {eq(90), eq(true), eq("arn:aws:iam::000000000000:role/proxy"),eq(List.of("sg-updated")), eq(Map.of("owner", "platform")), eq("us-west-2"));verify(rdsService, never()).createDbProxy(any(), any(), anyBoolean(), anyBoolean(),- any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any());+ any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(),+ any(), any());}@Test@@ -1134,7 +1138,30 @@ class RdsCfnProvisionerTest {verify(rdsService, never()).modifyDbProxy(any(), any(), any(), any(), any(), any(),any(), any(), any(), any());verify(rdsService, never()).createDbProxy(any(), any(), anyBoolean(), anyBoolean(),- any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any());+ any(), any(), anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(),+ any(), any());+ }++ @Test+ void changingDbProxyNetworkTypeFailsBeforeMutationSinceModifyDbProxyHasNoSuchParameter() {+ DbProxy existing = mock(DbProxy.class);+ when(existing.getDbProxyName()).thenReturn("app-proxy");+ when(existing.getEngineFamily()).thenReturn("POSTGRESQL");+ when(existing.getVpcSubnetIds()).thenReturn(List.of("subnet-a", "subnet-b"));+ when(existing.getEndpointNetworkType()).thenReturn("IPV4");+ when(existing.getTargetConnectionNetworkType()).thenReturn("IPV4");+ when(rdsService.getDbProxy("app-proxy", "us-east-1")).thenReturn(existing);++ StackResource resource = provisionExisting("Proxy", "AWS::RDS::DBProxy", """+ {"DBProxyName":"app-proxy","EngineFamily":"POSTGRESQL","DefaultAuthScheme":"NONE",+ "RoleArn":"arn:aws:iam::000000000000:role/proxy",+ "VpcSubnetIds":["subnet-a","subnet-b"],"EndpointNetworkType":"DUAL"}+ """, "us-east-1", "app-proxy", Map.of());++ assertEquals("CREATE_FAILED", resource.getStatus());+ assertTrue(resource.getStatusReason().contains("requires CloudFormation replacement"));+ verify(rdsService, never()).modifyDbProxy(any(), any(), any(), any(), any(), any(),+ any(), any(), any(), any());}@Test@@ -1831,7 +1858,8 @@ class RdsCfnProvisionerTest {when(proxy.getDbProxyName()).thenReturn("my-proxy");when(proxy.getDbProxyArn()).thenReturn("arn:aws:rds:us-east-1:000000000000:db-proxy:my-proxy");when(rdsService.createDbProxy(any(), any(), anyBoolean(), anyBoolean(), any(), any(),- anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any())).thenReturn(proxy);+ anyList(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(), any(), any()))+ .thenReturn(proxy);provision("Proxy", "AWS::RDS::DBProxy", """{"DBProxyName":"my-proxy","EngineFamily":"POSTGRESQL",@@ -1842,7 +1870,8 @@ class RdsCfnProvisionerTest {ArgumentCaptor<List<String>> subnets = ArgumentCaptor.forClass(List.class);verify(rdsService).createDbProxy(eq("my-proxy"), eq("POSTGRESQL"), anyBoolean(), anyBoolean(),- any(), any(), subnets.capture(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any());+ any(), any(), subnets.capture(), anyList(), anyList(), anyInt(), anyBoolean(), anyMap(), any(),+ isNull(), isNull());assertEquals(List.of("subnet-a", "subnet-b"), subnets.getValue());}}diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2SubnetIpv6CidrBlockIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2SubnetIpv6CidrBlockIntegrationTest.javanew file mode 100644index 0000000000..8bdc2cdb97--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2SubnetIpv6CidrBlockIntegrationTest.java@@ -0,0 +1,113 @@+package io.github.hectorvent.floci.services.ec2;++import static io.restassured.RestAssured.given;+import static org.hamcrest.Matchers.containsString;+import static org.hamcrest.Matchers.equalTo;+import static org.hamcrest.Matchers.not;++import org.junit.jupiter.api.Test;++import io.quarkus.test.junit.QuarkusTest;++/**+ * CreateSubnet accepted an Ipv6CidrBlock parameter and silently dropped it: the response always+ * carried an empty ipv6CidrBlockAssociationSet, so a Terraform aws_subnet with an ipv6_cidr_block+ * never converged the same way the VPC-level case fixed in+ * {@link Ec2VpcIpv6CidrBlockIntegrationTest} needed fixing.+ */+@QuarkusTest+class Ec2SubnetIpv6CidrBlockIntegrationTest {++ private static final String AUTH_HEADER =+ "AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/ec2/aws4_request";++ @Test+ void createSubnetWithAnIpv6CidrBlockReturnsItAndKeepsIt() {+ String vpcId = given()+ .formParam("Action", "CreateVpc")+ .formParam("CidrBlock", "10.94.0.0/16")+ .formParam("AmazonProvidedIpv6CidrBlock", "true")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .extract().path("CreateVpcResponse.vpc.vpcId");++ String subnetId = given()+ .formParam("Action", "CreateSubnet")+ .formParam("VpcId", vpcId)+ .formParam("CidrBlock", "10.94.1.0/24")+ .formParam("Ipv6CidrBlock", "2600:1f18:1::/64")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("CreateSubnetResponse.subnet.ipv6CidrBlockAssociationSet.item.ipv6CidrBlock",+ equalTo("2600:1f18:1::/64"))+ .body("CreateSubnetResponse.subnet.ipv6CidrBlockAssociationSet.item.ipv6CidrBlockState.state",+ equalTo("associated"))+ .extract().path("CreateSubnetResponse.subnet.subnetId");++ given()+ .formParam("Action", "DescribeSubnets")+ .formParam("SubnetId.1", subnetId)+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body("DescribeSubnetsResponse.subnetSet.item.ipv6CidrBlockAssociationSet.item.ipv6CidrBlock",+ equalTo("2600:1f18:1::/64"));+ }++ @Test+ void createSubnetWithoutAnIpv6CidrBlockHasNoIpv6Association() {+ String vpcId = given()+ .formParam("Action", "CreateVpc")+ .formParam("CidrBlock", "10.95.0.0/16")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .extract().path("CreateVpcResponse.vpc.vpcId");++ given()+ .formParam("Action", "CreateSubnet")+ .formParam("VpcId", vpcId)+ .formParam("CidrBlock", "10.95.1.0/24")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(not(containsString("<ipv6CidrBlock>")));+ }++ @Test+ void createSubnetRejectsAnIpv6CidrBlockWhenTheVpcHasNone() {+ String vpcId = given()+ .formParam("Action", "CreateVpc")+ .formParam("CidrBlock", "10.96.0.0/16")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .extract().path("CreateVpcResponse.vpc.vpcId");++ given()+ .formParam("Action", "CreateSubnet")+ .formParam("VpcId", vpcId)+ .formParam("CidrBlock", "10.96.1.0/24")+ .formParam("Ipv6CidrBlock", "2600:1f18:2::/64")+ .header("Authorization", AUTH_HEADER)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body(containsString("InvalidParameterValue"));+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.javaindex 1a046a3df8..b0318362f1 100644--- a/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsQueryHandlerTest.java@@ -1267,7 +1267,8 @@ class RdsQueryHandlerTest {when(service.createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(true), eq(true),eq("IAM_AUTH"), eq("arn:aws:iam::000000000000:role/proxy"),anyList(), anyList(), anyList(),- eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-west-2")))+ eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-west-2"),+ eq("IPV4"), eq("IPV4"))).thenReturn(proxy);MultivaluedMap<String, String> p = params();@@ -1313,7 +1314,8 @@ class RdsQueryHandlerTest {eq("IAM_AUTH"), eq("arn:aws:iam::000000000000:role/proxy"),anyList(), anyList(), argThat(auth -> auth.size() == 1&& "database-user".equals(auth.getFirst().getUserName())),- eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-west-2"));+ eq(120), eq(true), eq(Map.of("owner", "platform")), eq("us-west-2"),+ eq("IPV4"), eq("IPV4"));}@Test@@ -1335,7 +1337,7 @@ class RdsQueryHandlerTest {argThat(auth -> auth.size() == 1&& "ENABLED".equals(auth.getFirst().getIamAuth())&& "database-user".equals(auth.getFirst().getUserName())),- eq(1800), eq(false), eq(Map.of()), eq("us-west-2")))+ eq(1800), eq(false), eq(Map.of()), eq("us-west-2"), isNull(), isNull())).thenReturn(proxy);MultivaluedMap<String, String> p = params();@@ -1361,19 +1363,12 @@ class RdsQueryHandlerTest {argThat(auth -> auth.size() == 1&& "ENABLED".equals(auth.getFirst().getIamAuth())&& "database-user".equals(auth.getFirst().getUserName())),- eq(1800), eq(false), eq(Map.of()), eq("us-west-2"));+ eq(1800), eq(false), eq(Map.of()), eq("us-west-2"), isNull(), isNull());}@Test- void createDbProxyRejectsUnsupportedOrInvalidNetworkTypesBeforeCallingService() {- MultivaluedMap<String, String> ipv6 = params();- ipv6.add("EndpointNetworkType", "IPV6");-- Response ipv6Response = handler.handle("CreateDBProxy", ipv6, "us-west-2");-- assertEquals(400, ipv6Response.getStatus());- assertTrue(((String) ipv6Response.getEntity()).contains("UnsupportedOperation"));-+ void createDbProxyRejectsInvalidNetworkTypeValuesBeforeCallingService() {+ // TargetConnectionNetworkType has no DUAL value on real AWS (only EndpointNetworkType does).MultivaluedMap<String, String> invalidTargetType = params();invalidTargetType.add("TargetConnectionNetworkType", "DUAL");@@ -1382,9 +1377,51 @@ class RdsQueryHandlerTest {assertEquals(400, invalidResponse.getStatus());assertTrue(((String) invalidResponse.getEntity()).contains("InvalidParameterValue"));++ MultivaluedMap<String, String> bogus = params();+ bogus.add("EndpointNetworkType", "BOGUS");++ Response bogusResponse = handler.handle("CreateDBProxy", bogus, "us-west-2");++ assertEquals(400, bogusResponse.getStatus());+ assertTrue(((String) bogusResponse.getEntity()).contains("InvalidParameterValue"));verifyNoInteractions(service);}+ @Test+ void createDbProxyAcceptsIpv6AndDualNetworkTypes() {+ DbProxy proxy = new DbProxy();+ proxy.setDbProxyName("app-proxy");+ proxy.setEngineFamily("POSTGRESQL");+ proxy.setEndpointHost("app-proxy.host");+ proxy.setEndpointNetworkType("DUAL");+ proxy.setTargetConnectionNetworkType("IPV6");+ when(service.createDbProxy(eq("app-proxy"), eq("POSTGRESQL"), eq(false), eq(false),+ isNull(), eq("arn:aws:iam::000000000000:role/proxy"),+ anyList(), anyList(), anyList(),+ eq(1800), eq(false), eq(Map.of()), eq("us-west-2"),+ eq("DUAL"), eq("IPV6")))+ .thenReturn(proxy);++ MultivaluedMap<String, String> p = params();+ p.add("DBProxyName", "app-proxy");+ p.add("EngineFamily", "POSTGRESQL");+ p.add("EndpointNetworkType", "DUAL");+ p.add("TargetConnectionNetworkType", "IPV6");+ p.add("RoleArn", "arn:aws:iam::000000000000:role/proxy");+ p.add("VpcSubnetIds.member.1", "subnet-a");+ p.add("VpcSubnetIds.member.2", "subnet-b");+ p.add("Auth.member.1.AuthScheme", "SECRETS");+ p.add("Auth.member.1.SecretArn", "arn:aws:secretsmanager:us-east-1:000000000000:secret:db-AbCdEf");++ Response response = handler.handle("CreateDBProxy", p, "us-west-2");++ assertEquals(200, response.getStatus());+ String body = (String) response.getEntity();+ assertTrue(body.contains("<EndpointNetworkType>DUAL</EndpointNetworkType>"));+ assertTrue(body.contains("<TargetConnectionNetworkType>IPV6</TargetConnectionNetworkType>"));+ }+@Testvoid modifyDbProxy_mapsOptionalFieldsAndReturnsUpdatedProxy() {DbProxy proxy = new DbProxy();diff --git a/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.javaindex 90cd36aff1..91a2499c5a 100644--- a/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java@@ -10,6 +10,8 @@ import io.github.hectorvent.floci.core.storage.InMemoryStorage;import io.github.hectorvent.floci.core.storage.StorageBackend;import io.github.hectorvent.floci.services.ec2.Ec2Service;import io.github.hectorvent.floci.services.ec2.model.Subnet;+import io.github.hectorvent.floci.services.ec2.model.Vpc;+import io.github.hectorvent.floci.services.ec2.model.VpcIpv6CidrBlockAssociation;import io.github.hectorvent.floci.services.rds.model.DatabaseEngine;import io.github.hectorvent.floci.services.rds.model.DbCluster;import io.github.hectorvent.floci.services.rds.model.DbClusterParameterGroup;@@ -3291,6 +3293,74 @@ class RdsServiceTest {assertEquals("InvalidSubnet", mixedVpc.getErrorCode());}+ @Test+ void createDbProxyRejectsIpv6NetworkTypeWhenVpcHasNoIpv6CidrBlock() {+ // PROXY_SUBNET_IDS resolves to vpc-default, which the default ec2Service stub gives no+ // IPv6 CIDR block association, matching real AWS's IPv4-only VPC rejection.+ AwsException endpointRejected = assertThrows(AwsException.class, () ->+ rdsService.createDbProxy("ipv4-only-proxy", "POSTGRESQL", true, false, "NONE",+ PROXY_ROLE_ARN, PROXY_SUBNET_IDS, List.of(), PROXY_AUTH,+ 1800, false, Map.of(), "us-east-1", "DUAL", null));+ assertEquals("InvalidParameterValue", endpointRejected.getErrorCode());+ assertTrue(endpointRejected.getMessage().contains("IPv6 CIDR block"));++ AwsException targetRejected = assertThrows(AwsException.class, () ->+ rdsService.createDbProxy("ipv4-only-proxy", "POSTGRESQL", true, false, "NONE",+ PROXY_ROLE_ARN, PROXY_SUBNET_IDS, List.of(), PROXY_AUTH,+ 1800, false, Map.of(), "us-east-1", null, "IPV6"));+ assertEquals("InvalidParameterValue", targetRejected.getErrorCode());+ assertTrue(rdsService.listDbProxies(null).isEmpty());+ }++ @Test+ void createDbProxyAcceptsIpv6NetworkTypeWhenVpcHasIpv6CidrBlock() {+ List<String> dualStackSubnetIds = List.of("subnet-dualstack-a", "subnet-dualstack-b");+ Subnet subnetA = subnet("subnet-dualstack-a", "vpc-dualstack", "us-east-1a");+ subnetA.getIpv6CidrBlockAssociationSet().add(+ new VpcIpv6CidrBlockAssociation("subnet-cidr-assoc-a", "2600:1f18:1::/64", null));+ Subnet subnetB = subnet("subnet-dualstack-b", "vpc-dualstack", "us-east-1b");+ subnetB.getIpv6CidrBlockAssociationSet().add(+ new VpcIpv6CidrBlockAssociation("subnet-cidr-assoc-b", "2600:1f18:2::/64", null));+ when(ec2Service.describeSubnets(eq("us-east-1"), eq(dualStackSubnetIds), eq(Map.of())))+ .thenReturn(List.of(subnetA, subnetB));+ Vpc dualStackVpc = new Vpc();+ dualStackVpc.setVpcId("vpc-dualstack");+ dualStackVpc.getIpv6CidrBlockAssociationSet().add(+ new VpcIpv6CidrBlockAssociation("vpc-cidr-assoc-test", "2600:1f18::/56", "us-east-1"));+ when(ec2Service.describeVpcs(eq("us-east-1"), eq(List.of("vpc-dualstack")), eq(Map.of())))+ .thenReturn(List.of(dualStackVpc));++ DbProxy proxy = rdsService.createDbProxy("dualstack-proxy", "POSTGRESQL", true, false, "NONE",+ PROXY_ROLE_ARN, dualStackSubnetIds, List.of(), PROXY_AUTH,+ 1800, false, Map.of(), "us-east-1", "DUAL", "IPV6");++ assertEquals("DUAL", proxy.getEndpointNetworkType());+ assertEquals("IPV6", proxy.getTargetConnectionNetworkType());+ }++ @Test+ void createDbProxyRejectsIpv6NetworkTypeWhenSubnetsHaveNoIpv6CidrBlock() {+ List<String> mixedSubnetIds = List.of("subnet-mixed-a", "subnet-mixed-b");+ when(ec2Service.describeSubnets(eq("us-east-1"), eq(mixedSubnetIds), eq(Map.of())))+ .thenReturn(List.of(+ subnet("subnet-mixed-a", "vpc-mixed", "us-east-1a"),+ subnet("subnet-mixed-b", "vpc-mixed", "us-east-1b")));+ Vpc dualStackVpc = new Vpc();+ dualStackVpc.setVpcId("vpc-mixed");+ dualStackVpc.getIpv6CidrBlockAssociationSet().add(+ new VpcIpv6CidrBlockAssociation("vpc-cidr-assoc-mixed", "2600:1f18::/56", "us-east-1"));+ when(ec2Service.describeVpcs(eq("us-east-1"), eq(List.of("vpc-mixed")), eq(Map.of())))+ .thenReturn(List.of(dualStackVpc));++ AwsException rejected = assertThrows(AwsException.class, () ->+ rdsService.createDbProxy("mixed-proxy", "POSTGRESQL", true, false, "NONE",+ PROXY_ROLE_ARN, mixedSubnetIds, List.of(), PROXY_AUTH,+ 1800, false, Map.of(), "us-east-1", "DUAL", null));+ assertEquals("InvalidParameterValue", rejected.getErrorCode());+ assertTrue(rejected.getMessage().contains("VpcSubnetIds"));+ assertTrue(rdsService.listDbProxies(null).isEmpty());+ }+@Testvoid createDbProxyValidatesAndPersistsDefaultAuthScheme() {DbProxy iamProxy = rdsService.createDbProxy(