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.82k stars 9.17k forks source link

[Bug]: error creating ElastiCache Replication Group: InvalidParameterCombination: Expected a parameter group of family redis7 but found one of family redis6.x #27748

Open wgaldino opened 1 year ago

wgaldino commented 1 year ago

Terraform Core Version

1.3.4

AWS Provider Version

4.38.0, 4.37.0, 4.36.0, 4.35.0, 4.34.0

Affected Resource(s)

Expected Behavior

I noticed that since yesterday any aws_elasticache_replication_group resource that before could have been created with the code below was failing.

resource "aws_elasticache_replication_group" "service" {
  count = local.count

  replication_group_id = "service-${local.some_sufix}"
  description          = "Service Regional Redis cluster"
  engine               = "redis"
  node_type = var.node_type
  automatic_failover_enabled = true

  parameter_group_name = "default.redis6.x.cluster.on"

  subnet_group_name  = aws_elasticache_subnet_group.service[0].name
  security_group_ids = [data.aws_security_group.default.id]
  num_node_groups    = var.node_count
  apply_immediately  = true
}

Actual Behavior

Apply fails with the following message:

Error: error creating ElastiCache Replication Group: InvalidParameterCombination: Expected a parameter group of family redis7 but found one of family redis6.x

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_elasticache_replication_group" "service" {
  count = local.count

  replication_group_id = "service-${local.some_sufix}"
  description          = "Service Regional Redis cluster"
  engine               = "redis"
  node_type = var.node_type
  automatic_failover_enabled = true

  parameter_group_name = "default.redis6.x.cluster.on"

  subnet_group_name  = aws_elasticache_subnet_group.service[0].name
  security_group_ids = [data.aws_security_group.default.id]
  num_node_groups    = var.node_count
  apply_immediately  = true
}

Steps to Reproduce

Terraform init Terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

Today after some investigation I could extract the following facts:

The way to solve this issue was to add the engine_version argument to the resource definition. That's exactly the behaviour you get when creating the cluster through the GUI, you cannot set parameter_group_name as default.redis6.x.cluster.on if you select a different engine_version.

Possible ways of fixing it would be:

  1. Update the documentation so that is states that you cannot arbitrarily set parameter_group_name when engine_version is omitted. Enforce that those need to match somehow.
  2. Since the documentation states that engine_version is optional, why not infer the engine based on the parameter_group_name value? Doesn't it make sense? Is that really tricky?

References

No response

Would you like to implement a fix?

No response

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Related #27709

github-actions[bot] commented 1 day ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!