Skip to content

Commit f51bf71

Browse files
committed
EKS: Wait for DB instance before creating databases
1 parent e6ff556 commit f51bf71

File tree

2 files changed

+11
-10
lines changed
  • infra/terraform/EKS/modules/postgresql
  • tests/registry/ha+tls+external-db_redis

2 files changed

+11
-10
lines changed

infra/terraform/EKS/modules/postgresql/main.tf

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,24 @@ resource "aws_rds_cluster" "aurora" {
5656
}
5757

5858
resource "aws_rds_cluster_instance" "postgresql" {
59-
cluster_identifier = aws_rds_cluster.aurora.id
60-
engine = aws_rds_cluster.aurora.engine
61-
engine_version = aws_rds_cluster.aurora.engine_version
62-
instance_class = "db.t3.medium"
63-
#vpc_security_group_ids = [aws_security_group.allow_psql.id]
59+
cluster_identifier = aws_rds_cluster.aurora.id
60+
engine = aws_rds_cluster.aurora.engine
61+
engine_version = aws_rds_cluster.aurora.engine_version
62+
instance_class = "db.t3.medium"
6463

65-
publicly_accessible = true
64+
publicly_accessible = true
65+
depends_on = [aws_rds_cluster.aurora]
6666
}
6767

6868
resource "null_resource" "create_databases" {
6969
for_each = toset(var.databases)
7070

7171
provisioner "local-exec" {
72-
command = "createdb -h ${aws_rds_cluster.aurora.endpoint} -U ${var.administrator_login} ${each.value}"
72+
command = "until getent hosts ${aws_rds_cluster.aurora.endpoint}; do sleep 5; done; createdb -h ${aws_rds_cluster.aurora.endpoint} -U ${var.administrator_login} ${each.value}"
7373

7474
environment = {
7575
PGPASSWORD = random_password.db_password.result
7676
}
7777
}
78+
depends_on = [aws_rds_cluster_instance.postgresql]
7879
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
k8s_enabled = true
2-
db_enabled = true
1+
k8s_enabled = true
2+
db_enabled = true
33
object_storage_enabled = true
4-
redis_enabled = true
4+
redis_enabled = true

0 commit comments

Comments
 (0)