【发布时间】:2019-09-14 00:01:27
【问题描述】:
我正在尝试正确设置我的基础架构,并且没有密码或密钥。 AWS RDS 可以选择这样做,让用户(应用程序)使用生成的令牌进行身份验证。
但是,在文档中,其中一个步骤 (this one) 需要在 Postgres 数据库中运行查询以创建用户并授予他特定权限:
CREATE USER test_rds WITH LOGIN;
GRANT rds_iam TO test_rds;
我想使用 Terraform 配置整个堆栈。我在 RDS 实例化后查找了一些“hacks”来运行查询 (here),方法是:
resource "null_resource" "db_setup" {
depends_on = ["aws_db_instance.your_database_instance", "aws_security_group.sg_allowing_external_access"]
provisioner "local-exec" {
// run shell commands to manually psql into the db
或:
resource "aws_instance" "web" {
provisioner "remote-exec" {
inline = [
// run shell commands to manually psql into the db
但它们都需要创建主密码并以某种方式将其传递到“脚本”中。
是否可以使用 Terraform 干净地做到这一点,没有硬编码的密码被传递?
我很想配置数据库并仅启用具有正确 permissions 的特定 EC2/ECS 实例来访问它,而我的 git 存储库中没有任何密码。
【问题讨论】:
标签: postgresql amazon-web-services amazon-rds terraform infrastructure-as-code