I have a RDS Postgres instance. I have launched this instance using CloudFormation template. I am able to add PostGIS extension on this instance.
I will be using this template to launch multiple RDS instance frequently and every time I would need PostGIS extension on the instance. Is there any way, I can automate installation of Postgres extensions on RDS.
According to the RDS documentation the only way to enable this is by running the below SQL statement.
create extension postgis;
CREATE EXTENSION
create extension fuzzystrmatch;
CREATE EXTENSION
create extension postgis_tiger_geocoder;
CREATE EXTENSION
create extension postgis_topology;
CREATE EXTENSION
For this to happen a resource needs to be able to perform the SQL statement which requires an additional resource in order to apply this statement.
CloudFormation supports custom resources which allow a Lambda function to perform custom functionality. This Lambda would need to be able to connect to your RDS to perform the SQL command.
Related
I'm using pgAdmin to backup/restore a database from one Azure PostgreSQL Flexible server to another. The source server was created last year, the destination server is new.
The restore process fails early with the error:
ERROR: extension "azure" is not allow-listed for "azure_pg_admin" users in Azure Database for PostgreSQL
I came across this post https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/introducing-ability-to-allow-list-extensions-in-postgresql/ba-p/3219124 announcing recent changes to PostgreSQL Flexible Server. If I'm reading this correctly, my new database server is affected by this change and I need to allow specific extensions under the "azure.extensions" server parameter.
In the backup file I can see:
CREATE EXTENSION IF NOT EXISTS azure WITH SCHEMA public;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
And in Azure Portal I can see "UUID-OSSP" under the new "azure.extensions" server parameter, though there's nothing called just "azure". I enabled UUID-OSSP but the restore process still fails with the same error.
What am I missing here?
It's suggestable to install TimescaleDB that is having the package of supportive extension.
To learn abot TimescaleDB. (https://docs.timescale.com/timescaledb/latest/)
Change the Postgres's parameters for "shared_preload_libraries"
After creating extension
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
Follow the entire procedure from the below link.
https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-extensions
Is there an official way of installing an extension on a GCP Postgress Cloud SQL instance via Terraform?
Closest I've found is this unofficial Postgres resource but it's not immediately clear how to link the two. This issue on their tracker sort of shows how, but far from a step by step guide.
if it makes any difference, I'm trying to provision a Postgres Cloud SQL instance with PostGIS.
Thanks.
Terraform is a deployment tool, to create all your infrastructure. To install an extension on Postgres, you need a installation tool, because you need to connect to the database and to run a command.
It's the same thing if you want to create a user in the database and you want to grant some privileges on it.
In summary, you can't achieve that with Terraform. I recommend you to have an installation tool, such as Ansible to perform this action.
An alternative is to create, with Terraform, a micro VM with a startup script that connect the database, run the command and destroy itself at the end.
I have a AWS PostgreSQL RDS instance. I want to create mysql_fdw extension to communicate to MySQL RDS. When I try to create this extension, I am getting the following error
ERROR: Extension "mysql_fdw" is not supported by Amazon RDS
DETAIL: Installing the extension "mysql_fdw" failed, because it is not on the list of extensions supported by Amazon RDS.
HINT: Amazon RDS allows users with rds_superuser role to install supported extensions. See: SHOW rds.extensions;*
Is there any way to create this extension in AWS RDS?
Available extensions are listed be the below and are specific to Postresql version.
No version currently has mysql_fdw
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#CHAP_PostgreSQL.Extensions.log_fdw
Per the below, you cannot add your own Extensions to RDS
https://dba.stackexchange.com/questions/111477/amazon-rds-postgresql-adding-new-extensions
Might be specifically because you need MySQL's C client library.
Not going to be able to do this
Would require have super user access to underlying VM which would be a huge risk for AWS
Running create extension redis_fdw gives below error. Currently is there any alternative way to create foreign data wrapper for redis and achieve similar goals as this project on RDS ?
Extension "redis_fdw" is not supported by Amazon RDS
redis-fdw extension need it's native c libs installed on your servers, this is not allowed on amazon rds, you should use this in amazon ecs server, install postgresql and redis-fdw by yourself
I am following this tutorial
http://technobytz.com/install-postgis-postgresql-9-3-ubuntu.html
and i created db with this command
createdb test_db -T template_postgis2.1
but i get this error
test_db2=# select postgis_version();
ERROR: function postgis_version() does not exist
LINE 1: select postgis_version();
This works if use
create extension postgis
i want to know that is that ok or i have error. because i made the template before. Didn't that template automatically make the db as postgis
According to the official documentation on the topic, you have to create the extension in each new database you create. Why? This has to do with a change in the way a database is PostGIS-enabled in PostgreSQL-9.1+ and PostGIS-2+. Previously, there were a series of scripts that had to be run to load the functions, types, and other features of PostGIS into a database. Consequently, the best practice was to create a template database (template_postgis, etc.), run all the scripts against that template, and create each new PostGIS-enabled database against that template. In newer versions of PostgreSQL (9.1+), you can enabled PostGIS support within a new database by simply executing the command CREATE EXTENSION postgis; as such, you should skip the template step entirely.
So to sum up:
CREATE EXTENSION postgis; is the way to go for PostgreSQL-9.1+ and PostGIS-2+
Making a template database is the way to go for prior versions of PostgreSQL or PostGIS.
I hope that helps clear it up!