Any recommendations on how to wait for an AWS RDS database host to be provisioned before creating a database or user? To accomplish this, I am attempting to use depends_on parameter in order for it to wait for the RDS database to be provisioned first. It seems the provider cannot wait for the resource.
I get the following error when running this:
The provider argument name "depends_on" is reserved for use by Terraform in a future version.
--- Terraform Plan Snippet ----
# 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]
}
In the upper-right corner of the Amazon RDS console, choose the AWS Region in which you want to create the DB instance. In the navigation pane, choose Databases. Choose Create database. In Choose a database creation method, select Standard Create.
It is the basic building block of Amazon RDS. A DB instance can contain multiple user-created databases, and can be accessed using the same client tools and applications you might use to access a standalone database instance.
Note that RDS for SQL Server has a limit of up to 100 databases on a single DB instance to learn more see the Amazon RDS for SQL Server User Guide. If your application requires more DB instances, you can request additional DB instances via this request form.
Provisioned IOPS storage is a storage type that delivers predictable performance, and consistently low latency. Provisioned IOPS storage is optimized for online transaction processing (OLTP) workloads that have consistent performance requirements. Provisioned IOPS helps performance tuning of these workloads.
I asked about this in the postgres provider repository in a GitHub Issue, and the maintainers were able to provide a workaround for this - if you specify the expected_version
in the provider configuration, it does not attempt to connect until a resource actually uses the connection.
This means that the dependency behavior of resources can be used to prevent connection until Terraform finishes the setup of the RDS resource. This seems to work in both the plan
case and the apply
case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With