Pattern for Managing AWS EFS in terraform

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.