Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data-sources/ske_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ data "stackit_ske_cluster" "example" {
- `network` (Attributes) Network block as defined below. (see [below for nested schema](#nestedatt--network))
- `node_pools` (Attributes List) One or more `node_pool` block as defined below. (see [below for nested schema](#nestedatt--node_pools))
- `pod_address_ranges` (List of String) The network ranges (in CIDR notation) used by pods of the cluster.
- `service_account_issuer` (String) Service Account Issuer of the cluster.

<a id="nestedatt--extensions"></a>
### Nested Schema for `extensions`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/ske_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ To keep your Terraform plans clean and readable, always append new node pools to
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`,`region`,`name`".
- `kubernetes_version_used` (String) Full Kubernetes version used. For example, if 1.22 was set in `kubernetes_version_min`, this value may result to 1.22.15. SKE automatically updates the cluster Kubernetes version if you have set `maintenance.enable_kubernetes_version_updates` to true or if there is a mandatory update, as described in [General information for Kubernetes & OS updates](https://docs.stackit.cloud/products/runtime/kubernetes-engine/basics/version-updates/).
- `pod_address_ranges` (List of String) The network ranges (in CIDR notation) used by pods of the cluster.
- `service_account_issuer` (String) Service Account Issuer of the cluster.

<a id="nestedatt--node_pools"></a>
### Nested Schema for `node_pools`
Expand Down
4 changes: 4 additions & 0 deletions stackit/internal/services/ske/cluster/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func (r *clusterDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
Computed: true,
ElementType: types.StringType,
},
"service_account_issuer": schema.StringAttribute{
Description: "Service Account Issuer of the cluster.",
Computed: true,
},
"node_pools": schema.ListNestedAttribute{
Description: "One or more `node_pool` block as defined below.",
Computed: true,
Expand Down
13 changes: 13 additions & 0 deletions stackit/internal/services/ske/cluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type Model struct {
Extensions types.Object `tfsdk:"extensions"`
EgressAddressRanges types.List `tfsdk:"egress_address_ranges"`
PodAddressRanges types.List `tfsdk:"pod_address_ranges"`
ServiceAccountIssuer types.String `tfsdk:"service_account_issuer"`
Region types.String `tfsdk:"region"`
}

Expand Down Expand Up @@ -455,6 +456,13 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
listplanmodifier.UseStateForUnknown(),
},
},
"service_account_issuer": schema.StringAttribute{
Description: "Service Account Issuer of the cluster.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"node_pools": schema.ListNestedAttribute{
Description: "One or more `node_pool` block as defined below.\n" +
"To keep your Terraform plans clean and readable, always append new node pools to the end of the list.",
Expand Down Expand Up @@ -1528,6 +1536,11 @@ func mapFields(ctx context.Context, cl *ske.Cluster, m *Model, region string) er
}
}

m.ServiceAccountIssuer = types.StringNull()
if cl.Status != nil && cl.Status.ServiceAccountIssuer != nil {
m.ServiceAccountIssuer = types.StringValue(*cl.Status.ServiceAccountIssuer)
}

err := mapNodePools(ctx, cl, m)
if err != nil {
return fmt.Errorf("map node_pools: %w", err)
Expand Down
67 changes: 38 additions & 29 deletions stackit/internal/services/ske/cluster/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestMapFields(t *testing.T) {
Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
Region: types.StringValue(testRegion),
KubernetesVersionUsed: types.StringValue(""),
},
Expand Down Expand Up @@ -139,11 +140,12 @@ func TestMapFields(t *testing.T) {
},
},
Status: &ske.ClusterStatus{
Aggregated: &cs,
Error: nil,
Hibernated: nil,
EgressAddressRanges: []string{"0.0.0.0/32", "1.1.1.1/32"},
PodAddressRanges: []string{"0.0.0.0/32", "1.1.1.1/32"},
Aggregated: &cs,
Error: nil,
Hibernated: nil,
EgressAddressRanges: []string{"0.0.0.0/32", "1.1.1.1/32"},
PodAddressRanges: []string{"0.0.0.0/32", "1.1.1.1/32"},
ServiceAccountIssuer: new("issuer"),
},
},
testRegion,
Expand All @@ -166,6 +168,7 @@ func TestMapFields(t *testing.T) {
types.StringValue("1.1.1.1/32"),
},
),
ServiceAccountIssuer: types.StringValue("issuer"),
NodePools: types.ListValueMust(
types.ObjectType{AttrTypes: nodePoolTypes},
[]attr.Value{
Expand Down Expand Up @@ -284,6 +287,7 @@ func TestMapFields(t *testing.T) {
Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
KubernetesVersionUsed: types.StringValue(""),
Region: types.StringValue(testRegion),
},
Expand Down Expand Up @@ -312,14 +316,15 @@ func TestMapFields(t *testing.T) {
},
testRegion,
Model{
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(true),
Expand Down Expand Up @@ -364,14 +369,15 @@ func TestMapFields(t *testing.T) {
},
testRegion,
Model{
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(false),
Expand Down Expand Up @@ -427,14 +433,15 @@ func TestMapFields(t *testing.T) {
},
testRegion,
Model{
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
Id: types.StringValue("pid,region,name"),
ProjectId: types.StringValue("pid"),
Name: types.StringValue("name"),
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
Maintenance: types.ObjectNull(maintenanceTypes),
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
Extensions: types.ObjectValueMust(extensionsTypes, map[string]attr.Value{
"acl": types.ObjectValueMust(aclTypes, map[string]attr.Value{
"enabled": types.BoolValue(true),
Expand Down Expand Up @@ -476,6 +483,7 @@ func TestMapFields(t *testing.T) {
Extensions: types.ObjectNull(extensionsTypes),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
KubernetesVersionUsed: types.StringValue(""),
Region: types.StringValue(testRegion),
},
Expand Down Expand Up @@ -606,6 +614,7 @@ func TestMapFields(t *testing.T) {
KubernetesVersionUsed: types.StringValue("1.2.3"),
EgressAddressRanges: types.ListNull(types.StringType),
PodAddressRanges: types.ListNull(types.StringType),
ServiceAccountIssuer: types.StringNull(),
NodePools: types.ListValueMust(
types.ObjectType{AttrTypes: nodePoolTypes},
[]attr.Value{
Expand Down
3 changes: 3 additions & 0 deletions stackit/internal/services/ske/ske_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func TestAccSKEMax(t *testing.T) {
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "egress_address_ranges.0"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster", "pod_address_ranges.#", "1"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "pod_address_ranges.0"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "service_account_issuer"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "kubernetes_version_used"),

resource.TestCheckResourceAttr("stackit_ske_cluster.cluster", "network.control_plane.access_scope", testutil.ConvertConfigVariable(testConfigVarsMax["network_control_plane_access_scope"])),
Expand Down Expand Up @@ -396,6 +397,7 @@ func TestAccSKEMax(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "pod_address_ranges.#", "1"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster", "pod_address_ranges.0"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "network.control_plane.access_scope", testutil.ConvertConfigVariable(testConfigVarsMax["network_control_plane_access_scope"])),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster", "service_account_issuer"),
),
},
// 3) Import cluster
Expand Down Expand Up @@ -483,6 +485,7 @@ func TestAccSKEMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster", "pod_address_ranges.#", "1"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "pod_address_ranges.0"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "kubernetes_version_used"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster", "service_account_issuer"),
),
},
// Deletion is done by the framework implicitly
Expand Down
Loading