gruntwork-io / terraform-google-sql

Terraform modules for deploying Google Cloud SQL (e.g. MySQL, PostgreSQL) in GCP
https://gruntwork.io
Apache License 2.0
92 stars 103 forks source link

Add Abbility to Manage DB Users, and Little HOTFIX #59

Closed vovkanaz closed 1 year ago

vovkanaz commented 3 years ago

Hi there, would you mind considering expanding the current module with user management instead of only master user: Something like that:

resource "random_password" "password" {
  count            = length(var.accounts)
  length           = 16
  special          = true
  override_special = "_%@"
}

resource "postgresql_role" "user" {
  count    = length(var.accounts)
  name     = element(var.accounts, count.index)
  login    = true
  password = random_password.password[count.index].result
  depends_on = [
    module.postgres,
  ]
}

resource "postgresql_grant" "user_permissions" {
  count       = length(var.accounts)
  database    = var.service_name
  role        = postgresql_role.user[count.index].name
  schema      = "public"
  object_type = "table"
  privileges  = ["SELECT", "INSERT", "UPDATE", "DELETE"]
  depends_on = [
    module.postgres,
  ]
}

And also we've fixed a little issue during the process of the instance destroying. We've successfully figured out a problem, like in the example below:

Error: Error, failed to delete user adm in instance cloudsql-instance-chimp:

Solution: Add to the root module

deletion_policy = var.deletion_policy

and to the variables:

variable "deletion_policy" {
  description = "The deletion policy for the user. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where users cannot be deleted from the API if they have been granted SQL roles."
  default = "ABANDON"
}

Thanks in advance, and we really appreciate your efforts, so hopefully this functionality will be added to the current module

pixrl commented 3 years ago

I think I am getting the same error when I am using this module.

My terraform version

Terraform v0.15.0
on linux_amd64

Version of the module:

github.com/gruntwork-io/terraform-google-sql.git//modules/cloud-sql?ref=v0.5.0

Encountered error:

Error: Error, failed to deleteuser core in instance postgres-5497:

Looking forward for a patch!

Etiene commented 2 years ago

Apologies for the delay in responding to this issue. Please see below:

Sunset notice

We believe there is an opportunity to create a truly outstanding developer experience for deploying to the cloud, however developing this vision requires that we temporarily limit our focus to just one cloud. Gruntwork has hundreds of customers currently using AWS, so we have temporarily suspended our maintenance efforts on this repo. Once we have implemented and validated our vision for the developer experience on the cloud, we look forward to picking this up. In the meantime, you are welcome to use this code in accordance with the open source license, however we will not be responding to GitHub Issues or Pull Requests.

If you wish to be the maintainer for this project, we are open to considering that. Please contact us at support@gruntwork.io.

eak12913 commented 1 year ago

Closing due to repo sunset