# ANSWERED: Unable to import aws\_elasticache\_cluster

**URL:** <https://discuss.hashicorp.com/t/answered-unable-to-import-aws-elasticache-cluster/43766>\
**Category:** Terraform Providers\
**Created:** [August 30, 2022, 2:40pm UTC](https://discuss.hashicorp.com/t/answered-unable-to-import-aws-elasticache-cluster/43766 "2022-08-30T14:40:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastermindiv](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mastermindiv/32/23944_2.png) [@mastermindiv](https://discuss.hashicorp.com/u/mastermindiv)\
**Post date:** [August 30, 2022, 2:40pm UTC](https://discuss.hashicorp.com/t/answered-unable-to-import-aws-elasticache-cluster/43766/1 "2022-08-30T14:40:16Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![mastermindiv](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mastermindiv/32/23944_2.png) [@mastermindiv](https://discuss.hashicorp.com/u/mastermindiv)\
**Post date:** [August 30, 2022, 3:06pm UTC](https://discuss.hashicorp.com/t/answered-unable-to-import-aws-elasticache-cluster/43766/2 "2022-08-30T15:06:47Z")

</div>

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?
