3
votes

I am trying to enable some Postgres extensions to specific user in AWS RDS Postgres instance.

1) I have tried through deployment using rails migration, didnt work.

class InstallPgTrgmContribPackage < ActiveRecord::Migration[5.1]
  def change
    enable_extension "fuzzystrmatch"
    enable_extension "pg_trgm"
    enable_extension "unaccent"

    # execute "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;"
    # execute "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
    # execute "CREATE EXTENSION IF NOT EXISTS unaccent;"
  end
end

2) Also, tried through ssh-ing into postgres and create it from there.

psql -h blabla.us-east-1.rds.amazonaws.com -p 5432 -U prod -d prod

prod=> CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
returns: ERROR:  permission denied to create extension "fuzzystrmatch"
          HINT:  Must be superuser to create this extension.

By default RDS instance role is test, and I am able to create extension in test user. I am trying to install in prod and dev users.

enter image description here

The rails application deployed through Elastic Beanstalk.

Question: How to add superuser privileges into new user role?

1
Test user is rds_superuser member, how can i make dev and prod member of rds_superuser ? - 7urkm3n
What is your question? - sawa
@sawa Trying to create pg_trgm extension in dev and prod user roles, and it returns Must be superuser to create this extension. - 7urkm3n

1 Answers

6
votes

It seems like the prod user does not have superuser priviledges:

As stated from AWS Docs:

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

1. create role testuser with password 'testuser' login;   
   CREATE ROLE   

2. grant rds_superuser to testuser;   
   GRANT ROLE   

Point 1 has already been done as there is a prod user

Thus, you need to run point 2 command to grant priviledges.