Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres Module: additional_users requires password #222

Closed
Ulminator opened this issue May 26, 2021 · 5 comments
Closed

Postgres Module: additional_users requires password #222

Ulminator opened this issue May 26, 2021 · 5 comments
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work

Comments

@Ulminator
Copy link
Contributor

When trying to create users with the additional_users variable it looks like the desired functionality is for the user's passwords to be defaulted to random_id.user-password.hex, but this is not working for me. When I don't provide a password for a user in that list of maps, I receive an invalid value error for the variable. Since I now have to provide a password key to the user maps, the following lookup never reaches the "default" option.

resource "google_sql_user" "additional_users" {
  for_each  = local.users
  project     = var.project_id
  name        = each.value.name
  password = lookup(each.value, "password", random_id.user-password.hex)
  instance   = google_sql_database_instance.default.name
  depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}
@morgante
Copy link
Contributor

Have you tried setting the value to null? Like this:

additional_users = [{name: "test", password: null}]

@Ulminator
Copy link
Contributor Author

Yeah when I tried that earlier it failed as well with this error message:

Error: Error, failed to insert user test_user into instance test_instance: googleapi: Error 400: Invalid request: Missing user password for PostgreSQL instance., invalid

  on main.tf line 171, in resource "google_sql_user" "additional_users":
 171: resource "google_sql_user" "additional_users" {

@morgante
Copy link
Contributor

Interesting, this is definitely a bug then. null should be sufficient to accept the default.

We'll put it on the queue, but would also be happy to review a PR.

@morgante morgante added bug Something isn't working P2 high priority issues triaged Scoped and ready for work labels May 27, 2021
@ravisiddhu
Copy link
Contributor

ravisiddhu commented Dec 6, 2022

I am working on this bug. This issue is only fixed in postgres module but still exist in mysql and mssql module.

@imrannayer
Copy link
Collaborator

Fixed in #398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work
Projects
None yet
Development

No branches or pull requests

4 participants