1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Connect To An RDS PostgreSQL Database as a devops til

This commit is contained in:
jbranchaud
2019-02-15 15:34:14 -06:00
parent ebecc46ee0
commit 675ecdcfa2
2 changed files with 29 additions and 1 deletions

View File

@@ -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)

View File

@@ -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.