Skip to content

Commit

Permalink
azurerm_mssql_server - minimum_tls_version no longer accepts `Dis…
Browse files Browse the repository at this point in the history
…abled`, `1.0` and `1.1` as a value in 5.0. (hashicorp#28230)

* `azurerm_mssql_server` - `minimum_tls_version` no longer accepts
`Disabled`, `1.0` and `1.1` as a value in 5.0.

* remove `TODO 4.0` comments
  • Loading branch information
ziyeqf authored Dec 10, 2024
1 parent a487111 commit 338dca6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
24 changes: 18 additions & 6 deletions internal/services/mssql/mssql_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
keyVaultParser "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/custompollers"
Expand All @@ -37,7 +38,7 @@ import (
)

func resourceMsSqlServer() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Create: resourceMsSqlServerCreate,
Read: resourceMsSqlServerRead,
Update: resourceMsSqlServerUpdate,
Expand Down Expand Up @@ -155,16 +156,12 @@ func resourceMsSqlServer() *pluginsdk.Resource {
},
},

// TODO 4.0: Switch this field to use None pattern...
"minimum_tls_version": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "1.2",
ValidateFunc: validation.StringInSlice([]string{
"1.0",
"1.1",
"1.2",
"Disabled",
}, false),
},

Expand Down Expand Up @@ -202,6 +199,22 @@ func resourceMsSqlServer() *pluginsdk.Resource {
pluginsdk.CustomizeDiffShim(msSqlPasswordChangeWhenAADAuthOnly),
),
}

if !features.FivePointOhBeta() {
resource.Schema["minimum_tls_version"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Default: "1.2",
ValidateFunc: validation.StringInSlice([]string{
"1.0",
"1.1",
"1.2",
"Disabled",
}, false),
}
}

return resource
}

func resourceMsSqlServerCreate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -286,7 +299,6 @@ func resourceMsSqlServerCreate(d *pluginsdk.ResourceData, meta interface{}) erro
props.Properties.RestrictOutboundNetworkAccess = pointer.To(servers.ServerNetworkAccessFlagEnabled)
}

// TODO 4.0: Switch this field to use None pattern...
if v := d.Get("minimum_tls_version"); v.(string) != "Disabled" {
props.Properties.MinimalTlsVersion = pointer.To(servers.MinimalTlsVersion(v.(string)))
}
Expand Down
11 changes: 8 additions & 3 deletions internal/services/mssql/mssql_server_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
Expand Down Expand Up @@ -52,6 +53,9 @@ func TestAccMsSqlServer_complete(t *testing.T) {
}

func TestAccMsSqlServer_minimumTLSVersionDisabled(t *testing.T) {
if features.FivePointOhBeta() {
t.Skipf("The service require minimum TLS version to be 1.2+, skip the `disabled` testing.")
}
data := acceptance.BuildTestData(t, "azurerm_mssql_server", "test")
r := MsSqlServerResource{}

Expand Down Expand Up @@ -389,7 +393,7 @@ resource "azurerm_mssql_server" "test" {
version = "12.0"
administrator_login = "missadministrator"
administrator_login_password = "thisIsKat11"
minimum_tls_version = "1.1"
minimum_tls_version = "1.2"
identity {
type = "SystemAssigned"
Expand Down Expand Up @@ -564,7 +568,7 @@ resource "azurerm_mssql_server" "test" {
version = "12.0"
administrator_login = "missadministrator"
administrator_login_password = "thisIsKat11"
minimum_tls_version = "1.0"
minimum_tls_version = "1.2"
public_network_access_enabled = false
primary_user_assigned_identity_id = azurerm_user_assigned_identity.test.id
Expand All @@ -575,7 +579,8 @@ resource "azurerm_mssql_server" "test" {
}
tags = {
DB = "NotProd"
update = "true"
DB = "NotProd"
}
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/5.0-upgrade-guide.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Please follow the format in the example below for listing breaking changes in re

* The properties `weekly_retention`, `monthly_retention` and `yearly_retention` now default to `PT0S`.

### `azurerm_mssql_server`

* The property `minimum_tls_version` no longer accepts `Disabled`, `1.0` or `1.1` as a value.

## `azurerm_network_watcher_flow_log`

* The deprecated `network_security_group_id` property has been removed in favour of the `target_resource_id` property.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/mssql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ The following arguments are supported:

~> **NOTE:** The `minimum_tls_version` is set to `Disabled` means all TLS versions are allowed. After you enforce a version of `minimum_tls_version`, it's not possible to revert to `Disabled`.

~> **NOTE:** Azure Services will require TLS 1.2+ by August 2025, please see this [announcement](https://azure.microsoft.com/en-us/updates/v2/update-retirement-tls1-0-tls1-1-versions-azure-services/) for more.

* `public_network_access_enabled` - (Optional) Whether public network access is allowed for this server. Defaults to `true`.

* `outbound_network_restriction_enabled` - (Optional) Whether outbound network traffic is restricted for this server. Defaults to `false`.
Expand Down

0 comments on commit 338dca6

Please sign in to comment.