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.
npm install
in this repo- Setup an IAM policy for up like this
- run
npx up
in this directory to deploy and create a Lambda. The Lambda will be calledstar-wars
. - Create a new service in Engine
- Create an IAM user and add the predefined AWSLambdaRole policy to it (this is overly wide policy here, could be more narrow). Create an access key ID and secret access key, which you'll use in the next step.
- Create a config JSON like so with values from Engine, Lambda, and IAM credentials. The function ARN can be found at the Lambda page for the function.
{
"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": ["/graphql", "/staging/graphql", "/production/graphql"]
}
]
}
- 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. - Go to this link to start using Fargate for a service
- Choose
custom
and enter the following information:Then click Update.Container Name: Engine Image: gcr.io/mdg-public/engine:2018.02-50-gef2fc6d4e Port Mappings: 80 / TCP Advanced: Env Variables: ENGINE_CONFIG: <the stringified JSON from above>
- Edit the task definition to set name to be engine-proxy and click next
- Choose ALB (Application Load Balancer) and click next
- Set cluster name to Engine and click next
- Click create and wait until everything is ready
- After the cluster is ready, click the service "Engine-service" and click into the target group link
- Edit health check to be
/.well-known/apollo/engine-health
- Click back to Description and click the Load Balancer link
- Copy the DNS name, and go to it in your web browser. You may get a "503 Service Temporarily Unavailable" error while the service is still starting up; if so, give it a few minutes.
- Paste this query and hit go:
query Test { hero(episode:NEWHOPE){ name } }
- Profit (or replicate the above bugs)