Skip to content

Commit

Permalink
Merge pull request #12651 from aristosvo/feature/downgrade-aks-sku
Browse files Browse the repository at this point in the history
`azurerm_kubernetes_cluster`: Support for downgrade `sku_tier`
  • Loading branch information
tombuildsstuff authored Jul 20, 2021
2 parents e20a8f5 + 4177162 commit 5e15107
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
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

0 comments on commit 5e15107

Please sign in to comment.