我正在尝试使用 AWS 机密管理器来声明 RDS 管理员凭证。
- 将变量 RdsAdminCred 中的 rds.tf 中的凭据声明为键/值对
- 在同一个 tf 文件中也声明了秘密
variable "RdsAminCred" {
default = {
username = "dbadmin"
password = "dbadmin#02avia"
}
type = map(string)
}
resource "aws_secretsmanager_secret" "RdsAminCred" {
name = "RdsAminCred"
}
resource "aws_secretsmanager_secret_version" "RdsAminCred" {
secret_id = aws_secretsmanager_secret.RdsAminCred.id
secret_string = jsonencode(var.RdsAminCred)
}
- 我不确定如何在下面的声明中使用秘密字符串来替换用户名和密码的硬编码值。
resource "aws_db_instance" "default" {
identifier = "testdb"
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.medium"
name = "mydb"
username = "dbadmin"
password = "dbadmin#01avia"
任何帮助表示赞赏..