Closed ScottPierce closed 2 years ago
Not sure if this could impact things, but I'm using a service account from another project to create this.
Hi @ScottPierce! Looks like _
is not allowed in the sql database instance name. Only lowercase letters, numbers, or hyphens are allowed in the name and it should always start with a letter. Could you please try naming your instance in the correct format and see if that works for you? (e.g. instance-name
should be working)
I was trying this with a name that didn't have an underscore in it originally and I was getting the same invalid name error. I'll try it again when I get home.
I just tried the following:
resource "google_sql_database_instance" "primary-instance" {
project = google_project.default.id
name = "instance-name"
database_version = "MYSQL_5_7"
region = "us-central1"
settings {
tier = "db-f1-micro"
}
}
resource "google_sql_database" "database" {
project = google_project.default.id
name = "database-name"
instance = google_sql_database_instance.primary-instance.name
charset = "utf8"
collation = "utf8_general_ci"
}
resource "google_sql_user" "users" {
project = google_project.default.id
name = "root"
instance = google_sql_database_instance.primary-instance.name
host = "%"
password = "XXXXXXXXX"
}
And I'm still getting the same error:
google_sql_database_instance.primary-instance: Creating...
╷
│ Error: Error, failed to create instance instance-name: googleapi: Error 400: Invalid request: Invalid full instance name (projects/azapp-int-agry:instance-name).., invalid
│
│ with google_sql_database_instance.primary-instance,
│ on cloud-sql.tf line 22, in resource "google_sql_database_instance" "primary-instance":
│ 22: resource "google_sql_database_instance" "primary-instance" ***
│
╵
Error: Process completed with exit code 1.
For good measure I tried the below configuration with the same result as well:
resource "google_sql_database_instance" "fjhaksjhdfjhaf" {
project = google_project.default.id
name = "asdfjkasdfk"
database_version = "MYSQL_5_7"
region = "us-central1"
settings {
tier = "db-f1-micro"
}
}
Here is the full debug log of me trying a configuration without any underscores.
Oh, it looks like that project_id
should be used for google_project.default.id
instead of id
. Could you try that and see if that solves your problem?
Thanks - that fixed it
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
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 tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v1.1.3 on linux_amd64
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Database was created
Actual Behavior
Error
Steps to Reproduce
I've been trying to solve this for hours. Terraform is creating the entire project, but it won't create any cloudsql databases for some reason, and I can't figure out why. I was trying to create a postgres database, and now I'm just copying terraform samples directly from blogs, and they won't work either. I'm at a loss for what the problem could be.
terraform apply
Important Factoids
References
7878