Terraform Cognito 身份池

问题描述

我想使用 Terraform 添加 Cognito 用户池和身份池。我当前的错误是身份池提供者的名称不正确。身份池中的 Cognito 用户池的正确名称是什么?

我使用了用户池的名称和资源的名称。我应该用什么?

# Cognito.tf
resource "aws_ses_domain_identity" "identity" {
  domain = "mydomain.com"
}
data "aws_route53_zone" "blog" {
  name         = "mydomain.com"
}


# Cognito
resource "aws_cognito_user_pool" "main" {
  name = "${var.user_pool_name}-${var.stage}"

  # ATTRIBUTES
  alias_attributes = ["email","preferred_username"]

  # Require each user to supply a name
  schema {
    attribute_data_type = "String"
    mutable             = true
    name                = "name"
    required            = true
  }

  # Require each user to supply an email
  schema {
    attribute_data_type = "String"
    mutable             = true
    name                = "email"
    required            = true
  }

  # POLICY
  password_policy {
    minimum_length    = "8"
    require_lowercase = true
    require_numbers   = true
    require_symbols   = true
    require_uppercase = true
  }

  # MFA & VERIFICATIONS
  mfa_configuration        = "OFF"

  # MESSAGE CUSTOMIZATIONS
  verification_message_template {
    default_email_option  = "CONFIRM_WITH_LINK"
    email_message_by_link = "Your life will be dramatically improved by signing up! {##Click Here##}"
    email_subject_by_link = "Welcome to to a new world and life!"
  }
  email_configuration {
    reply_to_email_address = "[email protected]"
  }

  # TAGS
  tags = {
    project = "No Meat May"
  }

  # DEVICES
  device_configuration {
    challenge_required_on_new_device      = true
    device_only_remembered_on_user_prompt = true
  }
}

 resource "aws_cognito_user_pool_client" "client" {
    name = "client"
    user_pool_id = aws_cognito_user_pool.main.id
    generate_secret = true
    explicit_auth_flows = ["ADMIN_NO_SRP_AUTH"]
 }

resource "aws_cognito_identity_pool" "main" {
  identity_pool_name               = "${var.identity_pool_name}-${var.stage}"
  allow_unauthenticated_identities = false

  cognito_identity_providers {
    client_id               = aws_cognito_user_pool_client.client.id
    provider_name           = "${var.user_pool_name}-${var.stage}" # <= What's this?
    server_side_token_check = true
  }
 }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)