# Pattern for Managing AWS EFS in terraform

**URL:** <https://discuss.hashicorp.com/t/pattern-for-managing-aws-efs-in-terraform/14461>\
**Category:** Terraform\
**Created:** [September 21, 2020, 3:07pm UTC](https://discuss.hashicorp.com/t/pattern-for-managing-aws-efs-in-terraform/14461 "2020-09-21T15:07:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slngshotx](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/slngshotx/32/11891_2.png) [@slngshotx](https://discuss.hashicorp.com/u/slngshotx)\
**Post date:** [September 21, 2020, 3:07pm UTC](https://discuss.hashicorp.com/t/pattern-for-managing-aws-efs-in-terraform/14461/1 "2020-09-21T15:07:10Z")

</div>

So our use case is that we want to create some AWS infrastructure using the last good backup of an EFS drive. I keep hitting a dead end, so wondering if anyone has a suggested approach or best practices. What I currently have is:-

1 - Have a shell script called from terraform using local\_exec that uses the AWS CLI to restore to a new EFS volume. It then mounts the volume and copies files into the correct location etc.  
2 - Have a tf file with the following that then sets up mount targets etc. on the EFS file system:-  
`data "aws_efs_file_system" "eks_cluster_persistence" { creation_token = "${var.cluster_name}-efs" } `  
So that the new EFS volume is created with the same creation token. On V0.13.3 this errors on apply with:-  
`Error: Search returned 0 results, please revise so only one is returned`

I’ve tried several approaches and can’t seem to find a sensible solution. Ideally this would be a one step apply.

- I could run the script first then import the EFS resource I guess.
- I could create the EFS volume in terraform then manually copy all data from another restored EFS but this seems really heavy weight and slow.

Any ideas gratefully accepted.
