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

[Bug]: aws_elasticache_replication_group: unable to launch from snapshot due to slots error #32962

Open SanthanCH opened 1 year ago

SanthanCH commented 1 year ago

Terraform Core Version

1.5.4

AWS Provider Version

4.67.0

Affected Resource(s)

aws_elasticache_replication_group

Expected Behavior

Launching redis cluster from snapshot_arns requires slots but there is no parameter which we can fill for the slots

Actual Behavior

I was not able to launch cluster from the snapshot for cluster mode enabled as it is asking for slots . not able to add slots(of shard) as a parameter even in the terraform

Relevant Error/Panic Output Snippet

│ Error: creating ElastiCache Replication Group (***_******): InvalidParameterCombination: Slots must be provided when restoring from snapshot ARNs with cluster mode enabled

Terraform Configuration Files

resource "aws_elasticache_replication_group" "redis_replication_group" {
  description                = var.replication_group_id
  replication_group_id       = var.replication_group_id
  node_type                  = var.instance_type
  num_cache_clusters         = var.cluster_mode_enabled ? null : var.cluster_size
  engine                     = "redis"
  parameter_group_name       = var.use_existing_parameter_group ? var.parameter_group_name : module.aws_elasticache_parameter_group.redis_parameter_group_name[0]
  subnet_group_name          = var.subnet_group_name
  port                       = 6379
  automatic_failover_enabled = var.cluster_mode_enabled ? true : var.automatic_failover_enabled
  multi_az_enabled           = var.multi_az_enabled
  security_group_ids         = var.use_existing_security_group ? var.security_group_ids : module.redis_security_group.security_group_id
  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
  at_rest_encryption_enabled = var.at_rest_encryption_enabled
  engine_version             = var.engine_version
  notification_topic_arn     = var.sns_arn
  snapshot_name              = var.snapshot_name
  snapshot_arns              = var.snapshot_arns
  snapshot_window            = var.snapshot_window
  snapshot_retention_limit   = var.snapshot_retention_limit
  final_snapshot_identifier  = "${var.replication_group_id}${var.final_snapshot_identifier}"
  apply_immediately          = var.apply_immediately
  data_tiering_enabled       = var.data_tiering_enabled
  auto_minor_version_upgrade = var.auto_minor_version_upgrade
  maintenance_window         = var.maintenance_window

  dynamic "log_delivery_configuration" {
    for_each = var.slow_log_enabled ? [1] : []
    content {
      log_type         = "slow-log"
      destination      = module.redis_log_groups.slow_log_group_name
      destination_type = "cloudwatch-logs"
      log_format       = "json"
    }
  }

  dynamic "log_delivery_configuration" {
    for_each = var.engine_log_enabled ? [1] : []
    content {
      log_type         = "engine-log"
      destination      = module.redis_log_groups.engine_log_group_name
      destination_type = "cloudwatch-logs"
      log_format       = "json"
    }
  }
  tags       = local.tags
}

snapshot_arns                        = ["arn:aws:s3:::xxxxxxxxxx.rdb"]

Steps to Reproduce

Get the backup of any cluster mode enabled redis of any shard and copy that snapshot to S3 .so you will get the rdb file then try to launch the cluster using the same rdb file

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://github.com/hashicorp/terraform-provider-aws/issues/5577 https://github.com/hashicorp/terraform-provider-aws/issues/5510

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Looks like this might be due to missing the option to configure NodeGroupConfiguration:

However, it is required when seeding a Redis (cluster mode enabled) cluster from a S3 rdb file. You must configure each node group (shard) using this parameter because you must specify the slots for each node group.

SanthanCH commented 1 year ago

But the option is missing now how can i specify the slots ?When can we expect this to be resolved ?