Use Terraform on Google Cloud SQL Postgres to create a Replication Slot - postgresql

Overall I'm trying to create a Datastream Connection to a Postgres database in Cloud SQL.
As I'm trying to configure it all through Terraform, I'm stuck on how I should create a Replication Slot. This guide explains how to do it through the Postgres Client and running SQL commands, but I thought there might be a way to do it in the Terraform configuration directly.
Example SQL that I would like to replicate in Terraform:
ALTER USER [CURRENT_USER] WITH REPLICATION;
CREATE PUBLICATION [PUBLICATION_NAME] FOR ALL TABLES;
SELECT PG_CREATE_LOGICAL_REPLICATION_SLOT('[REPLICATION_SLOT_NAME]', 'pgoutput');
If not, does anyone know how to run the Postgres SQL commands against the Cloud SQL database through Terraform?
I have setup the Datastream and Postgres connection for all other parts. I'm expecting that there is a Terraform setting I'm missing or a way to run Postgres commands against the Google Cloud SQL Postgres database.

Unfortunately, there is no terraform resource for specifying a replication slot on a google_sql_database_instance.

Related

Refresh postgres materialized view using scheduler

I was trying to figure-out how we can schedule to refresh the materialized view on azure postgres database single server which is in azure cloud, one solution is to use pg_cron extension, but it
seems it is only available on azure flexible postgres database server and not on azure postgres database single server, I did not get any other option available, any suggestion in this regard will be really helpful.
I did not find any postgres scheduler extension for the db hosted on Azure, so created one microservice to schedule the db functions.
Example Link

GCP Cloud SQL Terraform Postgres extension

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.

Connect AWS Athena to Postgres SQL

I need to connect AWS Athena (which is binded to AWS s3 bucket) to a Postgres SQL database.
I have tried to connect with Tableau and PowerBI successfully (following the instructions in documentation) and the result was successful.
I think that I need to use the JDBC connector already installed on my machine and try to create a server in Postgres, but I cannot see any option in pgadmin in order to connect AWS athena to the server.
Any ideas?
Thank you in advance!

How do I connect from Azure Data Factory to an AWS-hosted Postgres database?

I have a Postgres database created on Heroku but looks like it's spun up on AWS based on the server name. Unfortunately, I can't tell if it's an Aurora or RDS instance.
I'm trying to create some data pipelines on Azure Data Factory to do some ETL work moving Blob files onto the Postgres Database but am having a tough time setting it up. The default Postgres option isn't working - looks like DataFactory tries to make a JDBC connection.
I'm stuck and am clueless as to how I should set up the connection.

Adding Amazon RDS as slave to external postgresql

We want to migrate an external postgresql database into amazon RDS however for some time we need to keep both of them working and in sync. I have found ways of doing it but only with RDS being the master and not the Slave. Is there a good and viable solution which could help us?
There is AWS service Database Migration Service which can be used to migrate external databases to Amazon AWS RDS.
https://docs.aws.amazon.com/dms/latest/userguide/Welcome.html
It supports postgresql 9.4 and higher.
There are different task types and you need to use Ongoing Replication to keep them sync.
https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Task.CDC.html
To setup that task you need to enable Logical Replication for source database