4. Cognito Identityプールの作成 (handson-cli-cognito-identity-idpool)

作業の目的 [why]

Cognito Identityプール名"handson-cli-cognito-identity-idpool"を作成します。

完了条件/事前条件 [設計者用情報]

完了条件 [after]

主処理は、以下を満たしたときに成功したものとします。

完了条件1

Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在する。

事前条件 [before]

主処理の実施は、以下の状態であることを前提とします。

事前条件1

Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在しない。

作業対象 [what]

  • Cognito Identityサービス

標準時間(合計)

8分

パラメータ設定

パラメータ設定の標準時間

2分

作業に必要なモノ・情報 [resource]

作業開始には、以下が全て揃っていることが必要です。

リソース1: IDプール名

  • 作成するIDプールの名称です。

  • 今回は"handson-cli-cognito-identity-idpool"とします。

パラメータの指定

作業に必要なパラメータを変数に格納をします。

0.0. リージョンの指定

変数の設定

export AWS_DEFAULT_REGION='ap-northeast-1'

0.1. IDプール名の指定

IDプール名を指定します。

変数の設定:

COGNITO_IDENTITY_POOL_NAME='handson-cli-cognito-identity-idpool'

パラメータの保存

設定されている変数の保存先となるファイル名を指定します。

変数の設定:

DIR_PARAMETER="${HOME}/tmp/parameter-handson-cli-cognito-identity"
FILE_PARAMETER="${DIR_PARAMETER}/$(date +%Y-%m-%d)-cognito_identity-pool-create.env" \
  && echo ${FILE_PARAMETER}

結果(例):

${HOME}/tmp/parameter-handson-cli-cognito-identity/2019-11-19-cognito_identity-pool-create.env

各変数に正しいパラメータ値が格納されていることを確認しながら保存します。

変数の確認:

cat << EOF > ${FILE_PARAMETER}

  # 0.0. AWS_DEFAULT_REGION:"ap-northeast-1"
         AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}"

  # 0.1. COGNITO_IDENTITY_POOL_NAME:"handson-cli-cognito-identity-idpool"
         COGNITO_IDENTITY_POOL_NAME="${COGNITO_IDENTITY_POOL_NAME}"

EOF

cat ${FILE_PARAMETER}

下段の変数が入っていない、もしくは上段と同等の値が入っていない場合は、それぞれの手順番号に戻って変数の設定を行います。

タスクの実施

タスク標準時間

6分

1. 前処理

処理対象の状態確認

主処理の実施は、以下の状態であることを前提とします。

前提と異なることが判明した場合、直ちに処理を中止します。

事前条件1: Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在しない。

「Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在しない。」ことを確認します。

コマンド:

aws cognito-identity list-identity-pools \
  --max-results 60 \
  --query "IdentityPools[?IdentityPoolName==\`${COGNITO_IDENTITY_POOL_NAME}\`].IdentityPoolName" \
  --output text

結果(例):

(出力なし)

2. 主処理

Cognito Identityプールの作成

変数の確認:

cat << ETX

  # COGNITO_IDENTITY_POOL_NAME:"handson-cli-cognito-identity-idpool"
    COGNITO_IDENTITY_POOL_NAME="${COGNITO_IDENTITY_POOL_NAME}"

ETX

コマンド:

aws cognito-identity create-identity-pool \
  --identity-pool-name ${COGNITO_IDENTITY_POOL_NAME} \
  --allow-unauthenticated-identities

結果(例):

{
  "IdentityPoolId": "ap-northeast-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "AllowUnauthenticatedIdentities": true,
  "IdentityPoolName": "handson-cli-cognito-identity-idpool"
}

3. 後処理

完了条件の確認

主処理は、以下を満たしたときに成功したものとします。

完了条件1: Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在する。

「Cognito Identityプール名"handson-cli-cognito-identity-idpool"が存在する。」ことを確認します。

コマンド:

aws cognito-identity list-identity-pools \
  --max-results 60 \
  --query "IdentityPools[?IdentityPoolName==\`${COGNITO_IDENTITY_POOL_NAME}\`].IdentityPoolName" \
  --output text

結果(例):

handson-cli-cognito-identity-idpool

完了