Track sharing activities in a team.
- Ensure AWS credentials are set
- Install Serverless Framework (
yarn global add serverless
) - Ensure
Node.js 12
is installed
cd
toapp/
- Run
. gen_env.sh
to generate.env.devolopment
file- The file looks like below
REGION=<region - e.g. us-east-1> COGNITO_IDENTITYPOOL_ID=<id> COGNITO_USERPOOL_ID=<id> COGNITO_USERPOOL_CLIENT_ID=<id> BUCKET_IMAGE=<bucket> APPSYNC_API_KEY=<key> APPSYNC_ENDPOINT=<endpoint>
- To generate for another stage, run
. gen_env.sh <stage>
- The file looks like below
- Run
yarn
ornpm i
to install packages - Run
yarn start
ornpm start
(orgatsby develop
)
cd
tostack/
- Run
yarn
ornpm i
to install packages - Run
sls offline
- Ensure you already logged in to Serverless
cd
tostack/
, then runserverless
and follow steps
- Ensure
.env.production
file is setup correctly (similar to.env.development
, but different keys/ids) cd
to root folder- Open
bash
(Windows) orterminal
(Mac), then run. deploy.sh
cd
tostack/
- Run
sls deploy --stage <stage_name>
(allowed stages are currently:dev
,qa
,prod
)
- Run
sls deploy function -f <fn_name>
- Use Github Actions for CI/CD. Each time codes are pushed to
app/
orstack/
folder, CloudFormation stack will be created and executed. See you more at.github/
folder. - Ensure Github Secrets were set correctly (find them by exploring files in
.github/workflows/
folder)
- How to get Cognito info?
cd
tostack/
, then runsls info -v
- How to seed user for testing?
- Run below script (or create
.sh
file, then execute)
USERPOOL_ID=us-east-1_xxxxxxxx
[email protected]
PASSWORD=yourpwd
aws cognito-idp admin-create-user --user-pool-id $USERPOOL_ID --username $USERNAME
aws cognito-idp admin-set-user-password --user-pool-id $USERPOOL_ID --username $USERNAME --password $PASSWORD --permanent
- Add new type (object, query, mutation, etc.)
- Declare new type in
stack/schema.graphql
- Run
amplify codegen
instack
- New type is added to
app/graphql
to use on client side
- Add resolver for new query
- Declare resources in
stack/serverless.yml
- Declare AppSync resources including mappingTemplates and dataSources as seen on AppSync
- For dataSources point the config to a lambda function which will act as the resolver
type: AWS_LAMBDA config: functionName: newFunc
- Declare new lambda function in function section to register the resolver function, point the function to a handler
newFunc: handler: handlers/funcHandler.index
- Add a handler to where we point to in the lambda declaration, in this case,
handlers/funcHandler.js
- GatsbyJS
- GraphQL, AWS Amplify
- AWS Cognito, Lambda, AppSync
- Google Sheet/Form API (“Sheet As A Database” - SAAD)
- Serverless Framework, GitHub Action
- Serverless Best Practices
- Serverless Terminal Commands
- Yarn
- Yarn is much faster than NPM Yarn vs NPM