* 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>
989 B
989 B
| 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 folder.
E.g. the import statement for a stackit_volume looks like the following:
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.