仅在预配AWS RDS实例后,才如何创建用户和数据库?

时间:2019-08-29 19:10:10

标签: terraform

关于在创建数据库或用户之前如何等待预配置AWS RDS数据库主机的任何建议?为此,我尝试使用 depends_on 参数,以使其等待首先提供RDS数据库。似乎提供者无法等待资源。

运行此程序时出现以下错误:

提供者参数名称“ depends_on”保留供Terraform在将来的版本中使用。

---地形计划摘要----

# Provision AWS PostgreSQL Dev Database
resource "aws_db_instance" "dev_db" {
    identifier = "dev"
    allocated_storage    = 100
    storage_type         = "gp2"
    engine               = "postgres"
    engine_version       = "10.9"
    port                 = 1433
    instance_class       = "db.t3.medium"
    name                 = "dev"
    username             = "dev"
    password             = "mydevpassword"
    parameter_group_name = "postgress10"
    tags = {
        Name = "dev"
    }
    skip_final_snapshot = true
}
# Setup PostgreSQL Provider After RDS Database is Provisioned
provider "postgresql" {
    host            = "${aws_db_instance.dev_db.address}"
    port            = 1433
    username        = "dev"
    password        = "mydevpassword"
    depends_on      = [aws_db_instance.dev_db]
}
# Create App User
resource "postgresql_role" "application_role" {
    name                = "dev_appuser"
    login               = true
    password            = "myappuserpassword"
    encrypted_password  = true
    depends_on          = [aws_db_instance.dev_db]
}
# Create Database 
resource "postgresql_database" "dev_db" {
    name              = "mydatabase1"
    owner             = "dev"
    template          = "template0"
    lc_collate        = "C"
    connection_limit  = -1
    allow_connections = true
    depends_on        = [aws_db_instance.dev_db]
}

0 个答案:

没有答案