Code Monkey home page Code Monkey logo

basic-up-engine-example's Introduction

Engine + Lambda example

This is a simple GraphQL endpoint demoing using Up by Apex to deploy to AWS Lambda and using AWS Fargate to deploy Engine and link them together.

Caveats

  • Engine does not currently support non GraphQL requests with Lambda. This means using GraphiQL or an auth check for private caching are not possible as they aren't GraphQL requests Issue

Reproduction steps

  1. Install Up
  2. Setup an IAM policy for up like this
  3. npm install in this repo
  4. run up in this directory to deploy and create a Lambda
  5. Setup a new service in Engine
  6. Setup an IAM policy with LambdaInvoke (this is overly wide policy here, could be more narrow) for an engine user and use in next step.
  7. Create a config JSON like so with values from Engine, Lambda, and IAM credentials:
{
  "apiKey": "<ENGINE_API_KEY>",
  "origins": [
    {
      "lambda": {
          "functionArn":"<LAMBDA_ARN>",
          "awsAccessKeyId":"<AWS_IAM_ID>",
          "awsSecretAccessKey":"<AWS_IAM_KEY>"
      }
    }
  ],
  "frontends": [
    {
      "host": "0.0.0.0",
      "port": 80,
      "endpoints": ["/", "/development", "/staging", "/production"]
    }
  ]
}
  1. Stringify this so it can be used with Fargate (hint in chrome you can run copy(JSON.stringify(<the above json>)) to copy it to your clipboard). It is worth saving this somewhere for future ease of use.
  2. To to this link to start using Fargate for a service
  3. Choose custom and enter the following information:
Container Name: Engine
Image: gcr.io/mdg-public/engine:2018.02-37-g678cbb68b
Port Mappings: 80 / TCP
Advanced:
  Env Variables:
    ENGINE_CONFIG: <the stringified JSON from above>

  1. Edit the task definition to set name to be engine-proxy and click next
  2. Choose ALB (Application Load Balancer) and click next
  3. Set cluster name to Engine and click next
  4. Click create and wait until everything is ready
  5. After the cluster is ready, click to the Engine-service and clik into the target group link
  6. Edit health check to be /.well-known/apollo/engine-health
  7. Click back to Description and click the Load Balancer link
  8. Copy the DNS name into the electron version of GraphiQL with http:// proceding it.
  9. Paste this query and hit go:
query Test {
  hero(episode:NEWHOPE){
    name
  }
}
  1. Profit (or replicate the above bugs)

Note

  • GraphiQL is turned off on this demo because it doesn't work (see included youtrack ticket above). Adding it back in is super easy, just follow the docs on apollo server for apollo-server-express
  • Introspection query is just broken, if you type up url --copy you can replace the url in graphiql with what is in your clipboard and see Introspection works and tracing is included.

basic-up-engine-example's People

Contributors

glasser avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.