DEV Community

WanjohiChristopher for AWS Community Builders

Posted on

4

Create,Connect,Configure Postgres on AWS Successfully with Python

I have seen many people have been struggling to connect with AWS Postgres. Here is a step by step guide.
Assuming you have already created an account on AWS, on the Console search "RDS" RDS meaning Relational Database Service.
Navigate to databases and click database as shown here:

Postgres

On the pop up choose Postgres, Free tier.

create database
Change the database identifier and create your own password for authentication in python.

DB IDENTIFIER
Remember to make sure the database is public and configure VPC security groups.
This is where you need to be careful. If you are using your company's laptop, the inbound rules will use ip address which might be closed so make sure it's not closed or use your own laptop to connect and use "my ip" or open all ports.

security groups

Once created lets now go to our python and connect using psycopg2.
The following code will connect to postgres successfully.

connection

host:

Endpoint on aws

database:

your database

user:

Postgres if default otherwise change to yours.

Password:

Db password

Thank you. Happy Learning

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay