Repository navigation
AWS CDK: route backend CouchDB traffic inside the VPC instead of via the public ALB - #2529
Merged
PeterBaker0 merged 4 commits intoNov 25, 2026
Conversation
…the public ALB Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…ting it after the fafct Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
PeterBaker0
marked this pull request as ready for review
November 25, 2026 01:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backend Conductor, spatial-worker, capacity-manager, and TTL-cleanup tasks were using
COUCHDB_INTERNAL_URLequal to the public ALB HTTPS URL. Every admin-credentialed Couch call left the VPC, resolved public DNS, and came back through the internet-facing ALB.This change gives Couch a stable VPC hostname via a Route 53 private hosted zone, points
COUCHDB_INTERNAL_URLathttp://couchdb.internal.<baseDomain>:5984, keepsCOUCHDB_PUBLIC_URLas the public HTTPS URL devices already get viabase_url, restricts instance ingress to 5984 from the ALB and Conductor task security groups, and stops the unauthenticated/fallback page from rendering the internal hostname.Proposed Changes
internal.<baseDomain>associated with the stack VPC, plus A recordcouchdb.internal.<baseDomain>→ Couch EC2 private IP (EC2CouchDB).buildConductorRuntimeEnvtakes a distinctcouchDBInternalUrl(no fallback to the public URL). Spatial worker, capacity manager, and TTL cleanup still receiveconductor.environmentwith no second Couch URL overlay.conductor.serviceSecurityGroup.0.0.0.0/0TCP 443 removed in the same change as the internal-URL split.AmazonSSMManagedInstanceCorekept forscripts/ssmCouchTunnel.sh.GET /rendersconfig.couchdbPublicUrlas the clickable URL, and apublicFacingDatabaseReportcopy ofdatabaseValidityReportthat redacts the internal URL/hostname fromserver_msg,database_errors, andvalidate_error.verifyCouchDBConnectionstill records the real internal URL for logs/CLI.stampListingCouchUrlis unchanged (dataDb.base_urlstill fromcouchdbPublicUrl).COUCHDB_INTERNAL_URLtohttps://db.<domain>:443.env-from-cdk-stacknow emits the VPC hostname; laptop access usesssmCouchTunnel.sh.How to Test
Automated (merge gate):
The fallback test in
api/test/healthApp.test.tscallsverifyCouchDBConnection()(real payload includescouchdb.internal.*inserver_msg) and asserts GET/HTML does not.Named manual checks before a production deploy:
COUCHDB_INTERNAL_URLishttp://couchdb.internal.<baseDomain>:5984, that name resolves to the instance private IP, andcurlof that URL returns 200 or 401 (not a TCP failure)../scripts/ssmCouchTunnel.shstill works.Additional Information
Cause of the
1c1be2034443 revertdab0866d9closed unused inbound 443 on the Couch instance SG.1c1be2034restored0.0.0.0/0TCP 443 “due to connectivity issues.”Code path:
COUCHDB_INTERNAL_URLwas still assigned frominput.couchDBEndpoint(the publichttps://<couch-domain>:443URL). Backend Nano/Pouch/JWT-key/migrate/worker traffic therefore left the VPC, resolved the public hostname, and returned through the internet-facing ALB — or, if operators used the instance public IP, hit instance:443 directly. Closing instance 443 while that was still the configured internal endpoint broke Conductor connectivity.This PR does not remove 443 while internal URL equals public URL. 443 is removed only together with pointing
COUCHDB_INTERNAL_URLat the VPC HTTP :5984 hostname, plus an explicit 5984 rule from the Conductor task SG.Checklist