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>
This commit is contained in:
Alexander Dahmen 2025-08-08 14:03:27 +02:00 committed by GitHub
parent e62729679e
commit 721e10a02f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 837 additions and 5 deletions

View file

@ -0,0 +1,27 @@
---
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.