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

Invalid function argument on v0.41.6 #151

Closed tyrannosaurus-becks closed 2 years ago

tyrannosaurus-becks commented 2 years ago

Describe the Bug

On version 0.41.6 of the module, when I attempt to import pre-existing items into my state that are unrelated to this module, I receive the following error:

│ Error: Invalid function argument
│
│   on .terraform/modules/redis_queue.aws_security_group/normalize.tf line 27, in locals:
│   27:     source_security_group_id = lookup(rule, "source_security_group_id", null)
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.

I am on version 1.1.2 of the Terraform CLI.

Expected Behavior

No failures due to module code failing to parse.

Steps to Reproduce

Create a terraform configuration that uses the module, like:

module "redis_queue" {
  count = local.environment == "staging" ? 0 : 1

  source                     = "cloudposse/elasticache-redis/aws"
  version                    = "0.41.6"
  availability_zones         = var.elasticache_availability_zones
  stage                      = local.environment
  name                       = var.elasticache_queue_name
  id_length_limit            = 40
  vpc_id                     = module.vpc.vpc_id
  allowed_cidr_blocks        = [module.vpc.vpc_cidr_block]
  subnets                    = module.vpc.database_subnets
  cluster_mode_enabled       = false
  cluster_size               = var.elasticache_cluster_size
  instance_type              = var.elasticache_queue_instance_size
  apply_immediately          = true
  automatic_failover_enabled = var.elasticache_cluster_size == 1 ? false : true
  multi_az_enabled           = var.elasticache_multi_az_enabled
  engine_version             = "6.x"
  family                     = "redis6.x"
  at_rest_encryption_enabled = false
  transit_encryption_enabled = false
  snapshot_window            = "05:00-06:00"
  snapshot_retention_limit   = var.elasticache_snapshot_retention_limit
  maintenance_window         = "wed:12:00-wed:14:00"
  tags                       = local.tags
}

Ensure you're on the noted version of the terraform CLI and Elasticache module. Attempt to run "terraform import". Observe the error.

Environment (please complete the following information):

Thank you for looking at this! Much appreciated.

tyrannosaurus-becks commented 2 years ago

Actually, I'm going to close this. I'm seeing this is likely due to breaking changes introduced in v41. Will open a separate ticket if I'm unable to resolve it, but this is likely an issue on my end. Thanks!