> Source: https://meetrix.io/blogs/postgresql-developer-guide/
> Markdown copy of that page. Cite the URL above, not this file.

Development

# PostgreSQL - Developer Guide

[By Dinesh Chathuranga](https://meetrix.io/blogs/authors/dinesh-chathuranga/) • November 7, 2023 • 7 min read

Welcome to the Meetrix PostgreSQL Developer Guide! This guide is designed to assist you in seamlessly integrating PostgreSQL into your AWS environment through detailed, step-by-step instructions.

## Related Article

[

Effortless PostgreSQL DB Backup Automation: Secure Your Data in the Cloud

Automate PostgreSQL database backups on AWS with Meetrix's pre-configured AMI - secure, scalable, GDPR-ready backup automation for the cloud.

Meetrix.IO - Kelum Sampath

![Effortless PostgreSQL DB Backup Automation](https://meetrix.io/blog-images/paas-products-articles/effortless-postgresql/effortless-postgresql.png)](https://meetrix.io/blogs/effortless-postgresql/)

### Video Guide

Prerequisites

Before you get started with the PostgreSQL AMI, ensure you have the following prerequisites:

-   Basic knowledge of AWS services, including EC2 instances and CloudFormation.
-   An active AWS account with appropriate permissions.
-   Enough vCPU limit to create instances. If you encounter a vCPU quota error when launching the stack, follow [https://meetrix.io/blogs/increase-aws-vcpu-quota/](https://meetrix.io/blogs/increase-aws-vcpu-quota/) to increase your vCPU limit.

## Launching the AMI

### Step 1: Find and Select AMI

1.  Log in to your AWS Management Console.
2.  Navigate to the ["PostgreSQL"](https://aws.amazon.com/marketplace/pp?sku=ecv6k11j3eu3oaor2ljgbnja0&ref=meetrix.io) in AWS Marketplace.

### Step 2: Initial Setup & Configuration

1.  Click the **"Continue to Subscribe"** button.
2.  After subscribing, you will need to accept the terms and conditions. Click on **"Accept Terms"** to proceed.
3.  Please wait for a few minutes while the processing takes place. Once it's completed, click on **"Continue to Configuration"**.
4.  Select the **"CloudFormation Template"** as the fulfillment option and choose your preferred region on the "Configure this software" page. Afterward, click the **"Continue to Launch"** button.
5.  From the "Choose Action" dropdown menu in "Launch this software" page, select **"Launch CloudFormation"** and click **"Launch"** button.

## Create CloudFormation Stack

### Step 1: Create stack

1.  Ensure the **"Template is ready"** radio button is selected under "Prepare template".
2.  Click "Next".

### Step 2: Specify stack options

Provide the necessary parameters for your PostgreSQL deployment. These settings define how your instance will be configured.

| Parameter | Description |
| --- | --- |
| Stack name | A unique name for your CloudFormation stack. |
| DatabaseSSHLocation | Set to `0.0.0.0/0`. |
| DeploymentName | A name for your deployment, of your choice. |
| InstanceType | The EC2 instance type. Recommended: `t3.small`. |
| keyName | The name of your preferred EC2 key pair for SSH access. |
| PostgresqlDatabase | A name of your choice for the PostgreSQL database. |
| PostgresqlPassword | A strong password for the PostgreSQL database. |
| PostgresqlUser | A username for the PostgreSQL database. |
| S3Bucket | The name of an S3 bucket used for storing backups. |
| SSHLocation | The IP address range for SSH access. Defaults to `0.0.0.0/0` (open to all). For better security, restrict this to your IP. |
| SubnetCidrBlock | The CIDR block for the subnet. Defaults to `10.0.0.0/24`. |
| VpcCidrBlock | The CIDR block for the VPC. Defaults to `10.0.0.0/16`. |

Click "Next".

### Step 3: Configure stack options

1.  Choose "Roll back all stack resources" and "Delete all newly created resources" under the "Stack failure options" section.
2.  Click "Next".

### Step 4: Review

1.  Review and verify the details you've entered.
![CloudFormation stack parameters for PostgreSQL](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-01.png)3.  Tick the box that says, **"I acknowledge that AWS CloudFormation might create IAM resources with custom names"**.
![Acknowledging IAM resource creation in CloudFormation](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-02.png)5.  Click **"Submit"**.

Afterward, you'll be directed to the CloudFormation stacks page.

![PostgreSQL CloudFormation stack in progress](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-03.png)

Please wait for 5-10 minutes until the stack has been successfully created.

![PostgreSQL CloudFormation stack creation complete](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-04.png)

## Connect to the Database

1.  To obtain the IP address, navigate to the **"Outputs"** tab and look for **"PublicIp"**.

![Copying the PublicIp from CloudFormation Outputs tab](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-05.png)

2.  Use **"PostgresqlUser"** as the username and **"PostgresqlPassword"** as the password, which you entered in "Step 2: Specify stack options" within the "Create CloudFormation Stack" section.
3.  You can access the database via **port 5432**.

You can access PostgreSQL using a tool like pgAdmin:

![Connecting to PostgreSQL using pgAdmin](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-06.png)

## Shutting Down PostgreSQL

1.  Click the link labeled **"Instance"** in the **"Resources"** tab to access the EC2 instance, you will be directed to the PostgreSQL instance in EC2.

![Resources tab showing the PostgreSQL EC2 instance link](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-07.png)

2.  Select the PostgreSQL instance by marking the checkbox and click **"Stop instance"** from the **"Instance state"** dropdown. You can restart the instance at your convenience by selecting **"Start instance"**.

![Stopping the PostgreSQL EC2 instance](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-08.png)

## Remove PostgreSQL

Delete the stack that has been created in the AWS Management Console under "CloudFormation Stacks" by clicking the "Delete" button.

## Upgrades

When there is an upgrade, we will update the product with a newer version. You can check the product version in AWS Marketplace. If a newer version is available, you can remove the previous version and launch the product again using the newer version. Remember to backup the necessary server data before removing.

## Troubleshoot

1.  If you face the following error, please follow [https://meetrix.io/blogs/increase-aws-vcpu-quota/](https://meetrix.io/blogs/increase-aws-vcpu-quota/) to increase vCPU quota.

![AWS vCPU quota exceeded error](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-09.png)

2.  If you face the following error ("do not have sufficient <instance\_type> capacity...") while creating the stack, try changing the region or try creating the stack at a later time.

![AWS insufficient instance capacity error](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-10.png)

3.  If you face the below error, when you try to access the API dashboard, please wait 5-10 minutes and then try.

![502 Bad Gateway error](https://meetrix.io/blog-images/paas-dev-guides/postgresql/postgresql-11.png)

## Conclusion

The Meetrix PostgreSQL Developer Guide provides detailed, step-by-step instructions for seamlessly integrating PostgreSQL into your AWS environment. PostgreSQL, a free open-source database system, supports both relational (SQL) and non-relational (JSON) queries, making it versatile for dynamic websites and web applications. With robust support for essential programming languages like Python, PostgreSQL ensures compatibility and performance in diverse development environments.

## Technical Support

Reach out to Meetrix Support ([aws@meetrix.io](mailto:aws@meetrix.io)) for assistance with PostgreSQL issues.

## Frequently Asked Questions

What is PostgreSQL?

PostgreSQL is a free, open-source object-relational database system that supports both relational (SQL) and non-relational (JSON) queries, making it versatile for dynamic websites and web applications, with robust support for languages like Python.

What are the prerequisites for deploying PostgreSQL on AWS?

You need basic knowledge of AWS services (EC2, CloudFormation), an active AWS account with appropriate permissions, and enough vCPU limit to launch the required instance type.

Which instance type is recommended for PostgreSQL?

t3.small is recommended as a baseline for running PostgreSQL on AWS.

How do I connect to the PostgreSQL database?

Use the PublicIp from the CloudFormation Outputs tab as the host, port 5432, and the PostgresqlUser / PostgresqlPassword you configured during stack creation - for example, via pgAdmin.

How do I handle upgrades?

When a newer version is available in AWS Marketplace, back up any necessary server data, remove the previous deployment, and relaunch the product using the newer version.

How do I get technical support?

Reach out to Meetrix Support at [aws@meetrix.io](mailto:aws@meetrix.io) for assistance with PostgreSQL issues.

## Ready to Deploy Your Own PostgreSQL Instance?

Get started in minutes with our pre-configured AMI and bring reliable, scalable database management to your development environment.

[Deploy PostgreSQL from AWS Marketplace](https://aws.amazon.com/marketplace/pp?sku=ecv6k11j3eu3oaor2ljgbnja0&ref=meetrix.io)

Meetrix Store

PostgreSQL

A Postgres server with backups to Amazon S3

[Deploy it](https://meetrix.io/store/postgresql/)

Meetrix Store New

Deploy what this guide covers, pre-configured.

-    [PostgreSQL A Postgres server with backups to Amazon S3](https://meetrix.io/store/postgresql/)
-    [MongoDB A MongoDB server with daily backups to S3](https://meetrix.io/store/mongodb/)
-    [Supabase Postgres, Auth, Storage and Realtime, self-hosted](https://meetrix.io/store/supabase/)
-    [Jitsi Meet Self-hosted video calls for 50 to 500 users](https://meetrix.io/store/jitsi-meet/)
-    [RustDesk Remote desktop AMI, a TeamViewer alternative](https://meetrix.io/store/rustdesk/)
-    [Coturn TURN/STUN for WebRTC, no per-minute relay fees](https://meetrix.io/store/coturn/)

[Browse all products](https://meetrix.io/store/)
