Apollo GraphQL Server template with AWS SAM, TypeScript & Lambda.
curl --request POST \
--header 'content-type: application/json' \
--url 'https://4r0gh327k1.execute-api.eu-west-1.amazonaws.com/Prod/graphql' \
--data-raw '{"query":"query Launches($limit: Int, $page: Int, $launchId: ID!) { healthCheck launch(id: $launchId) { id } launches(limit: $limit, page: $page) { limit page data { id name } }}","variables":{"launchId":"5eb87cdbffd86e000604b32d","limit":3,"page":3},"operationName":"Launches"}'
- Compiles NodeJS TypeScript to JS for AWS Lambda.
- Uses SAM template to create API Gateway, Lambda function with GraphQL
- Unit tests the Lambda handlers & libraries.
- Runs CI/CD pipelines through GitHub Actions.
- Grants the least privileges CI/CD security best practise; through AWS CDK unit tested.
- Delegates permissions through role CI/CD security best practise; through AWS CDK unit tested.
- Rapidly deploys dev stack locally through Makefile commands
- Automates dependency updates for NPM packages.
- Automates dependency updates for GitHub actions dependencies.
- Reuses CI checks through reusable GitHub workflows
- Ensures workflow runs at a time through GitHub's concurrency feature.
- Restricts NodeJS engine version to 14, same as AWS Lambda
- Disables Apollo Studio on production environment.
- Use this template to create a new GitHub repository.
- Clone your repository on your local machine.
- Configure AWS CloudFormation, such as stack name, region, and others through
infrastructurerc.json
- Find & global replace
aws-sam-ts
with your service name. - Create & authorise the CI/CD user with the least privileges. These have to be generated through your local machine to avoid putting administrator IAM credentials online.
cd cicd-authorisation && make deploy
- Use the link from the output to visit the newly created IAM user.
- Create access key
- Add this access key as GitHub encrypted repository secrets
- Once you commit & git push to main branch, it will be deployed to the default test stack
- Deploy to production environment by clicking the
Run workflow
button inDeploy
action. Example