Repository navigation
feat(rds): DB proxy endpoints - #6062
Conversation
CreateDBProxyEndpoint, DescribeDBProxyEndpoints, ModifyDBProxyEndpoint and DeleteDBProxyEndpoint store endpoints per account and Region, checked against the service model. Each endpoint reports its proxy's own host, so a client connects through it as through the proxy. DescribeDBProxyEndpoints lists each proxy's default endpoint first; it cannot be modified or deleted. Deleting a proxy deletes its endpoints, and endpoint ARNs take tags. Closes floci-io#5805
PR Summary by QodoAdd RDS DB proxy endpoint APIs
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1. Endpoint pages skip items after deletion
|
| OffsetPage<DbProxyEndpoint> page = offsetPage(matching, maxRecords, marker); | ||
| return new ProxyEndpointPage(page.items(), page.marker()); |
There was a problem hiding this comment.
1. Endpoint pages skip items after deletion 📘 Rule violation ≡ Correctness
describeDbProxyEndpoints passes a numeric page offset to offsetPage instead of resuming after the last endpoint's sort key. If an endpoint from the first page is deleted before the next request, the same marker points past the shifted item and the second page silently omits it.
Agent Prompt
## Issue description
Endpoint pagination uses a numeric offset, so deleting an item between requests shifts later items before the offset and causes the next page to skip results.
## Fix Focus Areas
- src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java[6425-6449]
- src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java[9861-9881]
- src/test/java/io/github/hectorvent/floci/services/rds/RdsServiceTest.java[10523-10552]
## Recommended Fix
Encode the last returned endpoint's stable sort key in the marker and, when the exact marker item is absent, begin at the first endpoint whose sort key is greater than the marker. Add a regression test that fetches page one, deletes its last item, fetches page two with the original marker, and verifies the remaining items are returned without an error.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| endpoint.setVpcSecurityGroupIds(vpcSecurityGroupIds == null || vpcSecurityGroupIds.isEmpty() | ||
| ? defaultSecurityGroupOf(vpcId, effectiveRegion) : vpcSecurityGroupIds); |
There was a problem hiding this comment.
5. Endpoints accept nonexistent security groups 🐞 Bug ≡ Correctness
createDbProxyEndpoint and modifyDbProxyEndpoint copy supplied VpcSecurityGroupIds without checking that the groups exist or belong to the endpoint's VPC. A request containing an unknown or other-VPC group succeeds and persists that ID, so subsequent describes report a network configuration that cannot be used as specified.
Agent Prompt
### Issue description
Create and modify accept nonexistent or cross-VPC security group IDs and persist them as endpoint settings.
### Fix Focus Areas
- src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java[6410-6411]
- src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java[6472-6474]
### Recommended Fix
Resolve every supplied security group through EC2 in the caller's Region and account, reject missing groups and groups outside the endpoint's VPC, and retain the current default-group behavior when no IDs are supplied.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if (!"IPV4".equals(networkType)) { | ||
| validateVpcHasIpv6CidrBlock(vpcId, effectiveRegion); | ||
| validateSubnetsHaveIpv6CidrBlock(vpcSubnetIds, effectiveRegion); | ||
| } |
There was a problem hiding this comment.
4. Ipv6 endpoints accept dedicated vpcs 🐞 Bug ≡ Correctness
createDbProxyEndpoint checks IPv6 CIDR associations but does not check the selected VPC's instance tenancy when EndpointNetworkType is IPV6 or DUAL. A dedicated-tenancy VPC with IPv6-enabled subnets passes those checks and yields an available endpoint, although the endpoint API excludes dedicated VPCs for those network types.
Agent Prompt
### Issue description
IPv6 and dual-stack endpoint creation accepts dedicated-tenancy VPCs despite the endpoint network prerequisite.
### Fix Focus Areas
- src/main/java/io/github/hectorvent/floci/services/rds/RdsService.java[6396-6400]
### Recommended Fix
For IPV6 and DUAL, resolve the endpoint VPC and reject dedicated instance tenancy in addition to checking its and its subnets' IPv6 associations; add a dedicated-VPC regression test.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
pgermosen
left a comment
There was a problem hiding this comment.
@avison9 thanks, this is nearly there, just one small thing before approving.
A custom endpoint keeps the proxy's host from when it was created, but restoring after a restart can give the proxy a new host, so default then reports the new one and every custom endpoint the old one. Reading the host from the proxy when building the response would keep them in step.
Follow-ups, separate PR: the IPv6 tenancy rule and the security group checks, which CreateDBProxy is missing too, and a Marker that survives a deletion between pages in the shared RDS paging.
A custom endpoint kept the proxy's host from when it was created, so after a restore gave the proxy a new host, every custom endpoint still reported the old one while default reported the new one. The host is no longer stored with the endpoint: create, describe, modify and delete take it from the proxy when they answer. A missing DBProxyName, DBProxyEndpointName or VpcSubnetIds is now MissingParameter, checked before the proxy is looked up.
|
@pgermosen thanks. Endpoints now take the host from the proxy whenever a response is built, so after a restore every custom endpoint reports the proxy's new host along with Also in this push: a missing Agreed on the follow-ups. The IPv6 tenancy rule, the security group checks (for |
pgermosen
left a comment
There was a problem hiding this comment.
@avison9 thanks, the host now follows the proxy everywhere, and the MissingParameter checks match the model's required members.
Two small things before approving: this now conflicts with main in docs/services/index.md, where the DSQL row landed next to the RDS count, so it needs a rebase. And the tests write org.junit.jupiter.api.function.Executable (five times in RdsServiceTest) and org.junit.jupiter.api.Assertions.assertTrue (in RdsProxyEndpointIntegrationTest) inline; neither file has a clashing name, so both can be imported.
…-endpoints # Conflicts: # docs/services/index.md
pgermosen
left a comment
There was a problem hiding this comment.
@avison9 thanks for the merge, the conflict is gone and the DSQL and RDS rows both read right now.
The inline names from last time are still there, though: org.junit.jupiter.api.function.Executable in RdsServiceTest (lines 10452 to 10491) and org.junit.jupiter.api.Assertions.assertTrue at line 86 of RdsProxyEndpointIntegrationTest. Once those are imports, I don't see anything else.
|
@pgermosen thanks. |
Summary
Closes #5805.
The four DB proxy endpoint actions answered
UnsupportedOperation, so Terraform'saws_db_proxy_endpointfailed at apply, andDescribeDBProxyEndpointscould not list a proxy's default endpoint. They now store endpoints per account and Region and return them as AWS does.aws --endpoint-url http://localhost:4566 rds create-db-proxy-endpoint --db-proxy-name app \ --db-proxy-endpoint-name reader --vpc-subnet-ids subnet-a subnet-b --target-role READ_ONLY # before: An error occurred (UnsupportedOperation) ... Operation CreateDBProxyEndpoint is not supported. # after: {"DBProxyEndpoint": {"DBProxyEndpointName": "reader", "TargetRole": "READ_ONLY", "IsDefault": false, ...}}What changed:
Storage. A new store,
rds-proxy-endpoints.json, keyed by Region and endpoint name likerds-cluster-endpoints.json, holds aDbProxyEndpointrecord.Where an endpoint leads.
Endpointis the proxy's own host, so a client connects through an endpoint as through the proxy, and an IAM token signed for that host verifies there. The host is not stored with the endpoint but read from the proxy for each response, so when a restore gives the proxy a new host, every endpoint reports it along withdefault.TargetRoleis recorded. Floci proxies have one target, so aREAD_ONLYendpoint reaches that target rather than an Aurora reader.CreateDBProxyEndpointchecks what the model and the API reference state:DBProxyEndpointAlreadyExistsFault);TargetRoleREAD_WRITE(the default) orREAD_ONLY, andREAD_WRITEonly for a SQL Server proxy;EndpointNetworkTypeIPV4(the default),IPV6orDUAL, with IPv6 needing an IPv6 block on the VPC and subnets, asCreateDBProxyalready checks;DBProxyName,DBProxyEndpointNameandVpcSubnetIdsrequired, eachMissingParameterwhen left out, checked before the proxy is looked up;InvalidSubnet), through the checkCreateDBProxyuses. The subnets may be in a different VPC from the proxy's;DBProxyEndpointQuotaExceededFault), and anavailableproxy (InvalidDBProxyStateFault).An endpoint with no
VpcSecurityGroupIdsgets its VPC's default security group, as the API reference says.DescribeDBProxyEndpointslists, for each proxy in scope, its default endpoint first, then the endpoints added to it by name. It filters byDBProxyName(DBProxyNotFoundFault) andDBProxyEndpointName(DBProxyEndpointNotFoundFault), and pages byMaxRecords(20 to 100) andMarkerthrough the existingoffsetPagehelper.Filtersis ignored, as the reference says it "is not currently supported".The default endpoint is built from the proxy when described:
default,IsDefaulttrue,READ_WRITE, the proxy's VPC, subnets, security groups and host, with no ARN of its own.ModifyDBProxyEndpointandDeleteDBProxyEndpointrefuse it withInvalidDBProxyEndpointStateFault, and no endpoint can be created or renamed todefault.ModifyDBProxyEndpointrenames an endpoint and replaces its security groups; security groups left out are kept.DeleteDBProxyEndpointreturns the endpoint with statusdeleting.DeleteDBProxydeletes the proxy's endpoints within its existing rollback.Tags.
db-proxy-endpointARNs work withAddTagsToResource,RemoveTagsFromResourceandListTagsForResource, which is how Terraform reads an endpoint's tags.Left out:
READ_ONLYendpoint to Aurora readers, which needs proxies with more than one target.AWS::RDS::DBProxyEndpoint, which can follow.Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
Shapes, limits and error names follow the
rds2014-10-31 service model in botocore 1.43.108. Verified against a local build:rds.batscase creates a proxy and aREAD_ONLYendpoint, lists the default endpoint first, renames the endpoint, deletes it, and getsDBProxyEndpointNotFoundFaulton a second delete. All 20rds.batscases pass.RdsControlPlaneTest.sdkRoundTripsDbProxyEndpointscovers create with tags, describe, rename,InvalidDbProxyEndpointStateExceptionfor the default endpoint, delete andDbProxyEndpointNotFoundException. All 23RdsControlPlaneTestcases pass.aws_db_proxyand anaws_db_proxy_endpoint(READ_ONLY, a security group, tags) apply, and a secondplanreports no changes.planwith no changes.planwith no changes.destroyleaves no proxies and no endpoints.Tests
RdsServiceTestadds ten tests:MissingParameter, with nothing created or changed.RdsProxyEndpointIntegrationTestcovers all four actions, tags, the cascade and the missing members over the Query protocol../mvnw checkstyle:check,make partition-checkandmake docs-checkpass.Checklist
./mvnw testpasses locally (the RDS classes above; the full suite was not run)