AWS Resources

Let's talk about Free Tier resources like S3 and RDS.

This is the 3rd part of our AWS Stories, before continue please verify your AWS Cli installation works and the EC2 instance is still running.

AWS gives a lot of resources. For many of us, a t2.micro instance will be small to run our application. In this case we will bring a Ruby on Rails example.

Our application will need a Database Service and a Storage place to be complete, so let's bring this resources to life before continue:

S3 Bucket

Amazon Simple Storage Service (Amazon S3), provides developers and IT teams with secure, durable, highly-scalable cloud storage. Amazon S3 is easy to use object storage, with a simple web service interface to store and retrieve any amount of data from anywhere on the web.
aws s3api create-bucket --bucket YourBucketName --region sa-east-1

RDS MySQL Instance

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud

In my case, We will bring up a MySQL instance because for me, it's the only Database ready for Web Applications. To be honest I'm MySQL DBA for more than 8 years, so MySQL keeps me comfortable…

Enough of me, let's start MySQL RDS Instance!

First, we will need to create a different Security Group. Last time we created for our EC2 instance, now is time to secure our Database.

# Create the Security Group
aws ec2 create-security-group --group-name fw-kbit-db --description "Default Firewall for DB"
# Then associate a new rule for MySQL port
# Use the private key of your EC2 instance to avoid access from any other place
aws ec2 authorize-security-group-ingress --group-name fw-designa-db --protocol tcp --port 3306 --cidr YourEC2PrivateIP
# Or enable access from everywhere AT YOUR OWN RISK
aws ec2 authorize-security-group-ingress --group-name fw-designa-db --protocol tcp --port 3306 --cidr

Now we are ready to deploy our MySQL Instance

aws rds create-db-instance --db-instance-identifier identifier --db-instance-class db.t2.micro --engine mysql --master-username user --master-user-password pass --availability-zone sa-east-1a --vpc-security-group-ids sg-******** --no-multi-az --allocated-storage 20 --storage-type gp2

Let's explain a little more What we did a few seconds ago:

  • aws rds create-db-instance: Let's call AWS API and create a new instance
  • db-instance-identifier: Is the name of our new instance
  • db-instance-class: To keep us inside the Free Tier, we choose t2.micro
  • engine: MySQL (you can bring a Postgres instance if your want)
  • master-username & master-user-password: Your root account
  • availability-zone: Try to bring it on the same place you have your EC2 instance in order to avoid charge on network traffic
  • vpc-security-group-ids: Security Group you created before
  • no-multi-az: Not recommendable for production environments
  • allocated-storage and storage-type: 20GB General Propose disk

RDS Instance ready, let's try to connect from our EC2 instance and check everything is running as expected before any deploy.

To be continue…

Like what you read? Give Javier Tomas Zon a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.