LoginSignup
13
5

More than 3 years have passed since last update.

Amplifyでcognito(ソーシャルIDP)使うときにデプロイがうまくいかないケース

Last updated at Posted at 2020-09-29

cognitoでソーシャルIDP(Facebook, googleログイン等)を使ったログインを実装中にハマったのでメモ。

:skull: 問題

amplify consoleでビルドログを見ると下記のようなエラーが出る。

2020-09-28T14:15:05.671Z [WARNING]: - Fetching updates to backend environment: develop from the cloud.
2020-09-28T14:15:05.891Z [WARNING]: ✔ Successfully pulled backend environment develop from the cloud.
2020-09-28T14:15:05.915Z [WARNING]: ✖ There was an error initializing your environment.
2020-09-28T14:15:05.917Z [INFO]: Failed to pull the backend.
2020-09-28T14:15:05.919Z [INFO]: auth headless is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool
2020-09-28T14:15:05.941Z [INFO]: Error: auth headless is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool
                                 at updateConfigOnEnvInit (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/src/provider-utils/awscloudformation/index.js:61:15)
                                 at /root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/src/index.js:230:28
                                 at /root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18
                                 at process._tickCallback (internal/process/next_tick.js:68:7)
2020-09-28T14:15:05.957Z [ERROR]: !!! Build failed
2020-09-28T14:15:06.091Z [ERROR]: !!! Non-Zero Exit Code detected
2020-09-28T14:15:06.092Z [INFO]: # Starting environment caching...
2020-09-28T14:15:06.092Z [INFO]: # Environment caching completed

:zap: 原因

この辺が怪しそうなので調べたところ、amplify pushはしてるのでcognitoの方の設定ファイルでfacebookやgoogleの変数を保持しているのですが、どうやら 環境変数 にも設定しないといけないとビルドでこけるぽい。

2020-09-28T14:15:05.941Z [INFO]: Error: auth headless is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool

:tada: 解決

使っているソーシャルIDPの環境変数を追加してビルドし直す。

AMPLIFY_AMAZON_CLIENT_ID
AMPLIFY_AMAZON_CLIENT_SECRET
AMPLIFY_FACEBOOK_CLIENT_ID
AMPLIFY_FACEBOOK_CLIENT_SECRET
AMPLIFY_GOOGLE_CLIENT_ID
AMPLIFY_GOOGLE_CLIENT_SECRET

Group.png

:pen_ballpoint: 追記

[2020/10/1]
公式のドキュメントにデフォルトで用意されている環境変数について書いてありました。

[引用] Amplify Console environment variables
https://docs.aws.amazon.com/ja_jp/amplify/latest/userguide/environment-variables.html

スクリーンショット 2020-10-01 22.25.53.png

13
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
5