AWS Amazon Cognito User Pool

This page shows how to write Terraform and CloudFormation for Amazon Cognito User Pool and write them securely.

aws_cognito_user_pool (Terraform)

The User Pool in Amazon Cognito can be configured in Terraform with the resource name aws_cognito_user_pool. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

positive.tf#L1
resource "aws_cognito_user_pool" "positive1" {
  # ... other configuration ...

  sms_authentication_message = "Your code is {####}"

  sms_configuration {
negative.tf#L1
resource "aws_cognito_user_pool" "negative1" {
  # ... other configuration ...

  mfa_configuration          = "ON"
  sms_authentication_message = "Your code is {####}"

main.tf#L5
resource "aws_cognito_user_pool" "user_pool" {
  name = "beats_user_pool"
  alias_attributes = ["email"]
  username_configuration {
    case_sensitive           = false
  }
positive.tf#L1
resource "aws_cognito_user_pool" "positive1" {
  # ... other configuration ...

  sms_authentication_message = "Your code is {####}"

  sms_configuration {
negative.tf#L1
resource "aws_cognito_user_pool" "negative1" {
  # ... other configuration ...

  mfa_configuration          = "ON"
  sms_authentication_message = "Your code is {####}"

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides a Cognito User Pool resource.

AWS::Cognito::UserPool (CloudFormation)

The UserPool in Cognito can be configured in CloudFormation with the resource name AWS::Cognito::UserPool. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

tag-example.yml#L8
    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: uat01a-cognito-user-pool
  UserPool2:
    Type: AWS::Cognito::UserPool
    Properties:
serverless.yml#L49
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: '${self:provider.environment.COGNITO_POOL_NAME}'
        # Set email as an alias
        UsernameAttributes:
          - email
cognito-user-pools.yml#L4
    Type: AWS::Cognito::UserPool
    Properties:
      MfaConfiguration: 'OFF'
      UserPoolName:
        Fn::Sub: Tzero${self:custom.stage}_ProducerUserPool
      UsernameAttributes:
cognito-user-pool.yml#L3
    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: ${self:provider.stage}-user-pool
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
serverless.yml#L10
      Type: "AWS::Cognito::UserPool"
      Properties:
        MfaConfiguration: OFF
        UserPoolName: ${service}-${name}-pool
        UsernameAttributes:
          - email
attendance_cognito_userpools.json#L8
            "Type":"AWS::Cognito::UserPool",
            "Properties":{
                "UserPoolName":"AdminUserPool",
                "AliasAttributes":["email"],
                "Schema": [
                    {
V1.json#L5
            "Type": "AWS::Cognito::UserPoolClient",
            "Properties": {
                "ClientName": "TestApp",
                "GenerateSecret": true,
                "ExplicitAuthFlows": [
                    "ALLOW_USER_PASSWORD_AUTH",
aws_cf_template.json#L499
      "Type": "AWS::Cognito::UserPool",
      "Properties": {
        "AutoVerifiedAttributes": [],
        "AliasAttributes": [],
        "UsernameAttributes": [],
        "Policies": {
aws_cognito.json#L4
    "path": "/ResourceTypes/AWS::Cognito::UserPool/Properties/AliasAttributes/Value",
    "value": {
      "ValueType": "AWS::Cognito::UserPool.AliasAttributes"
    }
  },
  {
serverless-state.json#L34
            "Type": "AWS::Cognito::UserPool",
            "Properties": {
              "MfaConfiguration": "OFF",
              "UserPoolName": "yyp-user-pool",
              "UsernameAttributes": [
                "email"

Parameters

Explanation in CloudFormation Registry

The AWS::Cognito::UserPool resource creates an Amazon Cognito user pool. For more information on working with Amazon Cognito user pools, see Amazon Cognito User Pools and CreateUserPool.

Frequently asked questions

What is AWS Amazon Cognito User Pool?

AWS Amazon Cognito User Pool is a resource for Amazon Cognito of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon Cognito User Pool?

For Terraform, the Checkmarx/kics, Checkmarx/kics and ccteng/nursing_capstone source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the cherylf/AWS-CloudFormation, uu4k/aws-nodejs-express-typescript and Chifhiwa/test-stack-002836 source code examples are useful. See the CloudFormation Example section for further details.