How to deploy Hasura GraphQL Engine to AWS with ECS and Aurora Serverless

AuthorAnaica Grouver

July 25, 2020

awshasuragraphql

How to deploy Hasura GraphQL Engine to AWS with ECS and Aurora Serverless

Following are the steps to build a scalable GraphQL API over Serverless Aurora PostgreSQL with the help of ECS to run the docker image which will be deployed by AWS Cloudformation.

Architecture overview

How to deploy Hasura GraphQL to AWS with ECS and Aurora Serverless

The idea is to deploy the Hasura Docker Image as a Elastic Cluster Service. This gives us ability to add compute tasks to the cluster whenever current CPU is not sufficient for serving the user requests. This behavior can be modified by changing AutoScalingTargetValue, MinContainers and MaxContainers parameters in the CloudFormation Templates. Aurora Serverless PostgreSQL is a managed service from AWS which handles on-demand scaling, this supports our scalable Hasura Compute with the database layer needed.

One Click Launch CloudFormation Links

This launch URL, retrieves cloudformation template from AWS S3 and runs it to form the stack. On calling the URL, it calls the yaml file which consist of the instructions aws must use while creating the stack on cloudformation. You will have to fill in the details to name the database, set password and define the domain in case if you want to deploy Hasura with SSL and custom domain name.

Deploy Hasura with default DNS of Load Balancer

Deploy Hasura Engine with a auto generated DNS from Load Balancer. To access the deployed Hasura, go to EC2 dashboard on AWS and click on the created load balancer, now copy the DNS name and open it in a new tab.

Click to Deploy to Cloudformation

Deploy Hasura with custom domain and SSL

Deploy Hasura Engine with custom domain name and SSL. Pre-requisites for this step would be to have a hosted zone setup in Route53 and SSL certificate issued from Amazon Certificate Manager.

Click to Deploy to Cloudformation

References

  1. Serverless GraphQL with Hasura on AWS ECS over Aurora PostgreSQL
  2. Construct Your Own Launch Stack URL

For questions and suggestions, feel free to reach out to us on Twitter.