-
Notifications
You must be signed in to change notification settings - Fork 38
feat(ske): add datasource to query provider options #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
h3adex
wants to merge
1
commit into
stackitcloud:main
Choose a base branch
from
h3adex:feat/add-ske-provider-option-datasource
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| --- | ||
| # generated by https://github.com/hashicorp/terraform-plugin-docs | ||
| page_title: "stackit_ske_provider_options Data Source - stackit" | ||
| subcategory: "" | ||
| description: |- | ||
| Returns a list of supported Kubernetes versions and a list of supported machine types for the cluster nodes. | ||
| --- | ||
|
|
||
| # stackit_ske_provider_options (Data Source) | ||
|
|
||
| Returns a list of supported Kubernetes versions and a list of supported machine types for the cluster nodes. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| data "stackit_ske_provider_options" "default" {} | ||
|
|
||
| data "stackit_ske_provider_options" "eu02" { | ||
| region = "eu02" | ||
| } | ||
|
|
||
| locals { | ||
| k8s_versions = [ | ||
| for v in data.stackit_ske_provider_options.default.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.default.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.default.machine_images : [ | ||
| for v in mi.versions : | ||
| v.version if mi.name == "ubuntu" && v.state == "supported" | ||
| ] | ||
| ]) | ||
| } | ||
| ``` | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Optional | ||
|
|
||
| - `region` (String) Region override. If omitted, the provider’s region will be used. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `availability_zones` (List of String) List of availability zones in the selected region. | ||
| - `kubernetes_versions` (Attributes List) Supported Kubernetes versions. (see [below for nested schema](#nestedatt--kubernetes_versions)) | ||
| - `machine_images` (Attributes List) Supported machine image types and software versions. (see [below for nested schema](#nestedatt--machine_images)) | ||
| - `machine_types` (Attributes List) List of machine types (node sizes) available in the region. (see [below for nested schema](#nestedatt--machine_types)) | ||
| - `volume_types` (List of String) Supported root volume types (e.g., `storage_premium_perf1`). | ||
|
|
||
| <a id="nestedatt--kubernetes_versions"></a> | ||
| ### Nested Schema for `kubernetes_versions` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `expiration_date` (String) Expiration date of the version in RFC3339 format. | ||
| - `state` (String) Version state, such as `supported`, `preview`, or `deprecated`. | ||
| - `version` (String) Kubernetes version string (e.g., `1.33`). | ||
|
|
||
|
|
||
| <a id="nestedatt--machine_images"></a> | ||
| ### Nested Schema for `machine_images` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `name` (String) Name of the OS image (e.g., `ubuntu`). | ||
| - `versions` (Attributes List) Supported versions of the image. (see [below for nested schema](#nestedatt--machine_images--versions)) | ||
|
|
||
| <a id="nestedatt--machine_images--versions"></a> | ||
| ### Nested Schema for `machine_images.versions` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `cri` (List of String) Container runtimes supported (e.g., `containerd`). | ||
| - `expiration_date` (String) Expiration date of the version in RFC3339 format. | ||
| - `state` (String) State of the image version (e.g., `supported`, `preview`, `deprecated`). | ||
| - `version` (String) Machine image version string. | ||
|
|
||
|
|
||
|
|
||
| <a id="nestedatt--machine_types"></a> | ||
| ### Nested Schema for `machine_types` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `architecture` (String) CPU architecture (e.g., `x86_64`, `arm64`). | ||
| - `cpu` (Number) Number of virtual CPUs. | ||
| - `gpu` (Number) Number of GPUs included. | ||
| - `memory` (Number) Memory size in GB. | ||
| - `name` (String) Machine type name (e.g., `c2i.2`). | ||
29 changes: 29 additions & 0 deletions
29
examples/data-sources/stackit_ske_provider_options/data-source.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| data "stackit_ske_provider_options" "default" {} | ||
|
|
||
| data "stackit_ske_provider_options" "eu02" { | ||
| region = "eu02" | ||
| } | ||
|
|
||
| locals { | ||
| k8s_versions = [ | ||
| for v in data.stackit_ske_provider_options.default.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.default.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.default.machine_images : [ | ||
| for v in mi.versions : | ||
| v.version if mi.name == "ubuntu" && v.state == "supported" | ||
| ] | ||
| ]) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
stackit_ske_kubernetes_versionsstackit_ske_machine_typesstackit_ske_volume_types