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.84k stars 9.19k forks source link

[Bug]: When creating an aws elastiCache user, the user id in the camel case naming method was all lowercase, which further caused the problem of user group reference failure. #37151

Open Rico00121 opened 6 months ago

Rico00121 commented 6 months ago

Terraform Core Version

1.5.6

AWS Provider Version

5.46.0

Affected Resource(s)

aws_elasticache_user aws_elasticache_user_group

Expected Behavior

create aws_elasticache_user and aws_elasticache_user_group successfully

Actual Behavior

Terraform helped me create a user whose user_id is all lowercase, but I declared the user_id named in camel case.

The same problem occurred when creating the aws_elasticache_user_group .

Relevant Error/Panic Output Snippet

aws_elasticache_user.test: Creating...
aws_security_group.redis-sg: Creating...
aws_elasticache_user.test: Creation complete after 2s [id=testuserid]
aws_security_group.redis-sg: Creation complete after 5s [id=sg-03208a6a4d9226e94]
╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for aws_elasticache_user_group.test to include new values learned so far during apply,
│ provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .user_ids: planned set element
│ cty.StringVal("testUserId") does not correlate with any element in actual.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Terraform Configuration Files

resource "aws_elasticache_serverless_cache" "example" {
#  provider = aws.DatabaseAdmin
  engine = "redis"
  name   = "example"
  description              = "Test Server"
  major_engine_version     = "7"
  security_group_ids       = [aws_security_group.redis-sg.id]
#  subnet_ids               = aws_subnet.test[*].id
  user_group_id         = aws_elasticache_user_group.test.user_group_id
}

resource "aws_security_group" "redis-sg" {
#  provider    = aws.TeamNetworkAdministrator
  name        = "redis-sg"
#  vpc_id      = data.aws_vpc.main.id
  ingress = [
    {
      description = "Redis access"

      from_port        = 6379
      to_port          = 6379
      protocol         = "tcp"
      cidr_blocks      = ["0.0.0.0/0"]
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      security_groups  = []
      self             = false
    }
  ]

  egress = [
    {
      description      = "Redis access"
      from_port        = 0
      to_port          = 0
      protocol         = "-1"
      cidr_blocks      = ["0.0.0.0/0"]
      ipv6_cidr_blocks = ["::/0"]
      prefix_list_ids  = []
      security_groups  = []
      self             = false
    }
  ]

  tags = {
    Name = "redis-sg"
  }
}

resource "aws_elasticache_user" "test" {
  user_id       = "testUserId"
  user_name     = "testUserName"
  access_string = "on ~* +@all"
  engine        = "REDIS"
  passwords     = ["password123456789"]
}

resource "aws_elasticache_user_group" "test" {
  engine        = "REDIS"
  user_group_id = "userGroupId"
  user_ids      = [aws_elasticache_user.test.user_id]
}

Steps to Reproduce

just try to apply it

Debug Output

No response

Panic Output

No response

Important Factoids

user_id = "testUserId" -> On AWS, a user with user id “testuserid” will actually be created. user_group_id = "userGroupId" -> On AWS, a user with user group id “usergroupid” will actually be created.

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 6 months ago

Similar #28449