📝

Cognito ユーザープールをマネジメントコンソールから作成した時に作成されるリソースを確認してみた

に公開

Create a new application in the Amazon Cognito console - Amazon Cognito
以下のリソースが自動的に作成されていました。

  • ユーザープールドメイン (CreateUserPoolDomain)
  • アプリケーションクライアント (CreateUserPoolClient)
  • マネージドログインブランディングのスタイル (CreateManagedLoginBranding)

ユーザープール

以下の設定で作成しました。

  • アプリケーションタイプ: 従来のウェブアプリケーション
  • サインイン識別子のオプション: メールアドレス

上記以外はデフォルト設定です。

ユーザープールドメイン

Configuring a user pool domain - Amazon Cognito
CloudTrail には以下のリクエストパラメータの記録がありました。

"requestParameters": {
    "domain": "ap-northeast-1jhfjnqgig",
    "userPoolId": "ap-northeast-1_JhfJnqgIG",
    "managedLoginVersion": 2
},

デフォルトでリージョン + ランダムな文字列がドメイン名になるようです。

アプリケーションクライアント

Application-specific settings with app clients - Amazon Cognito
CloudTrail には以下のリクエストパラメータの記録がありました。

"requestParameters": {
    "userPoolId": "ap-northeast-1_JhfJnqgIG",
    "clientName": "My web app - ltta5j",
    "generateSecret": true,
    "refreshTokenValidity": 5,
    "accessTokenValidity": 60,
    "idTokenValidity": 60,
    "tokenValidityUnits": {
        "accessToken": "minutes",
        "idToken": "minutes",
        "refreshToken": "days"
    },
    "explicitAuthFlows": [
        "ALLOW_REFRESH_TOKEN_AUTH",
        "ALLOW_USER_SRP_AUTH",
        "ALLOW_USER_AUTH"
    ],
    "supportedIdentityProviders": [
        "COGNITO"
    ],
    "callbackURLs": [
        "https://d84l1y8p4kdic.cloudfront.net"
    ],
    "allowedOAuthFlows": [
        "code"
    ],
    "allowedOAuthScopes": [
        "openid",
        "phone",
        "email"
    ],
    "allowedOAuthFlowsUserPoolClient": true,
    "preventUserExistenceErrors": "ENABLED",
    "authSessionValidity": 3
},

generateSecrettrue なのでクライアントシークレットも自動的に作成されています。

マネージドログインブランディングのスタイル

Apply branding to managed login pages - Amazon Cognito
CloudTrail には以下のリクエストパラメータの記録がありました。

"requestParameters": {
    "userPoolId": "ap-northeast-1_JhfJnqgIG",
    "clientId": "5b6inmbn2korfbdla86nh1mjor",
    "useCognitoProvidedValues": true,
    "assets": []
},

上記アプリケーションクライアントに紐づくように自動的に作成されています。

AWS CLI からユーザープールを作成した場合

create-user-pool — AWS CLI 2.27.40 Command Reference
AWS CLI などの API 経由でユーザープールを作成した場合、以下の 3 つは自動的には作成されません。

  • ユーザープールドメイン
  • アプリケーションクライアント
  • マネージドログインブランディングのスタイル
$ aws cognito-idp create-user-pool \
--pool-name test-user-pool

マネジメントコンソールから作成した時と同じ設定でユーザープールを作成したい場合には、以下の API で個別に作成する必要があります。

CloudFormation から作成する場合も個別のリソースとして定義する必要があります。

まとめ

今回は Cognito ユーザープールをマネジメントコンソールから作成した時に作成されるリソースを確認してみました。
どなたかの参考になれば幸いです。

参考資料

Discussion