cloud-sql-proxy
cloud-sql-proxy copied to clipboard
Using Foreign Data Wrapper (FDW) with GCP IAM authentication through Cloud SQL Proxy
trafficstars
Question
Description
I'm trying to use PostgreSQL Foreign Data Wrapper (FDW) with GCP Cloud SQL while authenticating via IAM credentials. The setup uses Cloud SQL Proxy for connection.
My scenario:
- Both the source and target databases are in the same GCP Cloud SQL cluster
- The user connects via Cloud SQL Proxy using IAM authentication
- The user successfully connects to the primary database
- When trying to use FDW to access another database in the same cluster, authentication fails
What I've tried
The server entity is already created. I've attempted the following USER MAPPING options:
-- Option 1: No password specified
CREATE USER MAPPING FOR "[email protected]"
SERVER financial_reporter_server
OPTIONS (user '[email protected]');
-- Option 2: Empty password
CREATE USER MAPPING FOR "[email protected]"
SERVER financial_reporter_server
OPTIONS (user '[email protected]', password '');
-- Option 3: Explicitly setting password as not required
CREATE USER MAPPING FOR "[email protected]"
SERVER financial_reporter_server
OPTIONS (user '[email protected]', password_required 'false');
Questions
Is it possible to use postgres_fdw with IAM authentication through Cloud SQL Proxy? How should USER MAPPING be configured to work with GCP IAM credentials? Does Cloud SQL Proxy support forwarding IAM authentication for FDW connections?
Any guidance would be greatly appreciated. Thank you!