Quick AWS Amplify
Posted on October 2, 2021
Tags: aws
1 Using Amplify UI
amplify init
# Project information
# | Name: MyAmplifyProject
# | Environment: dev
# | Default editor: Visual Studio Code
# | App type: javascript
# | Javascript framework: none
# | Source Directory Path: src
# | Distribution Directory Path: dist
# | Build Command: npm run-script build
# | Start Command: npm run-script start
# ? Initialize the project with the above configuration? Yes
# Using default provider awscloudformation
# ? Select the authentication method you want to use: AWS profile
# For more information on AWS Profiles, see:
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
# ? Please choose the profile you want to use mydemoamplifyprofile
# Adding backend environment dev to AWS Amplify app: awfieojiwfe
# Deployment completed.
# Deploying root stack MyAmplifyProject [ ---------------------------------------- ] 0/4
# amplify-MyAmplifyProject-dev-14222 AWS::CloudFormation::Stack CREATE_IN_PROGRESS Sat
# UnauthRole AWS::IAM::Role CREATE_IN_PROGRESS Sat
# DeploymentBucket AWS::S3::Bucket CREATE_IN_PROGRESS Sat
# AuthRole AWS::IAM::Role CREATE_IN_PROGRESS Sat
# ✔ Help improve Amplify CLI by sharing non sensitive configurations on failures (y/N) · no
# Deployment state saved successfully.
# ✔ Initialized provider successfully.
# ✅ Initialized your environment successfully.
# Your project has been successfully initialized and connected to the cloud!
# Some next steps:
# "amplify status" will show you what you've added already and if it's locally configured or deployed
# "amplify add <category>" will allow you to add features like user login or a backend API
# "amplify push" will build all your local backend resources and provision it in the cloud
# "amplify console" to open the Amplify Console and view your project status
# "amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud
# Pro tip:
# Try "amplify add api" to create a backend API and then "amplify push" to deploy everything
# (base) ➜ MyAmplifyProject amplify status
# Current Environment: dev
# ┌──────────┬───────────────┬───────────┬─────────────────┐
# │ Category │ Resource name │ Operation │ Provider plugin │
# └──────────┴───────────────┴───────────┴─────────────────┘
amplify add api
amplify remove api
# ? Select from one of the below mentioned services: GraphQL
# ? Here is the GraphQL API that we will create. Select a setting to edit or continue Continue
# ? Choose a schema template: Blank Schema
# ⚠️ WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules
# ✅ GraphQL schema compiled successfully.
# Edit your schema at /home/rhel/ReactProjs/1trash/amplifyTrash/amplify/backend/api/amplifytrash/schema.graphql or place .graphql files in a directory at /home/rhel/ReactProjs/1trash/amplifyTrash/amplify/backend/api/amplifytrash/schema
# ✔ Do you want to edit the schema now? (Y/n) · yes
# Could not find selected code editor (Visual Studio Code) on your machine.
# ? Try opening with system-default editor instead? No
# ✅ Successfully added resource amplifytrash locally
# ✅ Some next steps:
# "amplify push" will build all your local backend resources and provision it in the cloud
# "amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud
2 Auth rules
@auth
directive means accessing that Todo product type will require cognito sign-in- OBSERVE: the amplify generated Todo also included
owner
- On Creation, owner is the cognito user
- On Query, the Todo’s returned will only be the ones created by the owner
- OBSERVE: the amplify generated Todo also included
auth(rules: [{allow: owner}]){
type Todo @model @todoId: ID! @primaryKey
content: String
}
type Todo @aws_cognito_user_pools {todoId: ID!
content: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
owner: String
}