A quick example of how to setup AWS AppSync with Dotnet Core Lambda Resolvers using Open Id Connect (OIDC) authorization
I started investigating how to use AWS AppSync for one of my work projects, but found the examples online were either overly complex or didn't show how to connect to an OIDC authorizer such as Identity Server 4. This repo therefore is a stripped down HelloWorld solution which shows just what you need to use AppSync + Lambdas + OIDC.
You will need an AWS account with the AWS cli installed and working
- Clone the repo
- Install Serverless if you haven't already got it setup locally
npm install -g serverless
- A plugin that is used, Serverless AppSync Plugin, needs to be installed via npm:
npm install
- Set the url of your OIDC provider by updating "https://issuer_goes_here.com" in the serverless.yml
file
- Build the dotnet core code
./build.sh
- Deploy
sls deploy
All going well the deployment will success and you'll get back the Service Information
Service Information
service: myappsynctest
stage: dev
region: ap-southeast-2
stack: myappsynctest-dev
resources: 14
api keys:
None
appsync api keys:
None
endpoints:
None
appsync endpoints:
https://dq6kysaxwvhbvit7itwcjd3zqm.appsync-api.ap-southeast-2.amazonaws.com/graphql
functions:
graphql: myappsynctest-dev-graphql
Be sure to take note of the appsync endpoint. You'll need it later.
The deployment will create an AppSync api within your AWS account:
-
Open Postman
-
Set the following headers:
Header | Value |
---|---|
Content-Type | application/graphql |
Authorization | {Put your jwt access token here. No need for "Bearer ".} |
-
HTTP Verb: POST
-
In the Body tab, select GraphQL and set the following body:
query {helloWorld}