ANSWERED: Unable to import aws_elasticache_cluster

Command used: terraform import aws_elasticache_cluster.cache-redis cache-redis

In AWS env: cache-redis already exists

Config on terraform (if i run this config and apply it, it works fine)
resource “aws_elasticache_cluster” “cache-redis” {
cluster_id = “cache-redis”
engine = “redis”
engine_version = “6.2”
maintenance_window = “sun:05:00-sun:07:00”
node_type = var.aws_elasticache_cluster_node_type_t3
num_cache_nodes = 1
port = 6379
parameter_group_name = “default.redis6.x”
subnet_group_name = aws_elasticache_subnet_group.cache.name
availability_zone = “${var.aws_region}a”
security_group_ids = [aws_security_group.cache-sg.id]
}

Error: resource address “aws_elasticache_cluster.cache-redis” does not exist in the configuration.

Before importing this resource, please create its configuration in the root module. For example:

resource “aws_elasticache_cluster” “cache-redis” {
** # (resource arguments)**
}

Terraform v0.12.4

  • provider.aws v2.70.0
  • provider.template v2.1.2

FOR ANYONE IN THE FUTURE HAVING THE SAME ISSUE, HERE IS THE ANSWER AS I WAS NOT ABLE TO FIND ANY ONLINE

if you have nested modules you need to import it in the following way

terraform import module.aws_elasticache_cluster.cache-redis-other cache-redis

Get the cluster id by using the following command:
aws elasticache describe-cache-clusters --region=us-west-2 (your region)

if anyone else ever runs into this the issue was with nested module

following command seem to start importing

terraform import module.YOUR_MODULE_NAME.aws_elasticache_cluster.cache-redis cache-redis
Here is the output
module.aws_elasticache_cluster.cache-redis: Importing from ID “cache-redis”…
module.aws_elasticache_cluster.cache-redis: Import prepared!
Prepared aws_elasticache_cluster for import
module.aws_elasticache_cluster.cache-redis: Refreshing state… [id=cache-redis]

Error: Cannot import non-existent remote object

While attempting to import an existing object to
aws_elasticache_cluster.cache-redis, the provider detected that no
object exists with the given id. Only pre-existing objects can be imported;
check that the id is correct and that it is associated with the provider’s
configured region or endpoint, or use “terraform apply” to create a new remote
object for this resource.

However, when i try terraform apply i get an error that the resource with the same name already exists any ideas?