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
  • ...

@github-actions
Copy link

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions github-actions bot added the Stale PR is marked as stale due to inactivity. label Nov 12, 2025
@rubenhoenle rubenhoenle added needs-work PR needs changes by the author. and removed Stale PR is marked as stale due to inactivity. labels Nov 17, 2025
@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch 4 times, most recently from 31e0a82 to 3b48368 Compare November 18, 2025 14:20
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
@h3adex h3adex force-pushed the feat/add-ske-provider-option-datasource branch from 3b48368 to 8c9e943 Compare November 18, 2025 14:21
@h3adex
Copy link
Contributor Author

h3adex commented Nov 18, 2025

@rubenhoenle

I've just implemented your suggestion. While some work remains, could you please verify if this approach is heading in the right direction? I've split the functionality into 5 different data sources:

stackit_ske_kubernetes_versions
stackit_ske_machine_image_versions

Will also get the versionState flag once it is merged into the go-sdk:
https://docs.api.stackit.cloud/documentation/ske/version/v2#tag/ProviderOptions
stackitcloud/stackit-sdk-go#3786

I haven't yet identified a customer use case for the stackit_ske_volume_type data source. I'll reach out to our SKE team to request that they provide IOPS data through the API, allowing customers to filter volume names based on IOPS.

@h3adex h3adex requested a review from rubenhoenle November 18, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-work PR needs changes by the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants