hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[Bug]: Cognito client - aws_cognito_user_pool_client - empty write_attributes list is ignored #28684

Open filol opened 1 year ago

filol commented 1 year ago

Terraform Core Version

1.2.9

AWS Provider Version

4.31.0

Affected Resource(s)

aws_cognito_user_pool_client

Expected Behavior

I would like to create a client that can only read attribut.

Actual Behavior

If i create a client with write_attributes = [] all attributes are marked as writable but if I do write_attributes = ["name"] only the attributes name can me modified. Seem's to have a problem with an empty list, looks like it's ignored.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_cognito_user_pool_client" "xxxxxxxx" {
  name                    = "xxxxxxxxxx"
  enable_token_revocation = true
  generate_secret         = false

  user_pool_id                         = aws_cognito_user_pool.user_pool.id
  allowed_oauth_flows                  = ["code"]
  allowed_oauth_scopes                 = ["email", "openid", "profile"]
  allowed_oauth_flows_user_pool_client = true

  callback_urls = [
    "xxxx"
  ]

  logout_urls = [
    "xxx"
  ]

  read_attributes = [
    "phone_number",
    "picture",
    "zoneinfo",
    "given_name",
    "family_name",
    "name",
    "email",
    "name",
    "locale",
  ]
  write_attributes = [] // Bug is here, required at least one element or it's ignored

  access_token_validity = 60
  id_token_validity     = 60

  token_validity_units {
    access_token  = "minutes"
    id_token      = "minutes"
    refresh_token = "days"
  }

  supported_identity_providers = ["COGNITO"]

  explicit_auth_flows = ["ALLOW_USER_PASSWORD_AUTH", "ALLOW_CUSTOM_AUTH", "ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH"]
}

Steps to Reproduce

Deploy the upper client and you will see that all attributes are writable but if you but in write_attributes one element it's working as expected.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

bjiusc commented 5 months ago

Noticed this happening too on Terraform v1.5.3 and AWS provider 5.19.0