Resource: aws_cognito_user

Provides a Cognito User Resource.

Example Usage

Basic configuration

resource "aws_cognito_user_pool" "example" {
  name = "MyExamplePool"
}

resource "aws_cognito_user" "example" {
  user_pool_id = aws_cognito_user_pool.example.id
  username     = "example"
}

Setting user attributes

resource "aws_cognito_user_pool" "example" {
  name = "mypool"

  schema {
    name                     = "terraform"
    attribute_data_type      = "Boolean"
    mutable                  = false
    required                 = false
    developer_only_attribute = false
  }

  schema {
    name                     = "foo"
    attribute_data_type      = "String"
    mutable                  = false
    required                 = false
    developer_only_attribute = false
    string_attribute_constraints {}
  }
}

resource "aws_cognito_user" "example" {
  user_pool_id = aws_cognito_user_pool.example.id
  username     = "example"

  attributes = {
    terraform      = true
    foo            = "bar"
    email          = "no-reply@hashicorp.com"
    email_verified = true
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import Cognito User using the user_pool_id/name attributes concatenated. For example:

import {
  to = aws_cognito_user.user
  id = "us-east-1_vG78M4goG/user"
}

Using terraform import, import Cognito User using the user_pool_id/name attributes concatenated. For example:

% terraform import aws_cognito_user.user us-east-1_vG78M4goG/user