【问题标题】:Terraform Error while creating AWS Cognito Userpool创建 AWS Cognito 用户池时出现 Terraform 错误
【发布时间】:2022-01-13 05:40:54
【问题描述】:

下面是我创建 Cognito 用户池的 terraform 代码。

resource "aws_cognito_user_pool" "sample_application" {
    name = "sampletest-pool"
    schema {
            name                    = "email"
            attribute_data_type     = "String"
            required                = true
            string_attribute_constraints {
            }
    }
    schema {
            name                    = "name"
            attribute_data_type     = "String"
            required                = true
            string_attribute_constraints {
                min_length = 1
                max_length = 50
            }
    }
    schema {
            name                    = "family_name"
            attribute_data_type     = "String"
            required                = true
            string_attribute_constraints {
                min_length = 1
                max_length = 50
            }
    }
    schema {
            name                     = "phone_number"
            developer_only_attribute = true
            attribute_data_type      = "Number"
            required                 = true
            number_attribute_constraints {}
    }
}

当我给 terraform apply 时,我会显示以下错误。

╷ │ 错误:创建 Cognito 用户池时出错: InvalidParameterException:您不能更改 AttributeDataType 或设置 标准模式属性 phone_number 的 developerOnlyAttribute │ │ 使用 aws_cognito_user_pool.sample_application,│ 在 cognito.tf 行 1、在资源“aws_cognito_user_pool”“sample_application”中:│1: 资源 "aws_cognito_user_pool" "sample_application" { │ ╵

我知道我犯了一个小错误,但找不到它,官方文档根本没有这个用例的任何示例。 官方文档: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cognito_user_pool

【问题讨论】:

  • 错误是关于aws_cognito_user_pool.toggle_application。这不是您在问题中提供的资源。
  • @Marcin 刚刚更新了错误信息。 toggle 是我工作场所的内部应用程序名称。不想让它暴露在这里。这就是为什么在 terraform 代码中更改它但忘记在错误中更改它的原因。希望这能消除混乱

标签: amazon-web-services terraform amazon-cognito terraform-provider-aws


【解决方案1】:

正如错误所说,您不能为标准架构属性设置 developerOnlyAttribute (Standard Atrtibutes)

电话号码属性数据类型也应该是字符串,不能更改。

 schema {
            name                     = "phone_number"
            attribute_data_type      = "String"
            required                 = true
    }

【讨论】:

  • 谢谢!实际上,当我删除 developerOnlyAttribute 时,我仍然遇到相同的错误,但这是您指出的另一个错误。我将 data_type 更改为 String 并且它有效。错误消息有点误导。
猜你喜欢
  • 1970-01-01
  • 2019-09-04
  • 1970-01-01
  • 2017-12-03
  • 2019-07-31
  • 2020-05-13
  • 2016-04-08
  • 2021-08-13
相关资源
最近更新 更多