Copy / Import resource from one statefile to another statefile terraform

124 Views Asked by At

I'm working on importing synthetics from one statefile to another.

I am confused with a couple things here: should it be terraform move or terraform import.

Also, how do we tell terraform that the monitor ID comes from a different statefile. Using below command:

currently in destination directory cli:

terraform import 'datadog_synthetics.datadog_test.resource["test-synthetic-abc"]' 124349450

124349450 - this is the monitor/synthetic ID from datadog [whos' source comes from different statefile] but how does

Secondly - when I ran above command it alerted below:

│ Error: Resource already managed by Terraform
│ 
│ Terraform is already managing a remote object for datadog_synthetics.datadog_test.resource["test-synthetic-abc"]. To import to this address you must first remove the
│ existing object from the state.

When I did terraform state rm on it, it says this:

 Error: Cannot import non-existent remote object
│ 
│ While attempting to import an existing object to "datadog_synthetics.datadog_test.resource["test-synthetic-abc"]", 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.

can someone please explain what is wrong am I doing here?

Goal- Trying to import state of one synthetics test from one statefile[under workspace A] to another statefile[under workspace B].

thank you!

0

There are 0 best solutions below