Import several existing resources in Terraform state takes very long time

Viewed 871

I'm trying to import several resources by creating a scripts which read AWS resources and then import in Terraform state file using terraform import. The fact is that it takes ages because the import command upload at every call the changes to the remote state in S3. Do you have any idea how to approach in a different way the problem?

1 Answers

You could try to disable the remote state (delete the S3 state and keep a copy just in case), then import to the local path the state and once you finish all the imports you can configure the backend again and run terraform init -reconfigure then terraform will ask you to upload the local state to S3.

/Users/koe/.terraform-versions/terraform-0.9.11/terraform init -reconfigure
Initializing the backend...
Do you want to copy state from "local" to "s3"?
  Pre-existing state was found in "local" while migrating to "s3". No existing
  state was found in "s3". Do you want to copy the state from "local" to
  "s3"? Enter "yes" to copy and "no" to start with an empty state.

  Enter a value:
Related