Terraform AWS Cognito应用程序客户端

6

目前在尝试通过Terraform为AWS Cognito用户池设置“应用客户端”时遇到了困难。这是我目前的资源:

resource "aws_cognito_user_pool" "notes-pool" {
  name = "notes-pool"
  username_attributes = ["email"]

  verification_message_template {
    default_email_option = "CONFIRM_WITH_CODE"
  }

  password_policy {
    minimum_length    = 10
    require_lowercase = false
    require_numbers   = true
    require_symbols   = false
    require_uppercase = true
  }

  tags {
    "Name"    = "notes-pool"
    "Environment" = "production"
  }
}

上述代码完全正常,我的用户池已创建。如果有人对如何在同一资源中创建应用程序客户端有任何想法,我很愿意倾听。我开始怀疑这个功能不存在!

3个回答

7

我相信这是在最近版本的terraform中添加的。您可以执行以下操作将客户端添加到用户池中:

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

看这里的文档:Terraform中关于aws_cognito_user_pool_client的条目

3

更新 - terraform 现在已经支持此功能。请参考@cyram的答案

目前,Terraform 尚未支持此功能。

GitHub 上有一个开放问题,其中请求了此功能(如果您从中受益,请点赞)。

在支持之前,最好的选择是使用local-exec provisioner 通过 CLI 创建用户池。

resource "aws_cognito_user_pool" "notes-pool" {
  name = "notes-pool"

  username_attributes = ["email"]
  ...

  provisioner "local-exec" {
    command = <<EOF
aws cognito-idp create-user-pool-client \
  --user-pool-id ${aws_cognito_user_pool.notes-pool.id} \
  --client-name client-name \
  --no-generate-secret \
  --explicit-auth-flows ADMIN_NO_SRP_AUTH
EOF
  }
}

请注意,在使用此功能之前,您必须安装并验证 AWS CLI(我使用环境变量来验证Terraform和AWS CLI)。

-1

2
这个问题涉及到Terraform提供程序,因此API在这里没有用处。 - Adam Thomason

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接