DEV Community

Cover image for Deploying a free tier relational database with Amazon RDS
Chris Greening
Chris Greening

Posted on • Updated on

Deploying a free tier relational database with Amazon RDS

Databases can seem pretty scary! πŸ‘»

But they don't have to be! (for the most part)

So let's sit down together and figure out how we can leverage Amazon Relational Database Service (RDS) to setup an instance of a remote free tier relational database to tinker with from our local machine.

This blog post is going to be part of a larger series I'm developing on AWS, Python, R, and SQL so keep an eye out for future posts!

Table of Contents

GIF of the AWS console and a user clicking the link to RDS

❗ IMPORTANT ❗: This tutorial is strictly for practical learning purposes and not an exhaustive guide for setting up a production-ready environment.

We will work under Amazon's free tier but pay attention to your surroundings as misconfiguration can turn into unintended paid usage at Amazon's pay-as-you-go rates!

Be sure to monitor your AWS Cost Management and learn how to control your AWS costs to prevent incurring any unwanted charges!

Chris Greening - Software Developer

Hey! My name's Chris Greening and I'm a software developer from the New York metro area with a diverse range of engineering experience - beam me a message and let's build something great!

favicon christophergreening.com

What is Amazon RDS and why do we use it?

Amazon RDS is a collection of managed services offered on AWS for setting up relational databases in the cloud in just a few clicks.

Remember how I said databases can seem pretty scary? πŸ‘»

Migrations, patches, monitoring, backups, physical hardware, scaling, failover, security, storage, etc.

Lots to keep in mind!

Wouldn't it be great if there was a Database-as-a-Service (DBaas) that managed all of this tedious work for us and all we had to do was flip a switch and start using a production-ready database in our apps? πŸ’‘

This is where Amazon RDS shines! And this is why it's become a popular DBaaS.

With RDS, Amazon takes on the responsibility (for extra money of course) of managing the platform our databases are hosted on. All we have to do is provision our database and run with it.

This frees up our valuable time so we can focus on app development and not on expensive database administration.

Diagram showing Amazon RDS managed features such as "security and compliance", "data durability and redundancy", etc.


What does the Amazon RDS Free Tier offer?

"Did you say free?!"

"Yes, free!" (at least for a year πŸ˜…)

Amazon Free Tier is a collection of AWS' products offered under varying types of limited usage for free.

In the context of what we're building, the Amazon RDS Free Tier allows us 1 year of:

  • 750 hours of instance uptime per month (just enough to run a single DB instance continuously)
  • select instance types (db.t2.micro, db.t3.micro, db.t4g.micro)
  • select database engines (MySQL, PostgreSQL, MariaDB)
  • 20 GB of General Purpose (SSD) DB Storage
  • 20 GB of backup storage

This free tier should be more than adequate for most of our practice use cases! We can basically run a single instance continuously or multiple instances but with downtime (as long as the aggregate uptime across your instances is <750 hours per month you're good.)

❗ IMPORTANT ❗: When the 1 year is up or you exceed free tier usage, you will be charged accordingly at Amazon's pay-as-you-go rates!

Explanation from AWS on what is included in the RDS Free Tier


Creating an instance of MySQL (full instructions)

In this section I'm going to detail step-by-step (with pictures/GIFs) how to create our database. If you would rather read the short version... skip to the next section!

For the purpose of this tutorial we're going to create an instance of a MySQL database for us to connect to remotely via CLI, Python, R, etc.

Aside from a couple slight tweaks, Amazon's default configurations will suffice for creating our simple database so there isn't much for us to worry about! For the sake of brevity I'm only going to point out the configurations we'll be changing.

Let's get started:

  • First navigate to RDS on AWS (if you don't already have an account with AWS, check out this walkthrough)

Create database

  • Click Create database

User clicking "Create database" on RDS screen

Engine options

  • Select MySQL

Templates

  • ❗ IMPORTANT ❗: Select Free tier. This will give us guardrails on what we can configure.

User clicking "MySQL" and then scrolling down and clicking "Free tier"

Settings

  • Name your instance, username, and password as you see fit.

Storage

  • ❗ IMPORTANT ❗: Deselect Enable storage autoscaling!!! Recall from earlier that we only get 20 GB of General Purpose (SSD) DB Storage under the RDS Free Tier - if we approach that limit while practicing we don't want Amazon to automatically scale our storage up as this would bop us out of the free tier.

User deselecting "Enable storage autoscaling"

Connectivity

  • Set Public access to Yes. This will allow us to remotely access our database. (side note: this is for setting up a remote database we can connect to from our local machines - for information on private IP, VPC, etc. see here)

  • Find VPC security group and select Create new. This will assign a security group to our RDS instance that has an inbound rule that only allows the IP address from which we created the instance to access our database.

For information on allowing additional IP's, check out this video from the fantastic Stephane Maarek:

AWS RDS configuration screen with Public access set to yes and a new VPC security group named "sample-security-group"

Additional configuration

  • ❗ IMPORTANT ❗: Deselect Enable automated backups!!! Recall from earlier we only get 20 GB of backup storage. Configure this at your own discretion but for now I would recommend just turning this off (and of course be aware that you now won't have any backups.)

User deselecting the Enable automated backup option under Additional configuration on the RDS create screen

Create database

  • *drumroll* πŸ₯ Now let's scroll to the bottom and click Create database

AWS RDS dashboard showing database being created

Congratulations! πŸ‘

We've now successfully created our RDS instance and can start playing around with connecting to our database and using it for learning purposes, simple web apps, non-critical infrastructure, etc.

If you want to get a deeper understanding I highly encourage you to look up what some of those other configurations mean i.e. virtual private clouds, the implications of autoscaling, etc.

When you're ready to learn about how we can connect to our instance, feel free to skip to that section!


Creating an instance of MySQL (tl;dr)

Ah yes, welcome!

In this section I'm going to quickly detail step-by-step how to create our database. If you would rather read the long version... skip to the previous section!

Here's the tl;dr version of setting up the MySQL instance:

  1. Navigate to RDS on AWS
  2. Click Create database
  3. Select MySQL under Engine options
  4. ❗ IMPORTANT ❗: Select Free tier under Templates
  5. Under Settings set your instance name, username, and password
  6. ❗ IMPORTANT ❗: Deselect Enable storage autoscaling!!!
  7. Set Public access to Yes under Connectivity
  8. Find VPC security group and select Create new under Connectivity
  9. ❗ IMPORTANT ❗: Deselect Enable automated backups under Additional configuration!!!
  10. *drumroll* πŸ₯ Scroll to the bottom and click Create database

Congratulations! Now go to the Winchester, have a nice cold pint, and wait for your database to finish creating.

Shaun from Shaun of the Dead holding a beer and smiling at the camera


Connecting to our instance

Now that our instance is created, all that's left is to connect to our remote database and start using it!

To find the relevant endpoint and port for connecting to your instance, click into your newly created instance and take note of the listed endpoint and port under Connectivity & security.

Connectivity and security section of RDS instance showing <br>
endpoint and port of instance

Plug these into the utility of your choice for accessing MySQL and we should be good to go! I'm personally using the MariaDB CLI on Ubuntu.

$ mysql -h insert-your-database-name.abcdefgh.us-east-1.rds.amazonaws.com  -P 3306 -u admin -p
Enter fullscreen mode Exit fullscreen mode

MySQL client showing the connection to remote database


That's all folks!

Congratulations!

With this we were able to quickly launch a sample relational database and learn a bit about how we can leverage the cloud to rapidly provision resources just a few clicks away.

There is a whole world of cloud computing out there just waiting for you to discover and I urge you to go back and explore some of those other configurations we brushed over while creating our instance!

Thanks so much for reading and if you liked my content, be sure to check out some of my other work or connect with me on social media or my personal website πŸ˜„

Chris Greening - Software Developer

Hey! My name's Chris Greening and I'm a software developer from the New York metro area with a diverse range of engineering experience - beam me a message and let's build something great!

favicon christophergreening.com

Cheers!

❗ IMPORTANT ❗: Amazon is a business and thus these things will start incurring charges at Amazon's pay-as-you-go rate if you step outside the free tier. If you create any additional instances recall that we only have enough free tier hours for a single instance to be continuously running - make sure you clean up after yourself and delete any extra instances, backups, etc. you're not using or you might incur some charges.

I'd also like to remind you to monitor your AWS Cost Management and learn how to control your AWS costs to prevent incurring any unwanted charges!



Additional resources

Top comments (0)