terraform-provider-stackitp.../examples/resources/stackit_server/resource.tf
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
1 KiB
HCL

resource "stackit_server" "example" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "example-server"
boot_volume = {
size = 64
source_type = "image"
source_id = "59838a89-51b1-4892-b57f-b3caf598ee2f" // Ubuntu 24.04
}
availability_zone = "xxxx-x"
machine_type = "g1.1"
network_interfaces = [
stackit_network_interface.example.network_interface_id
]
}
# Only use the import statement, if you want to import an existing server
# Note: There will be a conflict which needs to be resolved manually.
# Must set a configuration value for the boot_volume.source_type and boot_volume.source_id attribute as the provider has marked it as required.
# Since those attributes are not fetched in general from the API call, after adding them this would replace your server resource after an terraform apply.
# In order to prevent this you need to add:
# lifecycle {
# ignore_changes = [ boot_volume ]
# }
import {
to = stackit_server.import-example
id = "${var.project_id},${var.server_id}"
}