Skip to content

AWS RDS

David Jones edited this page Feb 17, 2016 · 10 revisions

The AWS RDS instance/cluster

There are sections here on the RDS requirements, creating an RDS, and debugging RDS.

RDS requirements

The RDS will vary according to the requirements of the installation (disk size, RAM size, instance size, and so on). There are some things that are required however:

  • PostgreSQL engine
  • PostgreSQL version 9.3 (9.4 seems to work okay too)
  • Master user account (superuser) must be called root
  • Master user account should have a password that you know. Ideally mypassword, which is a default assumed by later scripts.
  • The RDS is launched in the default security group, so that security group must allow access to port 5432 from within the group (normally there is nothing to change here).

Creating an AWS RDS

You should be able to create one using the AWS CLI:

aws rds create-db-instance --db-instance-identifier rds-refinery --allocated-storage 5 --db-instance-class db.m1.small --engine postgres --master-username root --master-user-password mypassword --availability-zone us-east-1d --backup-retention-period 0 --port 5432 --no-multi-az --engine-version 9.3.10 --no-publicly-accessible --storage-type gp2 --copy-tags-to-snapshot

Do not change:

--engine postgres

May change:

--allocated-storage --db-instance-class --availability-zone --backup-retention-period --no-multi-az --engine-version --storage-type

Debugging RDS

If you've created an RDS that isn't publicly accessible (as recommended above), then you must connect to it from an EC2 instance inside the (default) security group of your AWS account. For now (2016-01) you can SSH into the web-refinery EC2 instance and connect to the RDS from there, using the psql tool. (or, create a dedicated "bastion" host that you can use to SSH tunnel to the RDS: not discussed here).

On the web-refinery EC2 instance, if the CloudInit scripts are successful, there should be a file /home/ubuntu/rds containing the connection details for the RDS instance in JSON format. Here's an example:

{
  "Port": 5432,
  "Address": "rds-refinery.cxbxs51vavna.us-east-1.rds.amazonaws.com"
}

This JSON file is created by the deployment/bin/aws-rds-endpoint script in the refinery-platform repo, so it can be found at /srv/refinery-platform/deployment/bin/aws-rds-endpoint. If /home/ubuntu/rds file is empty then the script couldn't find the RDS (it could be that the RDS has the wrong name, or that the EC2 instance does not have the role permissions to access the RDS API).

If you're logged onto the instance, you should be able to run the script. It needs the name of the RDS to find:

/srv/refinery-platform/deployment/bin/aws-rds-endpoint rds-refinery