terraform-provider-stackitp.../docs/guides/import_resources.md
Alexander Dahmen 721e10a02f
chore(examples): Add import examples for all resources (#939)
* chore(examples): Add import examples for all resources

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Add guide: How to import resources

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

---------

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
2025-08-08 14:03:27 +02:00

27 lines
No EOL
989 B
Markdown

---
page_title: "How to import an existing resources"
---
# How to import an existing resources?
## 1. **Create a terraform config file and add an import block for your resource**
In order to import an existing resources in terraform you need to add an import block for the corresponding resource in a terraform config file.
There is an example for every resource under the [examples](../../examples/) folder.
E.g. the import statement for a `stackit_volume` looks like the following:
```terraform
import {
to = stackit_volume.import-example
id = "${var.project_id},${var.volume_id}"
}
```
## 2. **Generate the destination resource automatically**
Run `terraform plan -generate-config-out=generated.tf` to let terraform generate the configuration for you.
In this step the `stackit_volume.import-example` resource is generated and filled with informations of your existing resource.
## 3. **Finish the import**
Run `terraform apply` to add your resource to the terraform state.