cloudposse / terraform-aws-elasticache-redis

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

Destroy command not removing parameter-group and subnet groups. #94

Closed akshaysgithub closed 3 years ago

akshaysgithub commented 3 years ago

Hello,

I am using the plugin on our development platform, daily at night we want to destroy the redis cluster, and in morning start it back again. But the destroy command is not removing parameter-group and subnet-groups, created by the plugin. I get an error when running create after destroy

` Error: Invalid index

on .terraform/modules/redis/main.tf line 56, in locals: 56: elasticache_member_clusters = module.this.enabled ? tolist(aws_elasticache_replication_group.default.0.member_clusters) : [] |---------------- | aws_elasticache_replication_group.default is empty tuple

The given key does not identify an element in this collection value. `

When I manually delete it, and remove the tfstate file as well, then only it works.

Code:

`

module "redis" { source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master" availability_zones = var.availability_zones namespace = var.namespace stage = var.stage name = var.redis-name vpc_id = data.aws_vpc.selected.id allowed_security_groups = ["${aws_security_group.redis.id}","${data.aws_security_group.default.id}"] subnets = [local.subnet_ids_list[0],local.subnet_ids_list[1]] cluster_size = var.cluster_size instance_type = var.instance_type apply_immediately = true engine_version = var.engine_version family = var.family at_rest_encryption_enabled = var.at_rest_encryption_enabled transit_encryption_enabled = var.transit_encryption_enabled

parameter = [
  {
    name  = "notify-keyspace-events"
    value = "lK"
  }
]

} `

What am I doing wrong?

akshaysgithub commented 3 years ago

I will close this, since it worked when I ran the command 2nd time. :-)