feat(go): add PGAdapter for PostgreSQL wire protocol proxy to DSQL#320
Draft
feat(go): add PGAdapter for PostgreSQL wire protocol proxy to DSQL#320
Conversation
Export ResolveCredentialsProvider with explicit parameters (region, profile, customProvider) instead of the internal resolvedConfig struct. This allows the pgadapter package to resolve credentials using the same logic without depending on internal types.
Add pgadapter package that proxies PostgreSQL wire protocol to Aurora DSQL with transparent IAM authentication. Clients connect without credentials; the adapter handles token generation.
Add dsql-pgadapter CLI that provides a PostgreSQL wire protocol proxy for Aurora DSQL. The CLI includes: - Version flag (1.0.0) - Required --endpoint flag for DSQL cluster endpoint - Optional --region, --listen, --user, --database, --profile flags - Verbose logging with --verbose flag - Graceful shutdown on SIGINT/SIGTERM
Add tests for the pgadapter.New() function covering: - Valid configuration with defaults applied - Missing DSQLEndpoint error handling - Invalid endpoint that cannot be parsed for region - Custom configuration values override defaults
Add end-to-end integration test for pgadapter that: - Starts adapter on random port (127.0.0.1:0) - Polls for adapter ready state (up to 5 seconds) - Connects using standard pgx (simulates OpenFGA) - Tests SELECT 1, CREATE TABLE, INSERT, SELECT, DROP TABLE - Verifies clean shutdown Also adds testify dependency and local module replace directive for development.
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.
Summary
Adds a PostgreSQL wire protocol proxy (PGAdapter) that allows unmodified PostgreSQL clients like OpenFGA to connect to Aurora DSQL with automatic IAM authentication.
Problem: OpenFGA and other PostgreSQL clients use
pgxpool.ParseConfig()which only recognizespostgres://andpostgresql://schemes. When given adsql://URL, pgx falls back to Unix socket connections which fail.Solution: A lightweight TCP proxy that:
This follows the same pattern as Google Spanner's PGAdapter.
Changes
dsql/token.go: ExportResolveCredentialsProviderfor reuse by pgadapterpgadapter/: New package implementing the PostgreSQL wire protocol proxyconfig.go- Configuration typesadapter.go- Core adapter withListenAndServe()proxy.go- PostgreSQL protocol handlingadapter_test.go- Unit testscmd/dsql-pgadapter/: CLI commandexample/test/pgadapter/: E2E integration test against real DSQL cluster.github/workflows/go-pgx-integ-tests.yml: Updated CI to run pgadapter testsUsage
Test plan
go test ./pgadapter/...)go test ./dsql/...)