Deployment of PostgreSQL RDS and its Replica through Stack
Tags: aws, cloudformation, rds, cloudwatch
Published: 2022-10-02 11:00:51

“ I have checked the various documents to automate the creation of postgresql rds and its replica. Using cloudformation it's very easy to create rds parameters. Pricing of rds based on db instance type and its storage cost.”

AWS CloudFormation is a service that helps you model and set up your AWS resources so that you can spend less time managing those resources and more time focusing on your applications that run in AWS. You create a template that describes all the AWS resources that you want (like Amazon EC2 instances or Amazon RDS DB instances).

CloudFormation takes care of provisioning and configuring those resources for you. You don't need to individually create and configure AWS resources and figure out what's dependent on what; CloudFormation handles that.

In this post, you will get to know how to do the deployment of postgresql rds and its replica through stack. Here I have used a cloudformation stack which creates the customized parameters for postgresql primary rds and read replica rds.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/azuukmtiqzdn048bhfiy.png)
The architecture diagram shows the overall deployment architecture with data flow, cloudformation, rds db instance, rds db instance read replica .

#Solution overview
The blog post consists of the following phases:
1. Launch of Stack for Postgres RDS
2. Cloudwatch Log Group for Postgresql

##Phase 1: Launch of Stack for Postgres RDS
1. Open the cloudformation console, create a stack for rds primary and read replica as template.yaml file. This creates customized configuration parameters for primary rds and its replica rds.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajwvfuyn8xqsbrkg8fqm.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnmm1lg1no591efd3fd6.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fc2ufhq9ynw8m5lpfng.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltfl6brapr8uv5g5mz7l.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fih9kg74kajxkho6ilzp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9fsuxv00kntklcozt27.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nni1j4gw4bv34wocyj18.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjusssc09vv0yt1fef3k.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0npb47ienz60bxy9rylp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi406b378lrjrqbaf5ob.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2k3njrxkxfurdnab8n95.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpxqwaito4382x987k7e.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3i11lm5j3wi1x0h2wfej.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvy3xmk74ijn724gpllw.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0sm1v49dlro2b85ejtpj.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdi8tkqj8j8ray9jyt4a.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqpcpt60udp8w0732q3i.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8c8rvr7cfs9mrjq30zl.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6rlunn4685cwkcg8241.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akloxm4hcq6qf1g2fmyg.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k3sk6lf2iolbpmv4q0j0.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pejk7jup4tq9w72p8a59.png)

##Phase 2: Cloudwatch Log Group for Postgresql 
1. Open the cloudwatch console, check the log streams for postgresql log group.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmujfvud84i3nhdpoemn.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uo6hcjo3tisxx3qi7yae.png)

#Clean-up
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/quamtmc4elhvuyv678cl.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gu6by0pjvktedzcw6c8g.png)

#Pricing
I review the pricing and estimated cost of this example. 

Cost of RDS (Service for PostgreSQL+Service for backup storage+Service for Provisioned gp2 storage) = $0.04

Cost of Cloudwatch = $0

Total Cost = $(0.04+0) = $0.04

#Summary
In this post, I showed “how to do the deployment of postgresql rds and its replica through stack”.

For more details on CloudFormation, Checkout Get started CloudFormation, open the [CloudFormation console](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/). To learn more, read the [CloudFormation documentation](https://docs.aws.amazon.com/cloudformation/).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)