Skip to content

AWS

This will be here to explain how you setup a “free” database on Amazon AWS. You may want to explore the other options on the “free” tier (but note not everything is “free” forever).

Hopefully we will have a centralised account (please use this to help handing over)

The specs are as follows:

  • 2 vCPUs
  • 1 GiB RAM
  • 20GiB storage

You need to sign up for AWS and input card details (I recommend to use virtual card which has £1 in it at the start to verify you).

Region

With Amazon DB you must know the region you are in (in the top right it normally says Ireland or something)

You will only be able to see the databases you have created in that instance. So choose wisely the location of it. You may want to consider where you are hosting the server which will be accessing this database to decrease the latency.

RDS

Creating security group

By default Amazon blocks all connections from random IP addresses to any port. To fix this we need to create a new group:

  • Search for “Security group” click the “EC2” option
  • Click create a new group (you can alter the default but that is not recommended)
  • Give your group a name like “public-postgresql”
  • Add inbound rule for “PostgreSQL” and set the source to “Anywhere-IPv4” (a warning will come up, ignore)
  • Outbound can be left as is
  • Create group

Creating the database

If you search for RDS, and click you should come to a page which explains things about the Relational Database Service.

There should be a button which says “Create database”, click it.

Sadly due to experience, I do not recommend using the easy create as it doesn’t actually create you a database and you have to go in and modify stuff anyway.

  • Choose the standard create

  • Choose postgreSQL

  • Templates choose “Free tier”

  • In settings

    • Give a descriptive identifier name
    • Change the primary username
    • Use a password manager to generate you a password (preferably > 20 chars) special characters should not be used unless you know they can be
  • Storage > autoscaling - disable it

  • Connectivity > public access - yes please

  • Monitoring - disable performance insights

  • Under Connectivity > security group - add your newly created security group

  • Initial configuration

    • Initial database name, give it one (this needs to be set)
    • You might want to increase the backup retention to around 7 days (note if these exceed 20 GB you will be charged)
  • Ignore the price prediction and create the database

Connecting to the database

For some reason this took me a long time to figure out. But the database URL string should be in the format:

postgres://<masterUsername>:<password>@<hostname>/<database_name>

Troubleshooting

If you have an issue similar to:

no pg_hba.conf entry for host

You might want to read through this answer on stack overflow