AWS Overview - graceoncampus/goc-web-v3 GitHub Wiki

AWS Overview

DynamoDB

Amazon DynamoDB is a fully managed NoSQL database, designed for applications that require consistent, single-digit millisecond response times at any scale. It is a highly available key-value storage system. This high availability offers an "always on" experience, but requires a sacrifice in consistency to achieve. See more details in the paper here.

Console Overview (5/16/2024)

console

We can view existing tables here and manually explore the items in each table with the Explore Items tab on the left nav bar.

Amplify

Amplify empowers frontend developers to deploy cloud infrastructure by simply expressing their app's data model, business logic, authentication, and authorization rules completely in TypeScript. Amplify automatically configures the correct cloud resources and removes the requirement to stitch together underlying AWS.

Essentially, it makes deploying full stack applications a lot easier for us. Read more here.

Console Overview (5/16/2024)

console2

Hosting → Build Settings

Importantly, the amplify.yml file specifies how our project is to be built:

version: 1
backend:
  phases:
    build:
      commands:
        - update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.8 11
        - /usr/local/bin/pip3.8 install --user pipenv
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - nvm use $VERSION_NODE_14
        - rm -rf node_modules
        - yarn install
        - amplify pull --appId d1afaiv4wnjkx7 --envName dev
        - amplify codegen --maxDepth 4
    build:
      commands:
        - nvm use $VERSION_NODE_14
        - yarn build
        - echo "REACT_APP_GOOGLE_PRIVATE_KEY=$REACT_APP_GOOGLE_PRIVATE_KEY" >> .env
        - echo "REACT_APP_GOOGLE_SERVICE_ACCOUNT_EMAIL=$REACT_APP_GOOGLE_SERVICE_ACCOUNT_EMAIL" >> .env
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Hosting → Domain

Specify a custom domain for the site. Eventually we want this to be graceoncampus.org (or something like that). Right now it's just https://main.d1afaiv4wnjkx7.amplifyapp.com

Hosting → Environment Variables

Key-value pairs that the application may need. Right now, including REACT_APP_GOOGLE_PRIVATE_KEY and REACT_APP_GOOGLE_SERVICE_ACCOUNT_EMAIL. These are mainly for interaction with the google-spreadsheets package for rides upload.

To give the application access to these variables, we can export them (via echo) to a .env file during the build process. See the above amplify.yml file for an example.

App settings

Here we can configure the settings of where our project is continuously deployed from. Right now it is set to our github, following the main branch.

Backend Environment Overview

backend

dev → Authentication

Backend authentication with Amazon Cognito, frontend libraries and components. Configure Users and Identities in Cognito

cognito

dev → API

GraphQL API to list or update the backend data source (our dynamoDB tables). See how it is linked to AppSync, which provides our GraphQL API.

dev → Storage

Files stored in S3 bucket.

AppSync

Schema

Modify this schema by creating resources which will interact with tables in DynamoDB. When creating a new resource, this creates a new table in DynamoDB and connects this resource with resolvers.

Resolvers can be configured to return or update the appropriate data. We can create custom resolvers, but so far this hasn't been necessary for our purposes.

When we update the schema, we can export the schema.graphql file and place it under amplify/backend/api/gocbackendv3. After doing this, run amplify push and amplify codegen to generate new graphql models. (will need to see if we can just amplify pull/amplify codegen without pushing and exporting the actual file) schema

Queries

Here we can test GraphQL queries and mutations to ensure they work the way we expect.

queries

The section in the brackets after the function name indicates the attributes which we want returned. In this example, when we listRides(), we want to specifically retrieve items → cars → driver → name, and so on. The main functions we need are under src/graphql. We have queries.ts, mutations.ts, and subscriptions.ts. Consider this same function in the queries.ts file. This returns attributes at a depth of 4. This was specified by running amplify codegen --maxDepth 4. Otherwise, it may only retrieve up until the attribute cars. This is why in the amplify.yml file I specify amplify codegen --maxDepth 4.

ymp

Cognito

[TODO]

Creating a Ministry Team Account

[TODO]

Lambda

We use AWS Lambda to host our rides backend function. The code, upon an amplify pull is located in amplify/function. You can check Lambda logs through CloudWatch.