Introduction to AWS Postgresql
AWS PostgreSQL is a managed relational database service provided by Amazon Web Services (AWS). It allows you to set up, operate, and scale PostgreSQL databases in the cloud without the need for extensive database administration tasks.
PostgreSQL is a open-source RDBMS that is robust, reliable and has extensive feature set. AWS offers a managed service for PostgreSQL, making it easier to deploy and manage PostgreSQL databases in the cloud.
With AWS PostgreSQL, you can leverage the benefits of the Each AWS cloud infrastructure, such as scalability, high availability, durability, and security, while focusing on your application development and data management tasks. The service takes care of routine database management tasks, including database setup, backups, software patching, monitoring, and automatic failover.
Here are some key features and benefits of AWS PostgreSQL:
- Ease of use: AWS makes it simple to create, configure, and manage PostgreSQL databases with just a few clicks through the AWS Management Console or API
- Scalability: AWS PostgreSQL database allows you to easily scale your database instance vertically by increasing the compute and memory resources, or horizontally by adding read replicas to handle higher traffic loads
- High availability and reliability: AWS provides automated backups, automated software patching, and Multi-AZ (Availability Zone) deployments to ensure high availability and data durability
- Security: AWS offers various security features to protect your PostgreSQL database, including network isolation through Virtual Private Cloud (VPC), security groups, encryption at rest with AWS Key Management Service (KMS), and encryption in transit using SSL/TLS
- Performance optimization: AWS PostgreSQL database provides performance-enhancing features such as Read Replicas for scaling read workloads, Multi-AZ deployments for high availability, and integration with AWS Database Migration Service for easy data migration
- Monitoring and metrics: You can monitor the performance and health of your PostgreSQL database using Amazon CloudWatch, which provides metrics, alarms, and log monitoring capabilities
- Integration with AWS ecosystem: AWS PostgreSQL database seamlessly integrates with other AWS services such as AWS Lambda, AWS Elastic Beanstalk, AWS Identity and Access Management (IAM), and AWS CloudFormation for building scalable and secure applications
By using AWS PostgreSQL, you can focus on your application development and data management tasks while leveraging the benefits of a managed database service with the scalability, reliability, and security of the AWS cloud infrastructure.
HOW TO CREATE AWS RDS DB(PostgreSQL)
In this section of the tutorial, we will look at how to create an AWS RDS database (PostgreSQL)
- Log in to your AWS Management Console
- Navigate to the RDS service and click on Dashboard
- RDS Dashboard will open from where you can create a Database
- Click on “Create database” and choose a database creation method. Here we will select “Standard Create” option. Here you can set all the configuration options including ones for security, backups and maintenance
- Select PostgreSQL as the engine and choose the appropriate version and instance type for your needs. Here we are selecting version 14.7-R1
- Select the type of template or environment for which you want the Postgresql database. There are 3 options:
- Production – Choose this template for production workloads which provides high availability, fast and consistent performance
- Dev/Test – Choose this template for Dev/Test use outside of production environment
- Free Tier – Choose this template if it is for learning and gaining hands on experience with AWS RDS
Free tier benefits include the following.
- 750 hrs of Amazon RDS in a Single-AZ db.t2.micro Instance
- 20 GB of General Purpose Storage (SSD)
- 20 GB for automated backup storage and any user-initiated DB snapshots
- Choose the Availability and durability settings. For “Free Tier” these options are disabled. But for production and dev/test templates, these options are enabled. You can choose the appropriate settings for Production or Dev/Test workloads
- Set the database DB Instance identifier. Here we are setting it as “my-aws-psql-db-1”. You can choose any DB name as per your choice. The constraints for choosing the DB name is that the name can contain, 1 – 60 alphanumeric characters or hyphens. The first character must be a letter and the name cannot contain two consecutive hyphens and can’t end with a hyphen
- Now setup the username and password that will be used to connect to the database. We are not selecting the options to managing the master credentials in AWS secrets manager as some RDS features are not supported. Also, we are not selecting auto generation of password. We will enter the password manually here
- In the “Instance configuration” option, select the DB instance class. Here since “Free Tier” option is chosen, the default instance class chosen is “db.t3.micro”
- Select the storage capacity required for the Database. Here we are disabling the “Storage Autoscaling”. Autoscaling will automatically increase the storage capacity after the threshold limit is crossed. This will lead to additional cost. Hence, enable this option after it is confirmed that it is absolutely needed
- Now configure networking settings that will be used to connect to DB.
- Compute Resource
Choose whether to setup a connection from a EC2 instance to Postgresql DB. This can be configured at a later time after deploying DB. Here we are not connecting to an EC2 instance resource
- Compute Resource
- Select the required VPC, subnet and subnet group as per your environment setup. Here we will leave all to default
- Choose the Database Authentication method. There are three options available. We will use the default “Password Authentication” method
- Choose the monitoring preferences. We are disabling monitoring for this tutorial. For production or Dev/Test workloads, enable the monitoring and choose the retention period and the AWS KMS key as below
- Now in the section “additional configuration”, enter the “Initial Database name”. If we enter the database name, then a database is created when the RDS Postgresql instance is created. Else, a database is not created. Here we are entering a database name. Leave the DB parameter group as the default option
- Configure the Backup options for the database. Here we will enable “automated backups” and keep the retention period as 1 day for this tutorial. We will not enable “Backup Replication” for this tutorial
- Now, choose the “Encryption” related options. By default, encryption is enabled. We have disabled encryption for this tutorial. To export logs to AWS Cloudwatch logs, select the type of log to be exported. Here we have not selected any logs to be exported
- Now select the maintenance options for the database. By default, auto minor version upgrade is enabled. This may be okay for some development or test environments. But it is not recommended for production DB’s. Here we will leave the settings as default. We are not enabling deletion protection and not choosing the maintenance window as this is a free tier DB. Maintenance of DB’s require pre-planning as it involves outage. Hence, these settings may not be suitable for Production or Development DB’s. This option should be reviewed properly before enabling so that it does not impact your applications
- Finally, you can see the estimated cost of the database, based on the settings and configuration chosen. Since this is a free tier instance, there is no cost associated with it. Once you review the estimated cost, click on “Create Database”
- Once the database is created, in the RDS dashboard under the databases section, we can see the DB in available state
AWS free tier is available for 12 months. When the free tier expires or if your application use exceeds the above free tier usage, then you will be charged standard, pay-as-you-go service rates.
Here we will select the “Free Tier” option. You can choose the template as per your needs.
Select the settings for RDS Proxy. Leave the settings to default, that is, do not create a RDS Proxy.
Leave the default option for Certificate authority.
Conclusion
In this tutorial, we have looked at how to create a AWS RDS Postgresql database in a detailed way. Postgresql is a widely used database. Due to its robustness, flexibility, and feature set, PostgreSQL is widely adopted by organizations of all sizes, from small startups to large enterprises, for a broad range of applications, including web applications, data warehouses, geospatial applications, and more.
Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.