GithubHelp home page GithubHelp logo

scottscovell / hasura-cdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lineupninja/hasura-cdk

0.0 0.0 0.0 1.04 MB

A deployment of Hasura using AWS CDK

License: MIT License

Makefile 4.92% JavaScript 17.36% TypeScript 76.78% Shell 0.94%

hasura-cdk's Introduction

Deploying Hasura using CDK

This repository contains an example of how to deploy Hasura into AWS using AWS CDK.

This project exists as a companion to a talk given at Hasura Con 2020. If you intend to use this repository then checking out the talk first might be a good idea.

Infrastructure Layout

The deployed Hasura instance looks like this:

Architecture

Which is to say a multi-az deployment of both Hasura and Postgres. It can be deployed either multi or single AZ with an environment flag.

In addition to the Hasura deployment a simple API gateway with a single function is deployed, this is use to demonstrate the 'actions' feature in Hasura.

Project Layout

  • cdk Contains the main CDK stack
  • actions Contains a simple lambda handler that returns a 'fortune'
  • hasura Contains a simple schema that connects the deployed 'action'

CDK Layout

CDK has been configured into 4 stacks

  • vpc-stack contains the main VPC component to deploy Hasura into
  • certificates-stack the ACM certificates for the Hasura and actions endpoints
  • hasura-stack the main Hasura Fargate and RDS components
  • actions-stack the API Gateway / Lambda stack for the actions endpoint.

The stack has been split into multiple components to make deployment and rollback easier. Note that new AWS accounts have an ACM limit of 20 certificates, so it's easy to run out of certificates if you regularly build up and tear down the environments.

How to deploy

First copy .env.example to .env and fill out the properties. They should be fairly obvious:

APP_NAME=Whatever you want to call the app, this is used to name the created objects
AWS_REGION=The region to deploy into
AWS_PROFILE=The profile in ~/.aws/credentials to use
AWS_ACCOUNT_ID=The ID of your AWS account
HOSTED_ZONE_ID=The ID of the zone in which to create the DNS records
HOSTED_ZONE_NAME=The name of the same zone
HASURA_ADMIN_SECRET=A secret to use to access the hasura admin interface
HASURA_JWT_SECRET='{"type":"HS256", "key": ""}' - Fill out the 'key' with something with at least 256bit.
HASURA_HOSTNAME=The hostname to use for Hasura, must exist in the hosted zone given above.
ACTIONS_HOSTNAME=The hostname to use for the Actions endpoint, must exist in the hosted zone given above.

Then to deploy just do

make deploy
make deploy-schema

This has been tested on macOS Catalina only but should work on Linux.

Learning More

This project was bought to you by Gordon Johnston at Lineup Ninja where he writes award winning event management software.

If you need help with your Hasura deployment check out the #deployment-help channel in the Hasura Discord community. You can ping Gordon at @elgordino in Discord.

hasura-cdk's People

Contributors

elgordino avatar tmaximini avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.