Each Time TF is executed aws_security_group is replace without a change. Why?

I don’t have any changed in security groups but each time i run terraform and expect no change i am getting resource must be replaced and it is because name_prefix which i don’t even call inside the resource. i have just description, name ,vpc and ingress and egress rules and tag(name). No dependencies.

# module.security_groups.aws_security_group.sf_servers_sg must be replaced
-/+ resource "aws_security_group" "sf_servers_sg" {
      ~ arn                    = "arn:aws:ec2:us-east-1:*:security-group/sg-02a29c6da1c7d01a9" -> (known after apply)
      ~ id                     = "sg-02a29c6da1c7d01a9" -> (known after apply)
      ~ name                   = "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-citrix_sfservers-z" -> "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-sfservers-z" # forces replacement
      + name_prefix            = (known after apply)
      ~ owner_id               = "*" -> (known after apply)
      ~ tags                   = {
          ~ "Name" = "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-citrix_sfservers-z" -> "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-sfservers-z"
      ~ tags_all               = {
          ~ "Name"        = "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-citrix_sfservers-z" -> "aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-sfservers-z"
            # (3 unchanged elements hidden)
        # (5 unchanged attributes hidden)

Hi @tahchiev,

The diff says that the name argument is changing:

Old value: aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-citrix_sfservers-z
New value: aws-nonprd-use1-0305c418e1baed208-z-sg-shrdsvcs-sfservers-z

The “citrix_” prefix seems to have been removed from one of the dash-separated segments in this name.

To avoid the AWS provider proposing to replace this object, I think you will need to change name back to the original value that included the “citrix_” prefix.