Skip to content

Conversation

@h3adex
Copy link
Contributor

@h3adex h3adex commented Nov 3, 2025

Description

This PR adds the ske options API as datasource to query kubernetes and machine versions. Currently the API does not support any filtering option, but this can be done in the meanwhile using terraform locals. Example code is in the generated docs.

data "stackit_ske_provider_options" "this" {}

locals {
  k8s_versions = [
    for v in data.stackit_ske_provider_options.this.kubernetes_versions :
    v.version if v.state == "supported"
  ]
  first_k8s_version = length(local.k8s_versions) > 0 ? local.k8s_versions[0] : ""
  last_k8s_version = length(local.k8s_versions) > 0 ? local.k8s_versions[length(local.k8s_versions) - 1] : ""


  flatcar_supported_versions = flatten([
    for mi in data.stackit_ske_provider_options.this.machine_images : [
      for v in mi.versions :
      v.version if mi.name == "flatcar" && v.state == "supported"
    ]
  ])

  ubuntu_supported_versions = flatten([
    for mi in data.stackit_ske_provider_options.this.machine_images : [
      for v in mi.versions :
      v.version if mi.name == "ubuntu" && v.state == "supported"
    ]
  ])
}

output "first_k8s_version" {
  value = local.first_k8s_version
}

output "last_k8s_version" {
  value = local.last_k8s_version
}

output "k8s_versions" {
  value = local.k8s_versions
}

output "ubuntu_supported_version" {
  value = local.ubuntu_supported_versions[0]
}

output "flatcar_supported_version" {
  value = local.flatcar_supported_versions[0]
}

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@h3adex h3adex requested a review from a team as a code owner November 3, 2025 15:25
@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch from 2b4b6de to f5062fe Compare November 3, 2025 15:28
@hown3d
Copy link
Member

hown3d commented Nov 3, 2025

Even if the API does not allow for filtering at the moment, we should still support filtering in the terraform go code.
Using locals may be possible, but is not a nice API and not something I want to recommend.

@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch from f5062fe to 186901b Compare November 3, 2025 15:32
@hown3d
Copy link
Member

hown3d commented Nov 3, 2025

Closes #953

@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch 3 times, most recently from f0516e4 to 1082886 Compare November 3, 2025 15:42
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch from 1082886 to 9315710 Compare November 3, 2025 15:44
## Example Usage

```terraform
data "stackit_ske_provider_options" "default" {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list provider options endpoint returns a lot of different information.

I wouldn't combine all of this into a single datasource, instead I would create multiple datasources here. (IMO there should be also multiple endpoints for listing k8s versions, listing machine types, ... but that's another discussion.)

So I would suggest

  • datasource stackit_ske_kubernetes_versions
  • datasource stackit_ske_machine_types
  • datasource stackit_ske_volume_types
  • ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants