Verify Managed DB VPC attach, role setup, and RLS on a live us-iad cluster #64
Notifications
Due Date
No due date set.
Blocks
Reference: bobby/hapi#64
Reference in new issue
Block a user
Part of #44
Question
Do the database decisions from #53 hold on the real platform? Spin up a throwaway Linode Managed PostgreSQL cluster (Shared 1 GB, 1 node, PostgreSQL 18) attached to a throwaway VPC in
us-iad. Check the following, then destroy everything.us-iad: the cluster provisions withprivate_network { vpc_id, subnet_id, public_access = false }vialinode_database_postgresql_v2, and a Linode in the same VPC subnet can connect over the private hostname withsslmode=verify-fullusing theca_certoutput. Ifus-iadrefuses, tryus-iad-2, thenus-east(Newark), and record which works. The Owner may also confirm the beta rollout status with Akamai.password_encryption: setengine_config_pg_password_encryption = "scram-sha-256"and confirm it withSHOW password_encryption.akmadmin(not a superuser): create ahapidatabase and two roles.hapi_migratorowns the database and a domain schema;hapi_appgets DML only throughALTER DEFAULT PRIVILEGES. Confirm thathapi_appcan't run DDL.hapi_migrator, create a table withENABLE+FORCE ROW LEVEL SECURITYand a policy keyed oncurrent_setting('hapi.principal_id'). Ashapi_app, check thatSET LOCAL hapi.principal_id = ...limits the visible rows, and that leaving it unset returns no rows (no error leak).max_connections: record the actual value.hapi_appcan'tSET ROLE hapi_migratororALTER TABLE ... NO FORCE ROW LEVEL SECURITY. Confirm that aSET LOCALinside a transaction doesn't leak into the next transaction on the same pooled connection.log_statement(or pgaudit) be enabled throughengine_config, and where do those logs surface?When everything passes, close How does hAPI connect to its managed database? (#53) and merge the ADR-0004 draft (branch
draft/adr-0004-database-access) with statusaccepted.Resolved when each check has a recorded pass/fail with evidence. On a failure, record the fallback it triggers: another region (ADR-0003 region change), or app-only enforcement instead of RLS.
Resolution
Run 2026-11-24 with Terraform (linode/linode v4.10) against a throwaway VPC, a PG 18 cluster and a Debian probe VM in
us-iad, then all destroyed (5 resources). The state, keys and passwords were deleted locally. Evidence: checks.sh, main.tf, results 1 GB, results 2 GB, resize probe log.us-iadus-iad, so no region fallback is needed. The private hostname resolves to a VPC IP (10.64.0.x) and only from inside the VPC. TLS 1.3 withverify-fullagainstca_certworks.public_access = false, the public name still resolves (IPv6 and IPv4), but connections from outside the allowlist time out. That includes a public IPv6 Linode in the same region. The allowlist is the enforcing control.password_encryptionscram-sha-256when set viaengine_config_pg_password_encryption.akmadminakmadminisrolsuper=f,createrole,createdb,bypassrls=t. Becausecreaterole_self_grant = inherit,set, it canSET ROLEto any role it creates, soCREATE DATABASE hapi OWNER hapi_migratorworks directly. Database-levelREVOKE/GRANTmust run ashapi_migrator(the owner); run asakmadminthey silently do nothing.pg_authidisn't readable.hapi_appcan't run DDL in the domain schemas or inpublic.hapi_appwith no principal sees 0 rows.SET LOCAL/set_config(..., true)scope correctly, and nothing leaks into the next transaction: afterwards the setting reads'', so the policy must wrap it innullif(..., '').WITH CHECKblocks cross-owner inserts, and cross-owner updates affect 0 rows. ⚠️FORCEputs the ownerhapi_migratorunder RLS too. With no principal it sees 0 rows and can't insert. It can runALTER TABLE ... NO FORCE ROW LEVEL SECURITYinside a transaction (tested, rolled back).max_connectionshapi_appis deniedSET ROLE hapi_migrator,NO FORCE,DISABLE RLSandDROP POLICY. ⚠️ Anyone holdinghapi_appcredentials can set anyhapi.principal_idand read that Person's rows. RLS doesn't protect against leaked app credentials.ALTER ROLE ... SET log_statement/log_min_duration_statementis denied, and no logging or pgaudit settings exist inengine_configor the API. There's no statement audit on the platform, so break-glass auditing has to happen outside the database.Other facts later tickets depend on
*.g2a.akamaidb.netplus public and private IPs and names, soverify-fullalso passes when connecting by IP.private_networkis an attribute (private_network = { ... }), not a block. The account uses Linode Interfaces: instances needlinode_interfacesblocks, and every interface needs an explicitfirewall_id(or-1). This matters for ADR-0003's node provisioning.postgresql/19). The cluster reports PG 18.7.Follow-up amendments for How does hAPI connect to its managed database? are posted on that ticket.