From 675ecdcfa2758a29496a02dacce432b77d828a04 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 15 Feb 2019 15:34:14 -0600 Subject: [PATCH] Add Connect To An RDS PostgreSQL Database as a devops til --- README.md | 3 ++- .../connect-to-an-rds-postgresql-database.md | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 devops/connect-to-an-rds-postgresql-database.md diff --git a/README.md b/README.md index a1b1d34..3afce7a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_765 TILs and counting..._ +_766 TILs and counting..._ --- @@ -108,6 +108,7 @@ _765 TILs and counting..._ - [Allow HTTPS Through Your UFW Firewall](devops/allow-https-through-your-ufw-firewall.md) - [Check The Status of All Services](devops/check-the-status-of-all-services.md) - [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md) +- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md) - [Determine The IP Address Of A Domain](devops/determine-the-ip-address-of-a-domain.md) - [Path Of The Packets](devops/path-of-the-packets.md) - [Push Non-master Branch To Heroku](devops/push-non-master-branch-to-heroku.md) diff --git a/devops/connect-to-an-rds-postgresql-database.md b/devops/connect-to-an-rds-postgresql-database.md new file mode 100644 index 0000000..bbf7340 --- /dev/null +++ b/devops/connect-to-an-rds-postgresql-database.md @@ -0,0 +1,27 @@ +# Connect To An RDS PostgreSQL Database + +You can connect to an RDS PostgreSQL database remotely via `psql`. First, +you need to tell AWS that connections from your IP address are allowed. This +is done by configuring the VPC (Virtual Private Cloud) that is associated +with the RDS instance. You'll need to add an inbound rule to the Security +Group associated with that VPC. You'll add an inbound rule that allows a +Postgres connection on port 5432 from your IP address -- which is identified +by a [CIDR +address](https://www.digitalocean.com/community/tutorials/understanding-ip-addresses-subnets-and-cidr-notation-for-networking#cidr-notation). + +![create inbound rule](https://i.imgur.com/Ypb9Du7.png) + +Once this rule has been added to the security groups associated with the VPC +that is associated with your RDS instance, you'll be able to connect from +your machine with `psql`. + +```bash +$ psql my-rds-endpoint.cbazqrhkmyo.us-east-1.rds.amazonaws.com \ + --port 5432 \ + --user rdsusername \ + postgres +``` + +Assuming the database username is `rdsusername` and the specific database is +named `postgres`, you'll be prompted for that user's password and then +connected.