-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Problem description
Creating a stackit_server
resource requires specifying an image_id, it would be useful to be able to discover this in Terraform based on a human friendly label.
This would also be useful for images we upload ourselves, as we for instance for a workflow when we're provided an image with a specific version that we upload outside of the Terraform deployment, then we just switch the image version reference.
Proposed solution
I would like to be able to use Terraform to discover the image_id based on the image name, or the distribution family. Bonus points for being able to automatically select the latest minor release of the specified distribution. For the latter part I would suggest being able to labels to filter the request and select the latest published version (see data.aws_ami use of most_recent
).
data "stackit_image" "ubuntu" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "Ubuntu 24.04"
}
data "stackit_image" "alpine" {
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
labels = {
os = "linux",
distro = "alpine",
version = "3.*"
}
most_recent = true
}