Skip to content

Commit

Permalink
feat: add python/appsync-graphql-dynamodb/README.md (aws-samples#124)
Browse files Browse the repository at this point in the history
* feat: add python/appsync-graphql-dynamodb/README.md

* feat: add python/appsync-graphql-dynamodb/README.md
  • Loading branch information
zanhsieh authored and garnaat committed Sep 18, 2019
1 parent 3ae5545 commit a917771
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ $ cdk destroy
|---------|-------------|
| [api-cors-lambda](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/api-cors-lambda/) | Shows creation of Rest API (GW) with an /example GET endpoint, with CORS enabled |
| [application-load-balancer](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/application-load-balancer/) | Using an AutoScalingGroup with an Application Load Balancer |
| [appsync-graphql-dynamodb](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/appsync-graphql-dynamodb/) | Creating a single GraphQL API with an API Key, and four Resolvers doing CRUD operations over a single DynamoDB |
| [classic-load-balancer](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/classic-load-balancer/) | Using an AutoScalingGroup with a Classic Load Balancer |
| [custom-resource](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/custom-resource/) | Shows adding a Custom Resource to your CDK app |
| [ecs-cluster](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/ecs/cluster/) | Provision an ECS Cluster with custom Autoscaling Group configuration |
Expand Down
58 changes: 58 additions & 0 deletions python/appsync-graphql-dynamodb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# AppSync GraphQL API Acting on DynamoDB
<!--BEGIN STABILITY BANNER-->
---

![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)

> **This is an experimental example. It may not build out of the box**
>
> This examples does is build on Construct Libraries marked "Experimental" and may not be updated for latest breaking changes.
>
> If build is unsuccessful, please create an [issue](https://github.com/aws-samples/aws-cdk-examples/issues/new) so that we may debug the problem
---
<!--END STABILITY BANNER-->

This an example of an AppSync GraphQL API, pointing to four resolvers doing CRUD operations with a single DynamoDB table.

## Build

To build this app, you need to be in this example's root folder. Then run the following:

```bash
$ python3 -m venv .env
$ source .env/bin/activate
$ pip install -r requirements.txt
```

This will install the necessary CDK, then this example's dependencies, and then build your Python files and your CloudFormation template.

Install the latest version of the AWS CDK CLI:

```shell
$ npm i -g aws-cdk
```

## Deploy

Run `cdk deploy`. This will deploy / redeploy your Stack to your AWS Account.

After the deployment you will see the API's URL, which represents the url you can then use.

## Synthesize Cloudformation Template

To see the Cloudformation template generated by the CDK, run `cdk synth`, then check the output file in the "cdk.out" directory.

## The Component Structure

This Stack contains:

- a __GraphQL API__ with an API Key (Use with caution, each key is only valid for 7 days.)
- a __GraphQL Schema__ with Queries to get one and all items and two mutations to save and delete an item
- a __DynamoDB table__ `items` that stores the data with a Pay Per Request Billing Mode
- an __IAM Role__ that allows AppSync to invoke your DynamoDB table.
- an __AppSync DataSource__, connecting your API to the DynamoDB table with the previously specified role.
- a __AppSync Resolver__ for a Query `getOne` to get one item from the DynamoDB table.
- a __AppSync Resolver__ for a Query `all` to get all items from the DynamoDB table.
- a __AppSync Resolver__ for a Mutation `save` to put an item into the DynamoDB table (the id is autogenerated, you need only name).
- a __AppSync Resolver__ for a Mutation `delete` to delete one item from the DynamoDB table.

0 comments on commit a917771

Please sign in to comment.