We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Create a PostgreSQL Database

Alright, let's get a database set up and ready to use.

Assignment

PatientPing's data needs a proper home. Everyone is in constant fear that the next time Zach reboots things, we're going to lose data.

Create a PostgreSQL RDS instance (patientping-db) in your patientping VPC's private subnets (no public access!).

Cost check: A db.t3.micro instance costs about $0.018 per hour (~$13/month). Be sure to delete this when you're done. AWS only allows you to "pause" an RDS instance for a time, then it starts it up again.

    • Make sure you save your database password securely! You won't be able to connect to the DB from your application server without it.

    AWS Free Tier issue: If the instance type dropdown is disabled, or all the instance types are greyed out, you'll need to create a database using the AWS CLI instead.

    Go directly to the Tips section below and use the provided CLI commands.

Once the database status shows Available, run and submit the CLI tests.

Tips

If you want (or need) to use the AWS CLI instead of the web console, you can use the following commands.

  • aws rds describe-db-subnet-groups \
      --db-subnet-group-name patientping-private-subnet-group
    
  • aws ec2 describe-subnets \
      --filters Name=tag:Name,Values=patientping-private-a --query 'Subnets[0].SubnetId'
    aws ec2 describe-subnets \
      --filters Name=tag:Name,Values=patientping-private-b --query 'Subnets[0].SubnetId'
    
  • aws rds create-db-subnet-group \
      --db-subnet-group-name patientping-private-subnet-group \
      --db-subnet-group-description 'Private subnets for RDS DB instances' \
      --subnet-ids PRIVATE_A_ID PRIVATE_B_ID
    
  • aws ec2 describe-vpcs \
      --filters 'Name=tag:Name,Values=patientping' --query 'Vpcs[0].VpcId'
    
  • aws ec2 create-security-group \
      --group-name patientping-rds-sg \
      --description 'Security group for PatientPing RDS' \
      --vpc-id VPC_ID
    
  • aws rds create-db-instance \
      --db-instance-identifier patientping-db \
      --db-instance-class db.t3.micro \
      --engine postgres \
      --master-username postgres \
      --master-user-password YOUR_ALPHANUMERIC_PASSWORD \
      --allocated-storage 20 \
      --storage-type gp2 \
      --db-name patientping \
      --db-subnet-group-name patientping-private-subnet-group \
      --vpc-security-group-ids SECURITY_GROUP_ID \
      --availability-zone us-east-1a \
      --no-publicly-accessible \
      --no-multi-az \
      --backup-retention-period 1 \
      --no-enable-performance-insights \
      --no-deletion-protection
    
  • aws rds wait db-instance-available --db-instance-identifier patientping-db