Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Terraform postgresql provider: SSL is not enabled on the server

I am trying to create a database in the created postgres RDS in AWS with postgresql provider. The terraform script i have created is as following:

    resource "aws_db_instance" "test_rds" {
  allocated_storage        = "" # gigabytes
  backup_retention_period  = 7   # in days
  engine                   = ""
  engine_version           = ""
  identifier               = ""
  instance_class           = ""
  multi_az                 = ""
  name                     = ""
  username                 = ""
  password                 = ""
  port                     = ""
  publicly_accessible      = "false"
  storage_encrypted        = "false"
  storage_type             = ""
  vpc_security_group_ids   = ["${aws_security_group.test_sg.id}"]
  db_subnet_group_name     = "${aws_db_subnet_group.rds_subnet_group.name}"
}

The postgresql provider is as following:

# Create databases in rds
provider "postgresql" {

  alias           = "alias"
  host            = "${aws_db_instance.test_rds.address}"
  port            =  5432
  username        = 
  password        = 
  database        = 
  sslmode         = "disable"

}

# Create user in rds
resource "postgresql_role" "test_role" {
  name             = 
  replication      = true
  login            = true
  password         = 
}

# Create database rds
resource "postgresql_database" "test_db" {
  name              = testdb
  owner             = "${postgresql_role.test_role.name}"
  lc_collate        = "C"
  allow_connections = true
  provider          = "postgresql.alias"
}

Anyway i keep retrieving Error: Error initializing PostgreSQL client: error detecting capabilities: error PostgreSQL version: pq: SSL is not enabled on the server

Note: the empty fields are already filled and the RDS is successfully created, the problem rises when trying to create the database in the rds with the postgresql provider.

like image 631
Mr 123 Avatar asked Oct 28 '25 12:10

Mr 123


2 Answers

We ran into this issue as well, and the problem was that the password was not defined. It seems that we will get the SSL is not enabled error when it has problems connecting. We also had the same problem when the db host name was missing. You will need to make sure you define all of the fields needed to connect in Terraform (probably database and username too).

like image 168
user2059166 Avatar answered Oct 30 '25 09:10

user2059166


Ensuring there was a password set for the postgres user and disabled sslmode, did it for me

sslmode = "disable"

like image 40
Gidi9 Avatar answered Oct 30 '25 11:10

Gidi9



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!