Vishal R
Vishal R

Reputation: 1379

AWS Cloudformation: Enable PostGIS Extension in RDS from Cloudformation

New to cloudformation. I am spawning PostgreSQL RDS instance using a aws cloudformation script.
Is there a way to enable PostGIS (and other extensions) from aws cloudFormation script?

Upvotes: 6

Views: 1467

Answers (4)

Gökhan Ayhan
Gökhan Ayhan

Reputation: 1299

You should Add Custom Resource, then write a lambda function so that function can connect and run extension create queries.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-lambda.html

Upvotes: 0

tto
tto

Reputation: 11

I think this can be done with AWSUtility::CloudFormation::CommandRunner.

Basically we can run bash command with this (https://aws.amazon.com/blogs/mt/running-bash-commands-in-aws-cloudformation-templates/)

Upvotes: 1

Muhammet Arslan
Muhammet Arslan

Reputation: 985

Working with PostGIS PostGIS is an extension to PostgreSQL for storing and managing spatial information. If you are not familiar with PostGIS, you can get a good general overview at PostGIS Introduction.

You need to perform a bit of setup before you can use the PostGIS extension. The following list shows what you need to do; each step is described in greater detail later in this section.

  • Connect to the DB instance using the master user name used to create the DB instance.
  • Load the PostGIS extensions.
  • Transfer ownership of the extensions to therds_superuser role.
  • Transfer ownership of the objects to the rds_superuser role.
  • Test the extensions.

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html

I'm not sure but maybe you can create a lambda function and RDS with your cloudformation and then you can invoke your lambda to do above steps. You need to try.

best,

Upvotes: 2

Shantanu
Shantanu

Reputation: 2346

I don't think you will be able to achieve it by using cloudformation. Cloudformation is a provisioning tool not a configuration management tool.

Upvotes: 0

Related Questions