You can read further here in this medium article.
This repo contains the code for a GraphQL API with all the CRUDs needed, keeping the developer in control of CI/CD, security, and other aspects using AWS CDK. The goal is to show how to code as little as possible and spend the energy on functions or features that MUST be customized.
We will use AWS AppSync to create a complete GraphQL CRUD backend. Under the hood, GraphQL queries and mutations, Resolvers functions, DynamoDB tables, and an API Endpoint will be created without intervention. However, you will be able to access all outputs and use them in other stacks of your project.
- NodeJs 18.x
- An AWS account - https://portal.aws.amazon.com/billing/signup
- AWS CLI configured - https://docs.aws.amazon.com/cdk/v2/guide/cli.html
- Clone the repo
git clone https://github.com/pedraohenrique/aws-cdk-appsync.git
- Install NPM packages
npm install
- Setup AWS CLI. The instructions are here.
- Deploy this stack to your default AWS account/region
npx cdk deploy
Check out the Output values in the terminal.
Outputs:
AwsCdkAppsyncStack.amplifyApiModelSchemaS3Uri =
AwsCdkAppsyncStack.awsAppsyncApiEndpoint =
AwsCdkAppsyncStack.awsAppsyncApiId =
AwsCdkAppsyncStack.awsAppsyncApiKey =
AwsCdkAppsyncStack.awsAppsyncAuthenticationType = API_KEY
AwsCdkAppsyncStack.awsAppsyncRegion = us-east-1
Stack ARN:
Set up your favourite GraphQL client to access the brand-new API. From the step above, you should get awsAppsyncApiEndpoint
and awsAppsyncApiKey
.
If you are using a post request, set the API Key correctly. Like this:
curl --location 'your-awsAppsyncApiEndpoint' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: your-awsAppsyncApiKey' \