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.75k stars 9.1k forks source link

ElastiCache Global "global_replication_group_id": conflicts with parameter_group_name #20893

Open christopher-wong opened 3 years ago

christopher-wong commented 3 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v1.0.6 on darwin_amd64

Affected Resource(s)

Terraform Configuration Files

resource "aws_elasticache_global_replication_group" "global_replication_group" {
  global_replication_group_id_suffix = var.name
  primary_replication_group_id       = aws_elasticache_replication_group.replication_group_primary.id
}

resource "aws_elasticache_replication_group" "replication_group_primary" {
  replication_group_id          = "${var.name}-primary"
  replication_group_description = "primary replication group"

  security_group_ids = [var.security_group_ids_primary]
  subnet_group_name  = var.subnet_group_name_primary

  kms_key_id = var.kms_key_id_primary
  auth_token = var.auth_token

  node_type   = var.node_type

  engine         = var.engine
  engine_version = var.engine_version

  transit_encryption_enabled    = true
  at_rest_encryption_enabled    = true

  automatic_failover_enabled    = true
  multi_az_enabled              = true
  apply_immediately             = true

  snapshot_retention_limit = 7

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

  cluster_mode {
    replicas_per_node_group = 3
  }
}

resource "aws_elasticache_replication_group" "replication_group_secondary" {
  provider = aws.ue2

  replication_group_id          = "${var.name}-secondary"
  replication_group_description = "secondary replication group"
  global_replication_group_id   = aws_elasticache_global_replication_group.global_replication_group.global_replication_group_id

  security_group_ids = [var.security_group_ids_secondary]
  subnet_group_name  = var.subnet_group_name_secondary

  kms_key_id = var.kms_key_id_secondary
  auth_token = var.auth_token
  automatic_failover_enabled    = true
  multi_az_enabled              = true
  apply_immediately             = true

  snapshot_retention_limit = 7

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

  cluster_mode {
    replicas_per_node_group = 3
  }
}

Actual Behavior

β•·
β”‚ Error: Conflicting configuration arguments
β”‚ 
β”‚   with module.elasticache-global.aws_elasticache_replication_group.replication_group_secondary,
β”‚   on modules/elasticache/main.tf line 42, in resource "aws_elasticache_replication_group" "replication_group_secondary":
β”‚   42:   global_replication_group_id   = aws_elasticache_global_replication_group.global_replication_group.global_replication_group_id
β”‚ 
β”‚ "global_replication_group_id": conflicts with parameter_group_name

Steps to Reproduce

I'm trying to create an ElastiCache Global Cluster and enable Redis Cluster mode by setting a parameter group but receive an error that "global_replication_group_id": conflicts with parameter_group_name.

According to the docs, this should work (although unclear if this works when using Global clusters):

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group

To enable cluster mode, use a parameter group that has cluster mode enabled. The default parameter groups provided by AWS end with ".cluster.on", for example default.redis6.x.cluster.on.
edmund-nelson commented 1 year ago

Has anyone ever found a solution to this? I'm also experiencing the same issue.

I have a custom parameter group where instead of having 16 databases I have 32. This is reflected on the primary replica - but the secondary replica can only have the default 16.

So presumably if there were more than 16 dbs on the primary, replication to the secondary would fail.

My error :-

β”‚ Error: Conflicting configuration arguments
β”‚ 
β”‚   with module.elasticache.aws_elasticache_replication_group.secondary[0],
β”‚   on .terraform/modules/elasticache/elasticache.tf line 138, in resource "aws_elasticache_replication_group" "secondary":
β”‚  138:   global_replication_group_id  = aws_elasticache_global_replication_group.elasticache[count.index].global_replication_group_id
β”‚ 
β”‚ "global_replication_group_id": conflicts with parameter_group_name