【发布时间】:2020-08-05 13:09:21
【问题描述】:
您好,我正在导入资源,但失败了。我不确定问题是什么。谁能指点我如何解决这个错误。
我尝试设置sslmode = "require",得到了同样的错误。
我的 ssl 在数据库中是 on,而 force.ssl 是 off
Terraform v0.12.20
provider.aws v2.58.0 提供者.postgresql v1.5.0 您的 Terraform 版本已过时!最新版本
我的模块: locals.tf:
pgauth_dbs = var.env == "prod" ? var.prod_dbs : var.stage_dbs
变量.tf
variable "stage_dbs" {
type = list(string)
default = ["host_configs", "staging", "staging_preview"]
}
提供者
provider "postgresql" {
version = ">1.4.0"
alias = "pg1"
host = aws_db_instance.name.address
port = aws_db_instance.name.port
username = var.username
password = var.master_password
expected_version = aws_db_instance.name.engine_version
sslmode = "disable"
connect_timeout = 15
}
模块:
resource "postgresql_database" "pgauth_dbs" {
provider = postgresql.pg1
for_each = toset(local.pgauth_dbs)
name = each.value
owner = "postgres"
}
根模块:
module rds {
source = ../../../../tf_module_rds
username = "postgres"
master_password = data.aws_kms_secrets.secrets_password.plaintext["password"]
engine_version = "11.5"
instance_class = "db.m5.xlarge"
allocated_storage = "300"
storage_type = "gp2"
}
terraform import module.rds.postgresql_database.name_dbs[“host_configs”] host_configs
module.rds.postgresql_database.name_dbs[“host_configs”]: Importing from ID “host_configs”…
module.rds.postgresql_database.name_dbs[“host_configs”]: Import prepared!
Prepared postgresql_database for import
module.rds.postgresql_database.name_dbs[\“host_configs”\]: Refreshing state… [id=host_configs]
Error: could not start transaction: pq: no PostgreSQL user name specified in startup packet
【问题讨论】:
-
您的 Terraform sn-ps 充满了缺失的部分,可能是由于大量编辑造成的。示例包括没有
module "rds" {或右大括号的根模块、未定义pg1postgres 提供程序、您的 locals.tf 不是有效的 HCL 以及您在 @987654333 中缺少host_configs的尾随引号@ 变量默认值。您能否阅读minimal reproducible example 指南,了解一个好的、最低限度可重现的示例是什么样的?这将使人们更容易帮助您并回答您的问题。
标签: postgresql amazon-web-services terraform amazon-rds terraform-provider-aws