Skip to content
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

azurerm_kubernetes_cluster: Support for downgrade sku_tier #12651

Merged
merged 2 commits into from
Jul 20, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ func testAccKubernetesCluster_upgradeSkuTier(t *testing.T) {
),
},
data.ImportStep(),
{
Config: r.freeSkuConfig(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

Expand Down Expand Up @@ -1156,9 +1163,6 @@ resource "azurerm_kubernetes_cluster" "test" {
}

func (KubernetesClusterResource) paidSkuConfig(data acceptance.TestData) string {
// @tombuildsstuff (2020-05-29) - this is only supported in a handful of regions
// whilst in Preview - hard-coding for now
location := "westus2" // TODO: data.Locations.Primary
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -1186,13 +1190,10 @@ resource "azurerm_kubernetes_cluster" "test" {
type = "SystemAssigned"
}
}
`, data.RandomInteger, location, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (KubernetesClusterResource) freeSkuConfig(data acceptance.TestData) string {
// @tombuildsstuff (2020-05-29) - this is only supported in a handful of regions
// whilst in Preview - hard-coding for now
location := "westus2" // TODO: data.Locations.Primary
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -1219,7 +1220,7 @@ resource "azurerm_kubernetes_cluster" "test" {
type = "SystemAssigned"
}
}
`, data.RandomInteger, location, data.RandomInteger, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (KubernetesClusterResource) tagsConfig(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
}),

CustomizeDiff: pluginsdk.CustomDiffInSequence(
// Downgrade from Paid to Free is not supported and requires rebuild to apply
pluginsdk.ForceNewIfChange("sku_tier", func(ctx context.Context, old, new, meta interface{}) bool {
return new == "Free"
}),
// Migration of `identity` to `service_principal` is not allowed, the other way around is
pluginsdk.ForceNewIfChange("service_principal.0.client_id", func(ctx context.Context, old, new, meta interface{}) bool {
return old == "msi" || old == ""
Expand Down Expand Up @@ -657,12 +653,7 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
"sku_tier": {
Type: pluginsdk.TypeString,
Optional: true,
// @tombuildsstuff (2020-05-29) - Preview limitations:
// * Currently, there is no way to remove Uptime SLA from an AKS cluster after creation with it enabled.
// * Private clusters aren't currently supported.
// @jackofallops (2020-07-21) - Update:
// * sku_tier can now be upgraded in place, downgrade requires rebuild
Default: string(containerservice.ManagedClusterSKUTierFree),
Default: string(containerservice.ManagedClusterSKUTierFree),
ValidateFunc: validation.StringInSlice([]string{
string(containerservice.ManagedClusterSKUTierFree),
string(containerservice.ManagedClusterSKUTierPaid),
Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ resource "azurerm_kubernetes_cluster" "example" {

* `sku_tier` - (Optional) The SKU Tier that should be used for this Kubernetes Cluster. Possible values are `Free` and `Paid` (which includes the Uptime SLA). Defaults to `Free`.

~> **Note:** It is currently possible to upgrade in place from `Free` to `Paid`. However, changing this value from `Paid` to `Free` will force a new resource to be created.

* `tags` - (Optional) A mapping of tags to assign to the resource.

* `windows_profile` - (Optional) A `windows_profile` block as defined below.
Expand Down