Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Allow non superuser users to drop databases owned by other roles #18

Conversation

tomelliff
Copy link
Contributor

Previously allowed non superusers to create databases owned by another user but running a destroy from that same config would error as the connected user isn't an owner of the database.

This is mostly important for Postgres instances in AWS RDS because the user created with the instance doesn't have super user permissions.

Previously allowed non superusers to create databases owned by another user but running a destroy from that same config would error as the connected user isn't an owner of the database.

This is mostly important for Postgres instances in AWS RDS because the user created with the instance doesn't have super user permissions.
@tomelliff
Copy link
Contributor Author

This is just copying the block from https://github.com/terraform-providers/terraform-provider-postgresql/blob/master/postgresql/resource_postgresql_database.go#L119-L131 to allow non super users the ability to drop databases (assuming they have the permission to modify roles).

This is useful for Postgres instances in AWS RDS because the user created with the instance doesn't have super user permissions.

I'm a little unsure of how to test this and noticed there wasn't anything to test the original create database as non super user either. Any pointers on this? Happy to add tests if you can set me in the right direction. For now I've just tested it by building it and running it locally.

@tomelliff
Copy link
Contributor Author

This should fix my issue #17

@tomelliff
Copy link
Contributor Author

tomelliff commented Oct 23, 2017

@radeksimko Sorry to bother you on this pull request as well as the one I opened on the AWS provider but does this need anything more from me before it can be merged? I noticed that this is one of the few providers to get a 1.0 release recently so I guess it's not got much activity?

@vaclavnemec
Copy link

It would be great to have this fixed.

@tomelliff
Copy link
Contributor Author

@radeksimko Does this need anything more from me? This is starting to cause us issues because I can't create dynamic review environments in Gitlab for services that use a Postgres database. I'm considering flipping to use psql CLI tool from a provisioner step on the RDS resource instead if we can't move this forward because it's not possible to destroy an RDS postgres database once you have added a database owned by another user right now.

@sean- sean- merged commit 5490131 into hashicorp:master Dec 19, 2017
@ringods
Copy link

ringods commented Dec 19, 2017

@sean- tnx for the merge. Can we expect a release of this provider soon enough too?

@sean-
Copy link
Contributor

sean- commented Dec 27, 2017

@ringods Yes, it's on my list of things to do this week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants