Recovering Terraform State
Uh oh.
So you made a typo and terraform rm
'd the wrong resource. Or you accidentally deleted S3 bucket terraform-111111011
instead of terraform-10111111
and your entire Terraform state is lost. It's ok! We've all done it, and there's a way out.
Using terraform import
terraform import
All Sym Terraform resources include support for the terraform import
command.
Note: this requires Sym Terraform provider v1.10.0 or greater
There are two types of imports:
- Import by name (slug) β used if the resource has no
type
field - Import by name (slug) and type β used if the resource has a
type
field
For example, if you have a sym_environment
and a sym_integration
:
resource "sym_environment" "this" {
name = "prod"
runtime_id = sym_runtime.other.id
integrations = {
slack_id = sym_integration.this.id
}
}
resource "sym_integration" "this" {
type = "slack"
name = "prod-workspace"
external_id = "T12345"
}
Then those resources could be imported with the following commands:
$ terraform import sym_environment.this prod
$ terraform import sym_integration.this slack:prod-workspace
Not sure what slug to use?
Some resources, like
sym_secret
, have autogenerated slugs that won't be defined in Terraform. For these resources, you can list them and their slugs using thesymflow
CLI.
Below are all Sym resources and a template command showing how to import each one:
Resource | Import Format |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Updated 8 days ago