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

google_sql_user has no privileges #3028

Closed
YaraMohammed opened this issue Feb 11, 2019 · 5 comments
Closed

google_sql_user has no privileges #3028

YaraMohammed opened this issue Feb 11, 2019 · 5 comments
Labels
bug forward/review In review; remove label to forward service/sqladmin-infra

Comments

@YaraMohammed
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

v0.11.11

Affected Resource(s)

  • google_sql_user

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://www.hashicorp.com/security
# If reproducing the bug involves modifying the config file (e.g., apply a config,
# change a value, apply the config again, see the bug) then please include both the
# version of the config before the change, and the version of the config after the change.
resource "google_sql_database_instance" "master" {
    
  provider      = "google"

  depends_on = ["google_service_networking_connection.private_vpc_connection"]

  name = "${var.instanse_name}"
  database_version = "${var.database_version}"

  settings {
    tier = "${var.tier}"
    ip_configuration {
            private_network = "${var.internal_network_selflink}"
        }
  }
}

resource "google_sql_database" "db" {
  provider      = "google"
  name      = "${var.db_name}"
  instance  = "${google_sql_database_instance.master.name}"
}

resource "random_id" "user-password" {
  byte_length = 8
}

resource "google_sql_user" "db-user" {
  provider      = "google"
  name     = "${var.user_name}"
  instance = "${google_sql_database_instance.master.name}"
  password = "${var.user_password == "" ? random_id.user-password.hex : var.user_password}"
}

Debug Output

Access denied for user

All resources are created but the cloudsql user has no privileges
from gcp cloud shell ERROR 1141 (42000): There is no such grant defined for user 'newuser' on host '%'

Panic Output

Expected Behavior

Generated user has privileges as the user created from UI or add option to the resource to grant privileges

Actual Behavior

User has no privileges at all

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@ghost ghost added the bug label Feb 11, 2019
@Chupaka
Copy link
Contributor

Chupaka commented Feb 11, 2019

Did you try to add host = '%' to google_sql_user resource?

@YaraMohammed
Copy link
Author

@Chupaka Yes that solved the problem, Thank you

@YaraMohammed
Copy link
Author

@Chupaka I'm using private IP in an associated network for google_sql_database_instance but the public IP is created anyway and I can't find an argument to disable it in the resource documentation, Is there is a way to disable the creation of the public IP if there is a private one? Sorry I'm a bit new to terraform

@Chupaka
Copy link
Contributor

Chupaka commented Feb 12, 2019

@YaraMohammed sorry, have no idea about public IP

@ghost
Copy link

ghost commented Mar 14, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 14, 2019
@github-actions github-actions bot added forward/review In review; remove label to forward service/sqladmin-infra labels Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug forward/review In review; remove label to forward service/sqladmin-infra
Projects
None yet
Development

No branches or pull requests

2 participants