创建 AWS Cognito 用户池时出现 Terraform 错误

Posted

技术标签:

【中文标题】创建 AWS Cognito 用户池时出现 Terraform 错误【英文标题】:Terraform error while creating AWS Cognito User Pool 【发布时间】:2022-01-13 08:33:07 【问题描述】:

以下是我创建 AWS Cognito 用户池的 terraform 代码:​​

resource "aws_cognito_user_pool" "CognitoUserPool" 
name = "cgup-aws-try-cogn-createcgup-001"
password_policy 
    minimum_length = 8
    require_lowercase = true
    require_numbers = true
    require_symbols = true
    require_uppercase = true
    temporary_password_validity_days = 7

lambda_config 
    

schema 
    attribute_data_type = "String"
    developer_only_attribute = false
    mutable = false
    name = "sub"
    string_attribute_constraints 
        max_length = "2048"
        min_length = "1"
    
    required = true
  

代码由几个模式组成,但我认为这可能就足够了。 它是从现有 cognito 用户池中的 aws 导出的,但是当我尝试 terraform 计划时,出现以下错误:

Error: "schema.1.name" cannot be longer than 20 character   
with aws_cognito_user_pool.CognitoUserPool,   
on main.tf line 216, in resource "aws_cognito_user_pool" "CognitoUserPool":  
216: resource "aws_cognito_user_pool" "CognitoUserPool" 

无论我如何减少名称的长度,我都会得到同样的错误。

【问题讨论】:

【参考方案1】:

我尝试部署

resource "aws_cognito_user_pool" "CognitoUserPool" 
name = "cgup-aws-try"
password_policy 
    minimum_length = 8
    require_lowercase = true
    require_numbers = true
    require_symbols = true
    require_uppercase = true
    temporary_password_validity_days = 7

lambda_config 
    

schema 
    attribute_data_type = "String"
    developer_only_attribute = false
    mutable = false
    name = "sub"
    string_attribute_constraints 
        max_length = "2048"
        min_length = "1"
    
    required = true
  

成功了。

也许尝试在新的工作区重新开始。

【讨论】:

所以看来我使用了太多模式,当我尝试只使用一个模式时,它也对我有用,但所有模式再次出现相同的错误。所以可能是这个问题的错误错误消息。

以上是关于创建 AWS Cognito 用户池时出现 Terraform 错误的主要内容,如果未能解决你的问题,请参考以下文章