Skip to content

Error connecting to postgres endpoint using AWS SSM remote port forwarding #525

@CJChristensen

Description

@CJChristensen

I've got an Aurora postgres DB running in a private subnet that I am trying to configure. I've got the AWS CLI SSM remote port forwarding working as I am able to connect using psql CLI and table plus.

However, when I run terraform apply with an active SSM session running I get the following.

Error connecting to PostgreSQL server 127.0.0.1 (scheme: postgres): dial tcp 127.0.0.1:15432: connect: connection refused.

I am using terraform cloud but everything is being ran from a CLI on my local computer here. Not sure if that could be the issue.

Provider blocks I've tried so far

provider "postgresql" {
host = "127.0.0.1"
port = 15432
database = var.db_name
username = var.username
password = var.password
sslmode = "disable"
connect_timeout = 15
superuser = false
}

Also tried this
provider "postgresql" {
host = "localhost"
port = 15432
database = var.db_name
username = var.username
password = var.password
sslmode = "disable"
connect_timeout = 15
superuser = false
}

Not really sure what else to try. If psql and table plus work without issue I would imagine something is happening with the connection string or it has to do with terraform cloud.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions