(Terraform)错误400:无效请求:实例名称(pg_instance)。,无效
在 GCP 上,我试图使用使用 此Terraform Code 以下:
resource "google_sql_database_instance" "postgres" {
name = "pg_instance"
database_version = "POSTGRES_13"
region = "asia-northeast1"
deletion_protection = false
settings {
tier = "db-f1-micro"
disk_size = 10
}
}
resource "google_sql_user" "users" {
name = "postgres"
instance = google_sql_database_instance.postgres.name
password = "admin"
}
但是我得到了这个错误:
错误:错误,无法创建实例pg_instance:googleapi:错误400:无效请求:instance name(pg_instance)。,无效
。
On GCP, I'm trying to create a Cloud SQL instance with this Terraform code below:
resource "google_sql_database_instance" "postgres" {
name = "pg_instance"
database_version = "POSTGRES_13"
region = "asia-northeast1"
deletion_protection = false
settings {
tier = "db-f1-micro"
disk_size = 10
}
}
resource "google_sql_user" "users" {
name = "postgres"
instance = google_sql_database_instance.postgres.name
password = "admin"
}
But I got this error:
Error: Error, failed to create instance pg_instance: googleapi: Error 400: Invalid request: instance name (pg_instance)., invalid
Are there any mistakes for my Terraform code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于,云SQL实例名称,仅允许小写字母,数字和连字符,它必须以字母开始。
因此,对此进行更改:
对此:
此外,在 gui 上,您可以在下面在下面看到此消息,例如,空白为例如ID(Terraform中的“名称”):
For a Cloud SQL instance name, only lowercase letters, numbers, and hyphens are allowed and it must start with a letter.
So, change this:
To this:
In addition, on GUI, you can see this message below under the blank for instance ID("name" in Terraform):