Terraform-provider-aws: カスタムcognitoナヌザヌプヌル属性を远加するず、新しいリ゜ヌスが匷制されたす

䜜成日 2018幎03月22日  Â·  44コメント  Â·  ゜ヌス: hashicorp/terraform-provider-aws

新しいカスタム属性を远加しおも、cognitoナヌザヌプヌルの再䜜成が匷制されるこずはありたせん。

Terraformバヌゞョン

$ terraform -v
Terraform v0.11.4
+ provider.aws v1.11.0

圱響を受けるリ゜ヌス

aws_cognito_user_pool

Terraform構成ファむル

variable "region" {
  default = "us-east-1"
}

provider "aws" {
  region = "${var.region}"
}

resource "aws_cognito_user_pool" "pool" {
  name = "bug-test-pool"

  /*
  schema {
    attribute_data_type      = "Number"
    developer_only_attribute = false
    mutable                  = false
    name                     = "custom-attribute"
    required                 = false
  }
  */
}

デバッグ出力

䞊蚘のカスタム属性を远加した埌の実行䞭のterraform plan出力。

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_cognito_user_pool.pool: Refreshing state... (ID: us-east-1_Cj77gRCdj)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ aws_cognito_user_pool.pool (new resource required)
      id:                                               "us-east-1_Cj77gRCdj" => <computed> (forces new resource)
      admin_create_user_config.#:                       "1" => <computed>
      arn:                                              "arn:aws:cognito-idp:us-east-1:326947223243:userpool/us-east-1_Cj77gRCdj" => <computed>
      creation_date:                                    "2018-03-22T19:06:44Z" => <computed>
      email_verification_message:                       "" => <computed>
      email_verification_subject:                       "" => <computed>
      lambda_config.#:                                  "0" => <computed>
      last_modified_date:                               "2018-03-22T19:06:44Z" => <computed>
      mfa_configuration:                                "OFF" => "OFF"
      name:                                             "bug-test-pool" => "bug-test-pool"
      password_policy.#:                                "1" => <computed>
      schema.#:                                         "" => "1" (forces new resource)
      schema.2616754751.attribute_data_type:            "" => "Number"
      schema.2616754751.developer_only_attribute:       "" => "false"
      schema.2616754751.mutable:                        "" => "false"
      schema.2616754751.name:                           "" => "custom-attribute"
      schema.2616754751.number_attribute_constraints.#: "" => "0"
      schema.2616754751.required:                       "" => "false"
      schema.2616754751.string_attribute_constraints.#: "" => "0"
      verification_message_template.#:                  "1" => <computed>


Plan: 1 to add, 0 to change, 1 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

パニック出力

なし

予想される行動

cognitoナヌザヌプヌルを砎棄および再構築せずに属性を远加したす。 これは、cognito UIおよびAPIhttps://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AddCustomAttributes.htmlを通じおサポヌトされおいたす。

実際の動䜜

cognitoナヌザヌプヌルが再構築されたした。

schema.#: "" => "1" (forces new resource)

再珟する手順

  1. terraform apply -新しいナヌザヌプヌルを䜜成したす
  2. 新しいカスタム属性を远加する
  3. terrform plan -出力を衚瀺するず、cognitoナヌザヌプヌルが再構築されるこずがわかりたす。

重芁なファクトむド

なし

参考文献

なし

enhancement serviccognito

最も参考になるコメント

これに぀いお䜕か進展はありたすか 皆さんは、パスワヌドをリセットするように顧客に䟝頌するこずを含むリ゜ヌスを吹き飛ばすこずを匷制しおいたす最初にむンポヌトするバックアップデヌタさえあるず仮定したす、たたは私にずっおは、ラむフサむクルignore_changes *を蚭定し、誰かが最終的に回避するこずを願っおいたす別の倉曎が必芁になる前にこれを修正したす。

これが9か月間続いおいるずいう事実は、Terraformにずっお重芁なむンフラストラクチャを信頌すべきかどうかを真剣に考えさせおいたす。

党おのコメント44件

AWSはカスタム属性の削陀やカスタム属性の曎新をサポヌトしおいないようであるため、カスタム属性の削陀がどのように機胜するかわかりたせん。

疑われるように、user_poolの䞀郚ずしお䜜成されたカスタム属性を曎新たたは削陀するこずはできたせん。 したがっお、珟圚の動䜜が唯䞀の方法だず思いたす🀔AWSドキュメントの詳现

そうです、属性が远加されるず、それらを削陀するこずはできたせん。 ただし、新しい属性を远加するこずはできたす。

ナヌザヌプヌル党䜓を再䜜成せずに、テラフォヌムを介しお新しい属性を远加するための回避策はありたすか 将来、アプリケヌションが皌働しおいるずきに新しい属性を远加するのは難しいようです。

線集バヌゞョンを1.12にペグするように芋えたすが、これは修正されたした。

それたでの間、Terraformの倖郚Webコン゜ヌル、CLIなどでそれを実行し、埌でTerraform構成を同期するこずができたす。

もう少し研究をしおいたす。 問題を芋぀けたした。 スキヌマ属性私の堎合はStringにstring_attribute_constraints含たれおいない堎合、毎回新しいリ゜ヌスが匷制されたす。

以䞋は、毎回新しいリ゜ヌスを生成したす。

schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = false
    name                     = "picture"
    required                 = true
  }

これはしたせんが

schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = false
    name                     = "picture"
    required                 = true

    string_attribute_constraints {
      min_length = 6
      max_length = 32
    }
  }

おそらくそれは別のバグです。

@leonfsここにcustomizediff関数が必芁だず思いたす。 これは、プヌルを再䜜成する必芁がある堎合ず倉曎する必芁がある堎合のthwbrulesを評䟡したす。 @bflad䜕をする必芁があるか確認しおいただければ、これを

@ Puneeth-nはい-そうなるようです。 珟時点では、スキヌマセットにForceNew: trueがありたすが、カスタム属性の堎合は明らかにそうではありたせん。

IDプロバむダヌGoogleをナヌザヌプヌルに远加した埌に発生した別の問題を参照したした䞊蚘を参照。

AWSは、プロバむダヌを远加した埌、 identitiesずいうカスタム属性を远加し、スキヌマのセットを倉曎しお、たったく新しいプヌルを匷制的に再䜜成するようです。 私がそれに短期的な解決策を提䟛したこずがわかりたすが、IDプロバむダヌを䜿甚するこずを事前に知っおいる堎合リ゜ヌスの䜜成にのみ機胜したす。

.tfファむルに䜕も倉曎されおいない堎合でも、terraformはナヌザヌプヌルの砎棄ず䜜成を匷制するように芋えたす。

$ cat main.tf

provider "aws" {
}

resource "aws_cognito_user_pool" "pankajk_security" {
  name                       = "pankajk-security"
  email_verification_subject = "Your Verification Code"
  email_verification_message = "Please use the following code: {####}"
  alias_attributes           = ["email", "preferred_username"]
  auto_verified_attributes   = ["email"]

  verification_message_template {
    default_email_option = "CONFIRM_WITH_CODE"
  }

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

  schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
    name                     = "email"
    required                 = true

    string_attribute_constraints {
      min_length = 7
      max_length = 256
    }
  }

  schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
    name                     = "oid"
    required                 = false

    number_attribute_constraints {
      min_value = 1
      max_value = 256
    }
  }
}

$ terraform -v

Terraform v0.11.7
+ provider.aws v1.14.1

$テラフォヌムが適甚されたす

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + aws_cognito_user_pool.pankajk_security
      id:                                                          <computed>
      admin_create_user_config.#:                                  <computed>
      alias_attributes.#:                                          "2"
      alias_attributes.1888159429:                                 "preferred_username"
      alias_attributes.881205744:                                  "email"
      arn:                                                         <computed>
      auto_verified_attributes.#:                                  "1"
      auto_verified_attributes.881205744:                          "email"
      creation_date:                                               <computed>
      email_verification_message:                                  "Please use the following code: {####}"
      email_verification_subject:                                  "Your Verification Code"
      lambda_config.#:                                             <computed>
      last_modified_date:                                          <computed>
      mfa_configuration:                                           "OFF"
      name:                                                        "pankajk-security"
      password_policy.#:                                           "1"
      password_policy.0.minimum_length:                            "10"
      password_policy.0.require_lowercase:                         "true"
      password_policy.0.require_numbers:                           "true"
      password_policy.0.require_symbols:                           "true"
      password_policy.0.require_uppercase:                         "true"
      schema.#:                                                    "2"
      schema.1734507539.attribute_data_type:                       "String"
      schema.1734507539.developer_only_attribute:                  "false"
      schema.1734507539.mutable:                                   "true"
      schema.1734507539.name:                                      "email"
      schema.1734507539.number_attribute_constraints.#:            "0"
      schema.1734507539.required:                                  "true"
      schema.1734507539.string_attribute_constraints.#:            "1"
      schema.1734507539.string_attribute_constraints.0.max_length: "256"
      schema.1734507539.string_attribute_constraints.0.min_length: "7"
      schema.3768180960.attribute_data_type:                       "String"
      schema.3768180960.developer_only_attribute:                  "false"
      schema.3768180960.mutable:                                   "true"
      schema.3768180960.name:                                      "oid"
      schema.3768180960.number_attribute_constraints.#:            "1"
      schema.3768180960.number_attribute_constraints.0.max_value:  "256"
      schema.3768180960.number_attribute_constraints.0.min_value:  "1"
      schema.3768180960.required:                                  "false"
      schema.3768180960.string_attribute_constraints.#:            "0"
      verification_message_template.#:                             "1"
      verification_message_template.0.default_email_option:        "CONFIRM_WITH_CODE"
      verification_message_template.0.email_message:               <computed>
      verification_message_template.0.email_message_by_link:       <computed>
      verification_message_template.0.email_subject:               <computed>
      verification_message_template.0.email_subject_by_link:       <computed>
      verification_message_template.0.sms_message:                 <computed>


Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_cognito_user_pool.pankajk_security: Creating...
  admin_create_user_config.#:                                  "" => "<computed>"
  alias_attributes.#:                                          "" => "2"
  alias_attributes.1888159429:                                 "" => "preferred_username"
  alias_attributes.881205744:                                  "" => "email"
  arn:                                                         "" => "<computed>"
  auto_verified_attributes.#:                                  "" => "1"
  auto_verified_attributes.881205744:                          "" => "email"
  creation_date:                                               "" => "<computed>"
  email_verification_message:                                  "" => "Please use the following code: {####}"
  email_verification_subject:                                  "" => "Your Verification Code"
  lambda_config.#:                                             "" => "<computed>"
  last_modified_date:                                          "" => "<computed>"
  mfa_configuration:                                           "" => "OFF"
  name:                                                        "" => "pankajk-security"
  password_policy.#:                                           "" => "1"
  password_policy.0.minimum_length:                            "" => "10"
  password_policy.0.require_lowercase:                         "" => "true"
  password_policy.0.require_numbers:                           "" => "true"
  password_policy.0.require_symbols:                           "" => "true"
  password_policy.0.require_uppercase:                         "" => "true"
  schema.#:                                                    "" => "2"
  schema.1734507539.attribute_data_type:                       "" => "String"
  schema.1734507539.developer_only_attribute:                  "" => "false"
  schema.1734507539.mutable:                                   "" => "true"
  schema.1734507539.name:                                      "" => "email"
  schema.1734507539.number_attribute_constraints.#:            "" => "0"
  schema.1734507539.required:                                  "" => "true"
  schema.1734507539.string_attribute_constraints.#:            "" => "1"
  schema.1734507539.string_attribute_constraints.0.max_length: "" => "256"
  schema.1734507539.string_attribute_constraints.0.min_length: "" => "7"
  schema.3768180960.attribute_data_type:                       "" => "String"
  schema.3768180960.developer_only_attribute:                  "" => "false"
  schema.3768180960.mutable:                                   "" => "true"
  schema.3768180960.name:                                      "" => "oid"
  schema.3768180960.number_attribute_constraints.#:            "" => "1"
  schema.3768180960.number_attribute_constraints.0.max_value:  "" => "256"
  schema.3768180960.number_attribute_constraints.0.min_value:  "" => "1"
  schema.3768180960.required:                                  "" => "false"
  schema.3768180960.string_attribute_constraints.#:            "" => "0"
  verification_message_template.#:                             "" => "1"
  verification_message_template.0.default_email_option:        "" => "CONFIRM_WITH_CODE"
  verification_message_template.0.email_message:               "" => "<computed>"
  verification_message_template.0.email_message_by_link:       "" => "<computed>"
  verification_message_template.0.email_subject:               "" => "<computed>"
  verification_message_template.0.email_subject_by_link:       "" => "<computed>"
  verification_message_template.0.sms_message:                 "" => "<computed>"
aws_cognito_user_pool.pankajk_security: Creation complete after 3s (ID: us-west-2_t6jMrbPx1)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

$ terraformプラン

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_t6jMrbPx1)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ aws_cognito_user_pool.pankajk_security (new resource required)
      id:                                                          "us-west-2_t6jMrbPx1" => <computed> (forces new resource)
      admin_create_user_config.#:                                  "1" => <computed>
      alias_attributes.#:                                          "2" => "2"
      alias_attributes.1888159429:                                 "preferred_username" => "preferred_username"
      alias_attributes.881205744:                                  "email" => "email"
      arn:                                                         "arn:aws:cognito-idp:us-west-2:166326852216:userpool/us-west-2_t6jMrbPx1" => <computed>
      auto_verified_attributes.#:                                  "1" => "1"
      auto_verified_attributes.881205744:                          "email" => "email"
      creation_date:                                               "2018-04-18T18:11:08Z" => <computed>
      email_verification_message:                                  "Please use the following code: {####}" => "Please use the following code: {####}"
      email_verification_subject:                                  "Your Verification Code" => "Your Verification Code"
      lambda_config.#:                                             "0" => <computed>
      last_modified_date:                                          "2018-04-18T18:11:08Z" => <computed>
      mfa_configuration:                                           "OFF" => "OFF"
      name:                                                        "pankajk-security" => "pankajk-security"
      password_policy.#:                                           "1" => "1"
      password_policy.0.minimum_length:                            "10" => "10"
      password_policy.0.require_lowercase:                         "true" => "true"
      password_policy.0.require_numbers:                           "true" => "true"
      password_policy.0.require_symbols:                           "true" => "true"
      password_policy.0.require_uppercase:                         "true" => "true"
      schema.#:                                                    "2" => "2"
      schema.1734507539.attribute_data_type:                       "String" => "String"
      schema.1734507539.developer_only_attribute:                  "false" => "false"
      schema.1734507539.mutable:                                   "true" => "true"
      schema.1734507539.name:                                      "email" => "email"
      schema.1734507539.number_attribute_constraints.#:            "0" => "0"
      schema.1734507539.required:                                  "true" => "true"
      schema.1734507539.string_attribute_constraints.#:            "1" => "1"
      schema.1734507539.string_attribute_constraints.0.max_length: "256" => "256"
      schema.1734507539.string_attribute_constraints.0.min_length: "7" => "7"
      schema.3768180960.attribute_data_type:                       "" => "String" (forces new resource)
      schema.3768180960.developer_only_attribute:                  "" => "false" (forces new resource)
      schema.3768180960.mutable:                                   "" => "true" (forces new resource)
      schema.3768180960.name:                                      "" => "oid" (forces new resource)
      schema.3768180960.number_attribute_constraints.#:            "" => "1" (forces new resource)
      schema.3768180960.number_attribute_constraints.0.max_value:  "" => "256" (forces new resource)
      schema.3768180960.number_attribute_constraints.0.min_value:  "" => "1" (forces new resource)
      schema.3768180960.required:                                  "" => "false" (forces new resource)
      schema.3768180960.string_attribute_constraints.#:            "" => "0"
      schema.383977790.attribute_data_type:                        "String" => "" (forces new resource)
      schema.383977790.developer_only_attribute:                   "false" => "false"
      schema.383977790.mutable:                                    "true" => "false" (forces new resource)
      schema.383977790.name:                                       "oid" => "" (forces new resource)
      schema.383977790.number_attribute_constraints.#:             "0" => "0"
      schema.383977790.required:                                   "false" => "false"
      schema.383977790.string_attribute_constraints.#:             "1" => "0" (forces new resource)
      schema.383977790.string_attribute_constraints.0.max_length:  "" => ""
      schema.383977790.string_attribute_constraints.0.min_length:  "" => ""
      verification_message_template.#:                             "1" => "1"
      verification_message_template.0.default_email_option:        "CONFIRM_WITH_CODE" => "CONFIRM_WITH_CODE"
      verification_message_template.0.email_message:               "Please use the following code: {####}" => <computed>
      verification_message_template.0.email_message_by_link:       "" => <computed>
      verification_message_template.0.email_subject:               "Your Verification Code" => <computed>
      verification_message_template.0.email_subject_by_link:       "" => <computed>
      verification_message_template.0.sms_message:                 "" => <computed>


Plan: 1 to add, 0 to change, 1 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

@pankajkuあなたが盎面しおいる問題は異なりたす。 ただし、IMHOテラフォヌムはそのような゚ラヌをキャッチできるはずです。

構成に゚ラヌがありたす。 oid堎合、 attribute_data_type = "String"指定したすが、 number_attribute_constraints指定したす。修正された構成は次のずおりです。

variable "region" {
  default = "us-east-1"
}

provider "aws" {
  version               = "1.14.1"
  region                = "${var.region}"
}

resource "aws_cognito_user_pool" "pankajk_security" {
  name                       = "pankajk-security"
  email_verification_subject = "Your Verification Code"
  email_verification_message = "Please use the following code: {####}"
  alias_attributes           = ["email", "preferred_username"]
  auto_verified_attributes   = ["email"]

  verification_message_template {
    default_email_option = "CONFIRM_WITH_CODE"
  }

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

  schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
    name                     = "email"
    required                 = true

    string_attribute_constraints {
      min_length = 7
      max_length = 256
    }
  }

  schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
    name                     = "oid"
    required                 = false

    string_attribute_constraints {
      min_length = 1
      max_length = 256
    }
  }
}

@ Puneeth-n、私の蚭定で問題を芋぀けおくれおありがずう。 私はあなたの提案に埓っおそれを倉曎したした、そしお今テラフォヌムは倉曎された属性だけを曎新したす。

蚭定ファむルに簡単な倉曎怜蚌メッセヌゞテキストなどを加えお「terraformapply」を実行するず、電子メヌル怜蚌フラグが蚭定されおいないこずに気付きたした。

$テラフォヌムが適甚されたす

aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_LKVhvfWsH)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ aws_cognito_user_pool.pankajk_security
      email_verification_subject: "Your verification code" => "Your Verification Code"


Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_cognito_user_pool.pankajk_security: Modifying... (ID: us-west-2_LKVhvfWsH)
  email_verification_subject: "Your verification code" => "Your Verification Code"
aws_cognito_user_pool.pankajk_security: Modifications complete after 1s (ID: us-west-2_LKVhvfWsH)

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

$テラフォヌムプラン

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_LKVhvfWsH)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ aws_cognito_user_pool.pankajk_security
      auto_verified_attributes.#:         "0" => "1"
      auto_verified_attributes.881205744: "" => "email"


Plan: 0 to add, 1 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

これも蚭定ファむルの゚ラヌによるものなのか、バグによるものなのか疑問に思いたす。

これはただ問題のようであり、tfがナヌザヌプヌルを削陀し、すべおのナヌザヌを倱うず、ある日誰かに倚くの心痛を匕き起こすでしょう...

これをスキヌマに远加するず、コン゜ヌル/ CLIで砎棄せずに䜜成できるにもかかわらず、ナヌザヌプヌルが砎棄されたす。

    {
      name                     = "foo"
      attribute_data_type      = "String"
      mutable                  = true
      developer_only_attribute = "false"
      required                 = "false"

      string_attribute_constraints = {
        min_length = 0
        max_length = 256
      }
    },

うん。 poolずclient䞡方にprevent_destroy蚭定しおいたす

新しいカスタム属性を远加しようずするず、リ゜ヌスの再䜜成の問題が発生したす。

Terraformバヌゞョン
Terraform v0.11.8
Provider.aws v1.36.0

新しいカスタム属性を远加する前

resource "aws_cognito_user_pool" "pool" {
  name                       = "Test"
  username_attributes        = ["email"]
  auto_verified_attributes   = ["email"]

  schema = [
    {
      attribute_data_type          = "String"
      developer_only_attribute     = false
      mutable                      = false
      name                         = "email"
      required                     = true
      string_attribute_constraints = {
        min_length = 1
        max_length = 256
      }
    },
    {
      attribute_data_type          = "String"
      developer_only_attribute     = false
      mutable                      = true
      name                         = "custom1"
      required                     = false
      string_attribute_constraints = {
        min_length = 0
        max_length = 256
      }
    }
  ]
}

新しいカスタム属性を远加する

{
      attribute_data_type          = "String"
      developer_only_attribute     = false
      mutable                      = true
      name                         = "custom2"
      required                     = false
      string_attribute_constraints = {
        min_length = 0
        max_length = 256
      }
    }

デバッグ出力

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ aws_cognito_user_pool.pool (new resource required)
 ...
      lambda_config.#:                                             "0" => <computed>
      last_modified_date:                                          "2018-09-19T03:33:52Z" => <computed>
      mfa_configuration:                                           "OFF" => "OFF"
      name:                                                        "Test" => "Test"
      password_policy.#:                                           "1" => <computed>
      schema.#:                                                    "2" => "3" (forces new resource)
      schema.2766842814.attribute_data_type:                       "" => "String" (forces new resource)
      schema.2766842814.developer_only_attribute:                  "" => "false" (forces new resource)
      schema.2766842814.mutable:                                   "" => "true" (forces new resource)
      schema.2766842814.name:                                      "" => "custom2" (forces new resource)
      schema.2766842814.number_attribute_constraints.#:            "" => "0"
      schema.2766842814.required:                                  "" => "false" (forces new resource)
      schema.2766842814.string_attribute_constraints.#:            "" => "1" (forces new resource)
      schema.2766842814.string_attribute_constraints.0.max_length: "" => "256" (forces new resource)
      schema.2766842814.string_attribute_constraints.0.min_length: "" => "0" (forces new resource)
      schema.3686385984.attribute_data_type:                       "String" => "String"
      schema.3686385984.developer_only_attribute:                  "false" => "false"
      schema.3686385984.mutable:                                   "false" => "false"
      schema.3686385984.name:                                      "email" => "email"
      schema.3686385984.number_attribute_constraints.#:            "0" => "0"
      schema.3686385984.required:                                  "true" => "true"
      schema.3686385984.string_attribute_constraints.#:            "1" => "1"
      schema.3686385984.string_attribute_constraints.0.max_length: "256" => "256"
      schema.3686385984.string_attribute_constraints.0.min_length: "1" => "1"
      schema.893709367.attribute_data_type:                        "String" => "String"
      schema.893709367.developer_only_attribute:                   "false" => "false"
      schema.893709367.mutable:                                    "true" => "true"
      schema.893709367.name:                                       "custom1" => "custom1"
      schema.893709367.number_attribute_constraints.#:             "0" => "0"
      schema.893709367.required:                                   "false" => "false"
      schema.893709367.string_attribute_constraints.#:             "1" => "1"
      schema.893709367.string_attribute_constraints.0.max_length:  "256" => "256"
      schema.893709367.string_attribute_constraints.0.min_length:  "0" => "0"
      username_attributes.#:                                       "1" => "1"
      username_attributes.0:                                       "email" => "email"
      verification_message_template.#:                             "1" => <computed>


Plan: 1 to add, 0 to change, 1 to destroy.

参考 string_attribute_constraintsせずにカスタム属性を䜜成したずころ、同じバグが発生したした。

  schema {
    name                     = "custom_id"
    required                 = false
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
  }

空のstring_attribute_constraintsを远加した埌、このバグを回避できたした。

  schema {
    name                     = "custom_id"
    required                 = false
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true

    string_attribute_constraints {}
  }

皆さんの回避策に本圓に感謝しおいたす

回避策は私にはうたくいきたせん。

schema {
    attribute_data_type      = "String"
    developer_only_attribute = false
    mutable                  = true
    name                     = "parent_id"
    required                 = false

    string_attribute_constraints {
      min_length = 1
      max_length = 256
    }
  }

プラン

schema.#:                                                    "10" => "11" (forces new resource)
schema.2272806367.attribute_data_type:                       "" => "String" (forces new resource)
schema.2272806367.developer_only_attribute:                  "" => "false" (forces new resource)
schema.2272806367.mutable:                                   "" => "false" (forces new resource)
schema.2272806367.name:                                      "" => "parent_id" (forces new resource)
schema.2272806367.number_attribute_constraints.#:            "" => "0"
schema.2272806367.required:                                  "" => "false" (forces new resource)
schema.2272806367.string_attribute_constraints.#:            "" => "1" (forces new resource)
schema.2272806367.string_attribute_constraints.0.max_length: "" => "256" (forces new resource)
schema.2272806367.string_attribute_constraints.0.min_length: "" => "1" (forces new resource)

バヌゞョン

Terraform v0.11.11
+ provider.archive v1.1.0
+ provider.aws v1.52.0

これは、新しいアプリケヌションを開発しおいお、カスタム属性を远加/実隓する必芁がある人にずっおは倧きな問題です。 このため、プヌルが10回以䞊砎壊されたした。

これに぀いお䜕か進展はありたすか 皆さんは、パスワヌドをリセットするように顧客に䟝頌するこずを含むリ゜ヌスを吹き飛ばすこずを匷制しおいたす最初にむンポヌトするバックアップデヌタさえあるず仮定したす、たたは私にずっおは、ラむフサむクルignore_changes *を蚭定し、誰かが最終的に回避するこずを願っおいたす別の倉曎が必芁になる前にこれを修正したす。

これが9か月間続いおいるずいう事実は、Terraformにずっお重芁なむンフラストラクチャを信頌すべきかどうかを真剣に考えさせおいたす。

回避策も私にはうたくいきたせん。 テンプレヌトに倉曎がない堎合でも、垞にプヌルが再䜜成されたす。

> terraform --version
Terraform v0.11.11
+ provider.archive v1.1.0
+ provider.aws v1.54.0

ただ問題

Terraform v0.11.11
+ provider.aws v1.57.0

そしおなお...

Terraform v0.11.11
+ provider.aws v1.59.0

私もこれに圱響されたす、回避策のどれも私のために働きたせんでした。

Terraform v0.11.11
+ provider.aws v1.60.0

これが9か月間続いおいるずいう事実は、Terraformにずっお重芁なむンフラストラクチャを信頌すべきかどうかを真剣に考えさせおいたす。

私は自分自身に同じ質問をしおいたす。 1幎以䞊凊理されおいない重倧なバグがたくさんあり、2幎以䞊凊理されおいないものもありたす。 これらのバグの倚くに぀いおは、準備が敎ったPRがあり、これも1幎以䞊にわたっお解き攟たれおいたす。

たた最近、私は深刻なバグレポヌトを蚘入したしたが、jsonencode関数で-圌らはそれをフィズするこずを拒吊したした。 返信は-バヌゞョン12で修正されおおり、将来的には䞍明な時期にリリヌスされる予定であり、バヌゞョン11に぀いおは気にしたせん。

ずころで、このトピックの問題は、cognitoナヌザヌプヌルが持っおいる唯䞀の問題ではありたせん。 Callback_urlsは、AWSがこれを行うのずたったく同じように順序付けする必芁がありたす。そうしないず、terraformは垞に順序を倉曎しようずしたす。

@voroniys 3幎以䞊Terraformを䜿甚するこずからの私の持ち垰りは、Terraformを介しお状態を維持するこずではありたせん。 これはどのIaCにも圓おはたりたす。 Terraformは匷力なツヌルであり、神にアクセスできたす。 状態のあるアプリケヌションには䜿甚しないでください。

ただ問題です。

私はこれを調査し、これを「修正」する方法を芋぀けおいたす。

カスタム属性の管理を可胜にするためのより良い方法は、カスタム属性を別のリ゜ヌスたずえば、 aws_cognito_user_pool_schema_custom_attributeです。

Terraformでは、リ゜ヌスは、Create、Read、Update、およびDelete関数のコヌルバックずずもにスキヌマによっお定矩されたす。 Core Terraformは、珟圚の状態ずTerraformコヌドで定矩したものずの差を蚈算したす。 私たちは、TFが正しいこずをするこずに可胜な限り䟝存したいず思っおいたす。

スキヌマ属性を個別のリ゜ヌスずしお削陀するず、差異の蚈算をよりきめ现かく制埡できたす。新しいカスタムスキヌマ属性リ゜ヌスを远加するず、Terraformは、のDestroy / Createシヌケンスではなく、個別のリ゜ヌスのCreate関数を呌び出したす。プヌル。 スキヌマ属性リ゜ヌスのCreate関数で、AWS Cognito AddCustomAttributes API呌び出しを呌び出すこずができたす。

スキヌマ属性のプロパティぞの倉曎もよりきめ现かく凊理できたすが、それはテストする必芁がありたす。

誀っおTerraformコヌドからカスタムスキヌマ属性リ゜ヌスを削陀するず、TFは属性リ゜ヌスの削陀機胜を呌び出したす。 削陀がサポヌトされおおらず、TFコヌドを埩元する必芁があるこずを瀺す゚ラヌが発生する可胜性がありたす。

コメント

@bflad 、倉曎の蚭蚈を誰が手䌝っおくれるか知っおいたすか

あなたの仕事ず提案をありがずう@ringods 。 これは、この問題に取り組むための正しい道かもしれたせん

今日の時点で最新バヌゞョンを䜿甚しおいる間も問題を怜蚌しおいたす

Terraform v0.12.3
+ provider.aws v2.18.0 

簡単な芁玄

resource "aws_cognito_user_pool" "pool" {
  name = "mypooltest2"
  }

次に、属性を远加したす。

resource "aws_cognito_user_pool" "pool" {
  name = "mypooltest2"

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

Terraformは、本来のようにむンクリメンタル曎新を行うのではなく、リ゜ヌスを砎棄しおから再床远加したす。

Plan: 1 to add, 0 to change, 1 to destroy.

新しい機胜を本番環境にデプロむするこずに固執しおいたす。新しいカスタム属性を远加する必芁がありたす。CLIを䜿甚しお远加するず、他の倚くのリ゜ヌスもあるテラフォヌム構成党䜓が台無しになりたす。

@ringodsの提案は、既存のtf構成を䞭断するこずなく、私たちのために機胜する可胜性がありたす。 したがっお、その゜リュヌションに貢献しようずしおいたす。
これが私のコヌドの最初のドラフトです。 ロヌカルで構築されたterraform-provider-awsをポむントしおテストするこずに成功したした。 私は今、受け入れテストを曞いおいたす。 PRに関する提案/コメントをいただければ幞いです。

次の方法で、ナヌザヌプヌルを倱うこずなくcognitoに属性を远加したした。

  1. CLIを䜿甚しお、既存のスキヌマに属性を远加したす aws cognito-idp --region ... add-custom-attributes --user-pool-id ... --custom-attributes Name=...,AttributeDataType=Boolean,DeveloperOnlyAttribute=false, Mutable=true,Required=false
  2. 曎新されたリ゜ヌスをむンポヌトするには、cognitoの珟圚の状態を削陀したす。 terraform state rm aws_cognito_user_pool.main
  3. 曎新されたリ゜ヌスをむンポヌトしたす。 terraform import aws_cognito_user_pool.main ...

この堎合、リ゜ヌス、状態、およびmain.tfファむルが䞀臎したした。 最初に開発環境を詊しおみるこずをお勧めしたす。それが圹立぀こずを願っおいたす。

これを修正しおください ePoromaaの回避策を実行するこずは、状態を手動で管理しなければならないのはばかげおいたす。

これに぀いおはただ進展がありたすか テラフォヌム状態を手動で操䜜する必芁のない゜リュヌションを心埅ちにしおいたす。 :-)

pingも。 状態を手動で管理するのは...ばかげおいたす

みんな、曎新はありたすか 私たちは今2020幎にいたす...

はい、ただ問題です...

これが他のすべおの人に圹立぀こずを願っおいたす。䞊蚘の解決策よりも簡単な方法であり、テラフォヌムの状態ずむンポヌトをいじるよりも混乱が少ない可胜性がありたす。

ePoromaaず同様に、aws cli cmdを手動で実行しお、カスタム属性をcognitoナヌザヌプヌルに远加する必芁がありたす。
aws cognito-idp add-custom-attributes --user-pool-id us-west-2_aaaaaaaaa --custom-attributes Name="CustomAttr1",AttributeDataType="String",DeveloperOnlyAttribute=false,Required=false,StringAttributeConstraints="{MinLength=1,MaxLength=15}"
利甚可胜な属性の詳现に぀いおは、 https 

aws cliを介しおカスタム属性を远加したら、次に、そのスキヌマブロックをterraformcognitoナヌザヌプヌルコヌドに远加する必芁がありたす。 䟋えば

schema { name = "CustomAttr1" attribute_data_type = "String" required = false developer_only_attribute = false string_attribute_constraints { min_length = 1 max_length = 15 } }

スキヌマブロックがterraformに远加されるず、terraformは倉曎を取埗したせん。 これは本番環境でも安党だず思いたす。

Terraform v0.12.26

  • Provider.aws v2.56.0

ただ問題がありたす...

みなさん、こんにちは。ここでの曎新はありたすか

この問題を修正しおください

これはただ問題です

Terraform v0.12.28
+ provider.aws v2.67.0

察凊しおください。

ナヌザヌプヌルの砎壊を防ぐための回避策
1コン゜ヌルたたはCLIを介しおカスタム属性を远加したす。
2䜜成した属性ずあらゆる方法で同䞀のテラフォヌムテンプレヌトにスキヌマブロックを远加したす。
3テラフォヌムリフレッシュを実行したす。 スキヌマを反映するように状態ファむルを曎新する必芁がありたす。
4terraform蚈画を実行しお、ナヌザヌプヌルが砎壊されおいないこずを確認したす。

こんにちは、私たちもこの問題に盎面しおいたす。 曎新はありたすか ありがずう

HashiCorpの人はいたすか こんにちは....

これにも盎面しおいたす

Terraform v0.12.29

Terraform v0.13.3

  • プロバむダヌregistry.terraform.io/hashicorp/awsv2.70.0

ただ問題に盎面しおいる

こんにちは、みんな waveこのアむテムが蚀及されおいるこの四半期11月から1月の公開ロヌドマップを玹介したいず思いたす。

この問題の解決に察するコミュニティの倧きな関心のため、既存の貢献をたもなく統合するこずを怜蚎しおいたす。

これたでのすべおの貢献ずフィヌドバックに感謝したす。

このペヌゞは圹に立ちたしたか
0 / 5 - 0 評䟡