0

So I'm trying to create a FDW in a running v12 Postgres RDS instance.

The extension already exists, but for some reason I cannot create one. This seems crazy simple having come from an on premises set up.

What am I missing here ?

   sourceDatabase=> create extension postgres_fdw ; 
ERROR:  extension "postgres_fdw" already exists
sourceDatabase=> create foreign data wrapper testwrap ; 
ERROR:  permission denied to create foreign-data wrapper "testwrap"
HINT:  Must be superuser to create a foreign-data wrapper.
sourceDatabase=> \du
                                                               List of roles
         Role name         |                   Attributes                   |                          Member of                           
---------------------------+------------------------------------------------+--------------------------------------------------------------
 rds_superuser             | Cannot login                                   | {pg_monitor,pg_signal_backend,rds_replication,rds_password}
 rdsadmin                  | Superuser, Create role, Create DB, Replication+| {}
                           | Password valid until infinity                  | 
 rdsrepladmin              | No inheritance, Cannot login, Replication      | {}
 sourceUser                | Create role, Create DB                        +| {rds_superuser}
                           | Password valid until infinity                  | 
6
  • So what user are you doing this as because the prompt would seem to say you are not doing it as a superuser. Commented Nov 15, 2020 at 22:08
  • I’m doing this as the user sourceUser Commented Nov 15, 2020 at 22:22
  • The error message: ERROR: permission denied to create foreign-data wrapper "testwrap" HINT: Must be superuser to create a foreign-data wrapper. tells you can't do that without becoming a superuser. You will need to do this as rdsadmin. Commented Nov 15, 2020 at 22:26
  • and my understanding is I cannot connect as this user, unless this has changed ? Commented Nov 15, 2020 at 22:45
  • So.. the syntax is different in RDS. docs.aws.amazon.com/AmazonRDS/latest/UserGuide/… Commented Nov 15, 2020 at 23:19

2 Answers 2

4

If you have the postgres_fdw extension installed, you already have a foreign data wrapper called postgres_fdw, so there is no need to create another one.

Use \dew in psql to verify that there is already a foreign data wrapper.

What you need to do now is create a foreign server that contains the connect string to the remote PostgreSQL database, a user mapping that contains the authentication information for that database and foreign tables which point to tables in the remote database.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I was tripping over myself.
1

What Adrian Klaver said is correct. (What is different is whether you want to create a wrapper or a server).

Foreign data wrapper:

This is Postgres's native feature to access the data across the multiple databases including databases like Postgres, Oracle, Redis and etc. The funny fact is you can read your Twitter messages via the foreign-data wrapper. Here is the list of active wrappers.

But you have to write the handlers and etc to access the data.

https://www.postgresql.org/docs/10/sql-createforeigndatawrapper.html

Postgres_FDW:

postgres_fdw is an extension developed under the postgres's contrib library and it's only specific to Postgres to make the Postgres integration much easier. All the necessary handlers and the functions are bundled with this extension.

Creating the foreign data wrappers needs the real superuser permission and it won't work rds_superuser.

The functionality provided by this module overlaps substantially with the functionality of the older dblink module. But postgres_fdw provides more transparent and standards-compliant syntax for accessing remote tables, and can give better performance in many cases.

So please refer to the postgres_fdw documentation instead of the Foreign data wrapper document.

OR better refer to the official AWS RDS doc which is already shared by VynlJunkie(in the comments section)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.