Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Lima committed Feb 25, 2019
1 parent 3c3b168 commit 671e83a
Show file tree
Hide file tree
Showing 66 changed files with 25,461 additions and 4 deletions.
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

#amplify
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/backend/amplify-meta.json
aws-exports.js
awsconfiguration.json
64 changes: 60 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
## AppSync Realtime Reference Architecture
# AppSync Real-Time Reference Architecture

AppSync Realtime Reference Architecture
![Overview](/media/realtime-refarch.png)

## License Summary
## Getting Started

This sample code is made available under a modified MIT license. See the LICENSE file.
### Prerequisites

- [AWS Account](https://aws.amazon.com/mobile/details) with appropriate permissions to create the related resources
- [NodeJS](https://nodejs.org/en/download/) with [NPM](https://docs.npmjs.com/getting-started/installing-node)
- [AWS CLI](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) with output configured as JSON `(pip install awscli --upgrade --user)`
- [AWS Amplify CLI](https://github.com/aws-amplify/amplify-cli) configured for a region where [AWS AppSync](https://docs.aws.amazon.com/general/latest/gr/rande.html) and all other services in use are available `(npm install -g @aws-amplify/cli)`
- [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli) `(pip install --user aws-sam-cli)`
- [Create React App](https://github.com/facebook/create-react-app) `(npm install -g create-react-app)`
- [Install JQ](https://stedolan.github.io/jq/)
- If using Windows, you'll need the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install-win10)

### Back End Setup

1. Install the required modules:

```bash
npm install
```

2. Init the directory as an amplify Javascript project using the React framework:

```bash
amplify init
```

3. Add an **Amazon Cognito User Pool** auth resource. Use the default configuration.

```bash
amplify add auth
```

4. Add an AppSync GraphQL API. Follow the default options. When prompted with "Do you have an annotated GraphQL schema?", select "NO" and copy/paste the schema from the file `schema.graphql` in this repo. It will use [GraphQL Transform](https://aws-amplify.github.io/docs/cli/graphql?sdk=js) [@model](https://aws-amplify.github.io/docs/cli/graphql?sdk=js#model) directives to create DynamoDB tables:

```bash
amplify add api
```
5. Now it's time to provision your cloud resources based on the local setup and configured features:
```bash
amplify push
```
Wait for the provisioning to complete. Once done, a `src/aws-exports.js` file with the resources information is created.
6. Execute the script `setupenv.sh` to configure some environment variables
7. Install the Lambda dependencies and deploy the backend with SAM:
```bash
cd ./sam-app/get-movie;npm install; cd ..
sam package --template-file ./sam-app/template.yaml --s3-bucket $DEPLOYMENT_BUCKET_NAME --output-template-file packaged.yaml --region $AWS_REGION
export STACK_NAME_SAM="$STACK_NAME-extra"
sam deploy --template-file ./packaged.yaml --stack-name $STACK_NAME_SAM --capabilities CAPABILITY_IAM --parameter-overrides unauthRole=$UNAUTH_ROLE graphqlApi=$GRAPHQL_API_ID graphqlEndpoint=$GRAPHQL_ENDPOINT --region $AWS_REGION
```
8. Finally, execute the following command to install your project package dependencies and run the application locally:
```bash
amplify serve
```
9. Open different browsers and test realtime subscriptions
17 changes: 17 additions & 0 deletions amplify/.config/project-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"projectName": "realtime",
"version": "1.0",
"frontend": "javascript",
"javascript": {
"framework": "react",
"config": {
"SourceDir": "src",
"DistributionDir": "build",
"BuildCommand": "npm run-script build",
"StartCommand": "npm run-script start"
}
},
"providers": [
"awscloudformation"
]
}
Loading

0 comments on commit 671e83a

Please sign in to comment.