$ npx create-react-app amplifyapp
Creating a new React app in /Users/xxx/aws/amplify/react-tutorial/amplifyapp.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1380 packages in 2m
178 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
added 39 packages in 9s
178 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1419 packages in 3s
178 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created amplifyapp at /Users/xxx/aws/amplify/react-tutorial/amplifyapp
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd amplifyapp
npm start
Happy hacking!
$ npm start
Compiled successfully!
You can now view amplifyapp in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.10.106:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
webpack compiled successfully
Specify the AWS Region
? region: ap-northeast-1
Specify the username of the new IAM user:
? user name: xxx
Complete the user creation using the AWS console
Enter the access key of the newly created user:
? accessKeyId: ********************
? secretAccessKey: ****************************************
This would update/create the AWS Profile in your local machine
? Profile Name: default
Successfully set up the new user.
$ amplify init --appId xxx
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project xxx
The following configuration will be applied:
Project information
| Name: xxx
| Environment: dev
| Default editor: Visual Studio Code
| App type: javascript
| Javascript framework: react
| Source Directory Path: src
| Distribution Directory Path: build
| 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:
? Please choose the profile you want to use default
Amplify AppID found: xxx. Amplify App name is: test-amplify
Adding backend environment dev to AWS Amplify app: xxx
⠦ Initializing project in the cloud...
(省略)
✔ Successfully created initial AWS cloud resources for deployments.
✔ 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
Amplifyプロジェクトをダッシュボードで確認する際は、以下コマンドを実行します。
$ amplify console
? Which site do you want to open? … (Use arrow keys or type to filter)
❯ Amplify Studio
AWS console
$ amplify add auth
Using service: Cognito, provided by: awscloudformation
The current configured provider is Amazon Cognito.
Do you want to use the default authentication and security configuration? Default configuration
Warning: you will not be able to edit these selections.
How do you want users to be able to sign in? Username
Do you want to configure advanced settings? No, I am done.
✅ Successfully added auth resource amplicyapp413c15cf 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
認証サービスのデプロイ
認証サービスをデプロイします。「–y」オプションで全ての質問を「yes」に設定します。「–y」オプションを付けない場合、デプロイしますか?という趣旨の質問に対して Yes or No で答えていきます。
$ amplify push --y
✔ Successfully pulled backend environment staging from the cloud.
Current Environment: staging
┌──────────┬────────────────────┬───────────┬───────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Auth │ amplicyapp413c15cf │ Create │ awscloudformation │
└──────────┴────────────────────┴───────────┴───────────────────┘
⠴ Updating resources in the cloud. This may take a few minutes...
(省略)
✔ All resources are updated in the cloud
# Starting phase: preBuild
# Executing command: npm ci
2022-05-04T13:06:30.403Z [WARNING]: npm
2022-05-04T13:06:30.404Z [WARNING]: WARN prepare removing existing node_modules/ before installation
2022-05-04T13:06:52.068Z [INFO]: > core-js@3.22.4 postinstall /codebuild/output/src583969016/src/amplicyapp/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
2022-05-04T13:06:52.114Z [INFO]: [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
[96mThe project needs your help! Please consider supporting of core-js:[0m
[96m>[94m https://opencollective.com/core-js [0m
[96m>[94m https://patreon.com/zloirock [0m
[96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m
[96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2022-05-04T13:06:52.292Z [INFO]: > core-js-pure@3.22.4 postinstall /codebuild/output/src583969016/src/amplicyapp/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
2022-05-04T13:06:52.877Z [INFO]: added 2054 packages in 22.501s
2022-05-04T13:06:52.892Z [INFO]: # Completed phase: preBuild
# Starting phase: build
2022-05-04T13:06:52.892Z [INFO]: # Executing command: amplifyPush --simple
2022-05-04T13:06:52.897Z [INFO]: # Getting Amplify CLI Cloud-Formation stack info from environment cache
2022-05-04T13:06:52.902Z [INFO]: # Start initializing Amplify environment: master
2022-05-04T13:06:52.903Z [INFO]: # Initializing new Amplify environment: master (amplify init)
2022-05-04T13:06:57.601Z [INFO]: [31mInvalid feature flag configuration[39m
2022-05-04T13:06:57.602Z [INFO]: [31mThese feature flags are defined in the "amplify/cli.json" configuration file and are unknown to the currently running Amplify CLI:[39m
[31m - graphqltransformer.showfieldauthnotification[39m
[31m - graphqltransformer.usesubusernamefordefaultidentityclaim[39m
[31mThis issue likely happens when the project has been pushed with a newer version of Amplify CLI, try updating to a newer version.[39m
[31mEnsure that the CI/CD pipeline is not using an older or pinned down version of Amplify CLI.[39m
[31mLearn more about feature flags: https://docs.amplify.aws/cli/reference/feature-flags[39m
2022-05-04T13:07:02.251Z [INFO]: [31mInvalid feature flag configuration[39m
2022-05-04T13:07:02.253Z [INFO]: [31mThese feature flags are defined in the "amplify/cli.json" configuration file and are unknown to the currently running Amplify CLI:[39m
[31m - graphqltransformer.showfieldauthnotification[39m
[31m - graphqltransformer.usesubusernamefordefaultidentityclaim[39m
[31mThis issue likely happens when the project has been pushed with a newer version of Amplify CLI, try updating to a newer version.[39m
[31mEnsure that the CI/CD pipeline is not using an older or pinned down version of Amplify CLI.[39m
[31mLearn more about feature flags: https://docs.amplify.aws/cli/reference/feature-flags[39m
2022-05-04T13:07:02.269Z [ERROR]: !!! Build failed
2022-05-04T13:07:02.269Z [ERROR]: !!! Non-Zero Exit Code detected
2022-05-04T13:07:02.269Z [INFO]: # Starting environment caching...
2022-05-04T13:07:02.270Z [INFO]: # Uploading environment cache artifact...
2022-05-04T13:07:02.362Z [INFO]: # Environment caching completed
Terminating logging...
「Invalid feature flag configuration」が気になったので調べてみると、以下のIssueが関係していそうでした。
$ amplify add 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: Single object with fields (e.g., “Todo”
with ID, name, description)
⚠️ 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 /Users/xx/aws/amplify/test-amplify/test/amplify/backend/api/testamplify/schema.graphql or place .graphql files in a directory at /Users/xx/aws/amplify/test-amplify/test/amplify/backend/api/testamplify/schema
✔ Do you want to edit the schema now? (Y/n) · yes
Edit the file in your editor: /Users/xx/aws/amplify/test-amplify/test/amplify/backend/api/testamplify/schema.graphql
✅ Successfully added resource testamplify 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
$ amplify add storage
? Select from one of the below mentioned services: Content (Images, audio, video, etc.)
✔ Provide a friendly name for your resource that will be used to label this category in the project: · imageStorage
✔ Provide bucket name: · test-amplify-image-storage-xxx
✔ Who should have access: · Auth users only
✔ What kind of access do you want for Authenticated users? · create/update, read, delete
✔ Do you want to add a Lambda Trigger for your S3 Bucket? (y/N) · no
✅ Successfully added resource imageStorage locally
⚠️ If a user is part of a user pool group, run "amplify update storage" to enable IAM group policies for CRUD operations
✅ Some next steps:
"amplify push" builds all of your local backend resources and provisions them in the cloud
"amplify publish" builds all of your local backend and front-end resources (if you added hosting category) and provisions them in the cloud