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

Can't import existing aws_elasticache_replication_group without recreate resource #207

Closed ABRIO-PR closed 6 months ago

ABRIO-PR commented 8 months ago

Describe the Bug

After importing an existing AWS ElastiCache for Redis, terraform wants to recreate it. This is caused by the "security_group_names" parameter. The other options in my template match the existing resource.

-/+ resource "aws_elasticache_replication_group" "default" {
      ~ arn                            = "arn:aws:elasticache:us-east-1:276741630740:replicationgroup:redis" -> (known after apply)
      ~ cluster_enabled                = false -> (known after apply)
      + configuration_endpoint_address = (known after apply)
      ~ engine_version_actual          = "6.2.6" -> (known after apply)
      + global_replication_group_id    = (known after apply)
      ~ id                             = "redis" -> (known after apply)
      ~ member_clusters                = [
          - "redis-001",
        ] -> (known after apply)
      ~ num_node_groups                = 1 -> (known after apply)
      ~ primary_endpoint_address       = "redis.6jpnqy.ng.0001.use1.cache.amazonaws.com" -> (known after apply)
      ~ reader_endpoint_address        = "redis-ro.6jpnqy.ng.0001.use1.cache.amazonaws.com" -> (known after apply)
      ~ replicas_per_node_group        = 0 -> (known after apply)
      + security_group_names           = (known after apply) # forces replacement
        tags                           = {
            "Name" = "redis"
        }
      - user_group_ids                 = [] -> null
        # (21 unchanged attributes hidden)
    }

By adding to the resource 'resource "aws_elasticache_replication_group" "default"' in the module

  lifecycle {
    ignore_changes = [
      security_group_names,
    ]
  }

it works great and Terraform doesn't find any changes.

The module does not support the "security_group_names" parameter

Expected Behavior

No changes. Your infrastructure matches the configuration.

Steps to Reproduce

terraform import 'module.redis-cluster["elasticache-redis"].aws_elasticache_replication_group.default[0]' elasticache-redis

Screenshots

No response

Environment

Module version = "0.53.0" Terraform version = "1.5.0" Provider version = "5.21.0"

Additional Context

No response

y3ti commented 7 months ago

It's a bug in AWS Provider: https://github.com/hashicorp/terraform-provider-aws/issues/32835

y3ti commented 6 months ago

Fixed in v1.2.0

ABRIO-PR commented 6 months ago

It's great! It works for me. Thanks!