cloudposse / terraform-aws-elasticache-redis

Terraform module to provision an ElastiCache Redis Cluster
https://cloudposse.com/accelerate
Apache License 2.0
141 stars 246 forks source link

Argument is deprecated [elasticache_replication_group] #155

Closed adamwshero closed 2 years ago

adamwshero commented 2 years ago

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

When planning an elasticache redis instance with a cluster_size = 2 and cluster_mode_enabled = false, using v0.42.0, a deprecation warning is issued.

Expected Behavior

No deprecation warnings are issued and a you have a clean plan.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a redis instance with a cluster size of 2 and cluster mode disabled.
  2. Run 'terraform plan'
  3. See error
    │ Warning: Argument is deprecated
    │ 
    │   with aws_elasticache_replication_group.default,
    │   on main.tf line 116, in resource "aws_elasticache_replication_group" "default":
    │  116: resource "aws_elasticache_replication_group" "default" {
    │ 
    │ Use num_node_groups and replicas_per_node_group instead
    │ 
    │ (and 4 more similar warnings elsewhere)

Screenshots

N/A

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

Additional Context

N/A

Epic55 commented 2 years ago

I have the same issue, but cluster size = 1.

purplepangolin commented 2 years ago

I get the same issue following a recent upgrade of aws provider version. Current settings: Terraform v1.1.9 on darwin_amd64

Previously I was using terraform v1.0.1 provider registry.terraform.io/hashicorp/aws v3.75.1

The previous settings did not exhibit this issue.

From the AWS provider docs:

cluster_mode - (Optional, Deprecated use root-level num_node_groups and replicas_per_node_group instead) Create a native Redis cluster. automatic_failover_enabled must be set to true. Cluster Mode documented below. Only 1 cluster_mode block is allowed. Note that configuring this block does not enable cluster mode, i.e., data sharding, this requires using a parameter group that has the parameter cluster-enabled set to true.

I think the issue relates to this dynamic block in the aws_elasticache_replication_group default resource:

dynamic "cluster_mode" {
    for_each = var.cluster_mode_enabled ? ["true"] : []
    content {
      replicas_per_node_group = var.cluster_mode_replicas_per_node_group
      num_node_groups         = var.cluster_mode_num_node_groups
    }
  }

From the explanation in the aws docs, I think this dynamic block should be replaced with the following root level attributes:

num_node_groups = var.cluster_mode_enabled ? var.cluster_mode_num_node_groups : null
replicas_per_node_group = var.cluster_mode_enabled ? var.cluster_mode_replicas_per_node_group : null

Modifying the above locally seems to fix the warning, but further deprecation warnings are raised in the same resource. Fixing each in turn exposes the next one:

replication_group_description -> use description instead number_cache_clusters -> use num_cache_clusters instead