To deploy the application, setup a default AWS profile using the AWS cli. You only need to do this once per environment. The IAM user for this will need admin access to your account and is also used to run integration tests locally.
Development
yarn deploy
Staging
yarn deploy -s staging
Production
yarn deploy -s production
To run unit tests
yarn unit-test
To run integration tests
yarn export-env
yarn integration-test
To run end to end tests
yarn export-env
yarn e2e-test
Install the Thunder Client for VS Code https://www.thunderclient.io
Create a collection by importing the file thunder-collection-appsync-crud-sls-backend-dev.json to Thunder client.
Setup the following environment variables in Thunder.
- APPSYNC_URL
- TOKEN
To get a valid token run yarn signup which will output JSON with an idToken which you can copy.
yarn export-env
yarn signup
{
  "id": "21bfa9a8-0382-4757-9533-649a21c0866e",
  "email": "[email protected]",
  "accessToken": "...",
  "idToken": "..."
}IAM setup
- Setup a user appsync-crud-sls-ci-userin IAM that doesn't have any permissions. Take note of theAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY.
- Setup a role appsync-crud-sls-ci-rolein IAM that has admin permission.
- Edit the trust relationship that only allows the appsync-crud-sls-ci-userthe ability to assume the role.
Make sure the edit <YOUR_AWS_ACCOUNT_ID>.
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<YOUR_AWS_ACCOUNT_ID>:user/appsync-crud-sls-ci-user"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
Github actions setup
Add the following secrets in the github actions settings
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- DEV_ACCOUNT_ID
- STAGING_ACCOUNT_ID
- PRODUCTION_ACCOUNT_ID
Dev / Feature work
- Work on a feature branch for example feature/some-feature. Make sure the tests are passing for each of the commits.
- When the feature is complete send a pull request to dev.
- If tests are passing, and code review is complete merge the pull request. Make sure the deployment succeeds and tests pass.
Deploy to staging
- Create a release branch off devfor examplerelease/1.1and push to github.
- Make sure the deployment succeeds and tests pass.
Deploy to production
- Create a pull request from release/1.1intomain.
- Merge the pull request. Make sure deployment succeeds and tests pass.