Skip to content

Commit c5febb9

Browse files
committed
feat: add python/appsync-graphql-dynamodb/README.md (#124)
* feat: add python/appsync-graphql-dynamodb/README.md * feat: add python/appsync-graphql-dynamodb/README.md
1 parent a357fc4 commit c5febb9

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ $ cdk destroy
8484
|---------|-------------|
8585
| [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 |
8686
| [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 |
87+
| [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 |
8788
| [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 |
8889
| [custom-resource](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/custom-resource/) | Shows adding a Custom Resource to your CDK app |
8990
| [ecs-cluster](https://github.com/aws-samples/aws-cdk-examples/tree/master/python/ecs/cluster/) | Provision an ECS Cluster with custom Autoscaling Group configuration |
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# AppSync GraphQL API Acting on DynamoDB
2+
<!--BEGIN STABILITY BANNER-->
3+
---
4+
5+
![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
6+
7+
> **This is an experimental example. It may not build out of the box**
8+
>
9+
> This examples does is build on Construct Libraries marked "Experimental" and may not be updated for latest breaking changes.
10+
>
11+
> 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
12+
13+
---
14+
<!--END STABILITY BANNER-->
15+
16+
This an example of an AppSync GraphQL API, pointing to four resolvers doing CRUD operations with a single DynamoDB table.
17+
18+
## Build
19+
20+
To build this app, you need to be in this example's root folder. Then run the following:
21+
22+
```bash
23+
$ python3 -m venv .env
24+
$ source .env/bin/activate
25+
$ pip install -r requirements.txt
26+
```
27+
28+
This will install the necessary CDK, then this example's dependencies, and then build your Python files and your CloudFormation template.
29+
30+
Install the latest version of the AWS CDK CLI:
31+
32+
```shell
33+
$ npm i -g aws-cdk
34+
```
35+
36+
## Deploy
37+
38+
Run `cdk deploy`. This will deploy / redeploy your Stack to your AWS Account.
39+
40+
After the deployment you will see the API's URL, which represents the url you can then use.
41+
42+
## Synthesize Cloudformation Template
43+
44+
To see the Cloudformation template generated by the CDK, run `cdk synth`, then check the output file in the "cdk.out" directory.
45+
46+
## The Component Structure
47+
48+
This Stack contains:
49+
50+
- a __GraphQL API__ with an API Key (Use with caution, each key is only valid for 7 days.)
51+
- a __GraphQL Schema__ with Queries to get one and all items and two mutations to save and delete an item
52+
- a __DynamoDB table__ `items` that stores the data with a Pay Per Request Billing Mode
53+
- an __IAM Role__ that allows AppSync to invoke your DynamoDB table.
54+
- an __AppSync DataSource__, connecting your API to the DynamoDB table with the previously specified role.
55+
- a __AppSync Resolver__ for a Query `getOne` to get one item from the DynamoDB table.
56+
- a __AppSync Resolver__ for a Query `all` to get all items from the DynamoDB table.
57+
- a __AppSync Resolver__ for a Mutation `save` to put an item into the DynamoDB table (the id is autogenerated, you need only name).
58+
- a __AppSync Resolver__ for a Mutation `delete` to delete one item from the DynamoDB table.

0 commit comments

Comments
 (0)