Skip to content

Commit

Permalink
azurerm_windows_web_app, azurerm_windows_web_app_slot, `azurerm_l…
Browse files Browse the repository at this point in the history
…inux_web_app`, `azurerm_linux_web_app_slot` - remove `auto_heal_enabled` property (#26763)

* remove the restrictions between auto heal enabled and the detailed auto heal settings

* update docs and test cases for updated auto heal schema

* remove auto_heal_enable restriction for linux and app slot as well

* update auto heal schema and test cases

* revert the type change in migration part

* revert changes for migration

* remove the top autoheal switch
  • Loading branch information
xiaxyi authored Aug 20, 2024
1 parent 81bcedb commit 3893142
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 126 deletions.
7 changes: 2 additions & 5 deletions internal/services/appservice/helpers/auto_heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ func autoHealSettingSchemaWindows() *pluginsdk.Schema {
"action": autoHealActionSchemaWindows(),
},
},
RequiredWith: []string{
"site_config.0.auto_heal_enabled",
},
}
}

Expand Down Expand Up @@ -218,7 +215,7 @@ func autoHealTriggerSchemaWindows() *pluginsdk.Schema {
},

"status_code": {
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Optional: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down Expand Up @@ -388,7 +385,7 @@ func autoHealTriggerSchemaWindowsComputed() *pluginsdk.Schema {
},

"status_code": {
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down
30 changes: 8 additions & 22 deletions internal/services/appservice/helpers/linux_web_app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type SiteConfigLinux struct {
ApiManagementConfigId string `tfschema:"api_management_api_id"`
ApiDefinition string `tfschema:"api_definition_url"`
AppCommandLine string `tfschema:"app_command_line"`
AutoHeal bool `tfschema:"auto_heal_enabled"`
AutoHealSettings []AutoHealSettingLinux `tfschema:"auto_heal_setting"`
UseManagedIdentityACR bool `tfschema:"container_registry_use_managed_identity"`
ContainerRegistryMSI string `tfschema:"container_registry_managed_identity_client_id"`
Expand Down Expand Up @@ -88,14 +87,6 @@ func SiteConfigSchemaLinux() *pluginsdk.Schema {

"application_stack": linuxApplicationStackSchema(),

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
RequiredWith: []string{
"site_config.0.auto_heal_setting",
},
},

"auto_heal_setting": autoHealSettingSchemaLinux(),

"container_registry_use_managed_identity": {
Expand Down Expand Up @@ -321,11 +312,6 @@ func SiteConfigSchemaLinuxComputed() *pluginsdk.Schema {

"application_stack": linuxApplicationStackSchemaComputed(),

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"auto_heal_setting": autoHealSettingSchemaLinuxComputed(),

"container_registry_use_managed_identity": {
Expand Down Expand Up @@ -490,9 +476,6 @@ func autoHealSettingSchemaLinux() *pluginsdk.Schema {
"action": autoHealActionSchemaLinux(),
},
},
RequiredWith: []string{
"site_config.0.auto_heal_enabled",
},
}
}

Expand Down Expand Up @@ -586,7 +569,7 @@ func autoHealTriggerSchemaLinux() *pluginsdk.Schema {
},

"status_code": {
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Optional: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down Expand Up @@ -753,7 +736,7 @@ func autoHealTriggerSchemaLinuxComputed() *pluginsdk.Schema {
},

"status_code": {
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down Expand Up @@ -892,7 +875,7 @@ func (s *SiteConfigLinux) ExpandForCreate(appSettings map[string]string) (*webap
expanded.FtpsState = pointer.To(webapps.FtpsState(s.FtpsState))
expanded.MinTlsVersion = pointer.To(webapps.SupportedTlsVersions(s.MinTlsVersion))
expanded.ScmMinTlsVersion = pointer.To(webapps.SupportedTlsVersions(s.ScmMinTlsVersion))
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.AutoHealEnabled = pointer.To(false)
expanded.VnetRouteAllEnabled = pointer.To(s.VnetRouteAllEnabled)
expanded.IPSecurityRestrictionsDefaultAction = pointer.To(webapps.DefaultAction(s.IpRestrictionDefaultAction))
expanded.ScmIPSecurityRestrictionsDefaultAction = pointer.To(webapps.DefaultAction(s.ScmIpRestrictionDefaultAction))
Expand Down Expand Up @@ -1009,6 +992,7 @@ func (s *SiteConfigLinux) ExpandForCreate(appSettings map[string]string) (*webap
}

if len(s.AutoHealSettings) == 1 {
expanded.AutoHealEnabled = pointer.To(true)
expanded.AutoHealRules = expandAutoHealSettingsLinux(s.AutoHealSettings)
}

Expand All @@ -1020,7 +1004,6 @@ func (s *SiteConfigLinux) ExpandForUpdate(metadata sdk.ResourceMetaData, existin

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.LocalMySqlEnabled = pointer.To(s.LocalMysql)
expanded.RemoteDebuggingEnabled = pointer.To(s.RemoteDebugging)
Expand Down Expand Up @@ -1175,6 +1158,10 @@ func (s *SiteConfigLinux) ExpandForUpdate(metadata sdk.ResourceMetaData, existin
}

if metadata.ResourceData.HasChange("site_config.0.auto_heal_setting") {
expanded.AutoHealEnabled = pointer.To(false)
if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
}
expanded.AutoHealRules = expandAutoHealSettingsLinux(s.AutoHealSettings)
}

Expand All @@ -1185,7 +1172,6 @@ func (s *SiteConfigLinux) Flatten(appSiteConfig *webapps.SiteConfig) {
if appSiteConfig != nil {
s.AlwaysOn = pointer.From(appSiteConfig.AlwaysOn)
s.AppCommandLine = pointer.From(appSiteConfig.AppCommandLine)
s.AutoHeal = pointer.From(appSiteConfig.AutoHealEnabled)
s.AutoHealSettings = flattenAutoHealSettingsLinux(appSiteConfig.AutoHealRules)
s.ContainerRegistryMSI = pointer.From(appSiteConfig.AcrUserManagedIdentityID)
s.DetailedErrorLogging = pointer.From(appSiteConfig.DetailedErrorLoggingEnabled)
Expand Down
37 changes: 12 additions & 25 deletions internal/services/appservice/helpers/web_app_slot_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type SiteConfigLinuxWebAppSlot struct {
ApiManagementConfigId string `tfschema:"api_management_api_id"`
ApiDefinition string `tfschema:"api_definition_url"`
AppCommandLine string `tfschema:"app_command_line"`
AutoHeal bool `tfschema:"auto_heal_enabled"`
AutoHealSettings []AutoHealSettingLinux `tfschema:"auto_heal_setting"`
AutoSwapSlotName string `tfschema:"auto_swap_slot_name"`
UseManagedIdentityACR bool `tfschema:"container_registry_use_managed_identity"`
Expand Down Expand Up @@ -88,14 +87,6 @@ func SiteConfigSchemaLinuxWebAppSlot() *pluginsdk.Schema {

"application_stack": linuxApplicationStackSchema(),

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
RequiredWith: []string{
"site_config.0.auto_heal_setting",
},
},

"auto_heal_setting": autoHealSettingSchemaLinux(),

"container_registry_use_managed_identity": {
Expand Down Expand Up @@ -292,7 +283,6 @@ type SiteConfigWindowsWebAppSlot struct {
ApiDefinition string `tfschema:"api_definition_url"`
ApplicationStack []ApplicationStackWindows `tfschema:"application_stack"`
AppCommandLine string `tfschema:"app_command_line"`
AutoHeal bool `tfschema:"auto_heal_enabled"`
AutoHealSettings []AutoHealSettingWindows `tfschema:"auto_heal_setting"`
AutoSwapSlotName string `tfschema:"auto_swap_slot_name"`
UseManagedIdentityACR bool `tfschema:"container_registry_use_managed_identity"`
Expand Down Expand Up @@ -358,15 +348,6 @@ func SiteConfigSchemaWindowsWebAppSlot() *pluginsdk.Schema {
Optional: true,
},

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
RequiredWith: []string{
"site_config.0.auto_heal_setting",
},
},

"auto_heal_setting": autoHealSettingSchemaWindows(),

"auto_swap_slot_name": {
Expand Down Expand Up @@ -575,7 +556,7 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForCreate(appSettings map[string]strin
expanded.FtpsState = pointer.To(webapps.FtpsState(s.FtpsState))
expanded.MinTlsVersion = pointer.To(webapps.SupportedTlsVersions(s.MinTlsVersion))
expanded.ScmMinTlsVersion = pointer.To(webapps.SupportedTlsVersions(s.ScmMinTlsVersion))
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.AutoHealEnabled = pointer.To(false)
expanded.VnetRouteAllEnabled = pointer.To(s.VnetRouteAllEnabled)
expanded.IPSecurityRestrictionsDefaultAction = pointer.To(webapps.DefaultAction(s.IpRestrictionDefaultAction))
expanded.ScmIPSecurityRestrictionsDefaultAction = pointer.To(webapps.DefaultAction(s.ScmIpRestrictionDefaultAction))
Expand Down Expand Up @@ -698,6 +679,7 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForCreate(appSettings map[string]strin
}

if len(s.AutoHealSettings) == 1 {
expanded.AutoHealEnabled = pointer.To(true)
expanded.AutoHealRules = expandAutoHealSettingsLinux(s.AutoHealSettings)
}

Expand All @@ -709,7 +691,6 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaDat

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.LocalMySqlEnabled = pointer.To(s.LocalMysql)
expanded.RemoteDebuggingEnabled = pointer.To(s.RemoteDebugging)
Expand Down Expand Up @@ -870,6 +851,10 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaDat
}

if metadata.ResourceData.HasChange("site_config.0.auto_heal_setting") {
expanded.AutoHealEnabled = pointer.To(false)
if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
}
expanded.AutoHealRules = expandAutoHealSettingsLinux(s.AutoHealSettings)
}

Expand All @@ -879,7 +864,6 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaDat
func (s *SiteConfigLinuxWebAppSlot) Flatten(appSiteSlotConfig *webapps.SiteConfig) {
s.AlwaysOn = pointer.From(appSiteSlotConfig.AlwaysOn)
s.AppCommandLine = pointer.From(appSiteSlotConfig.AppCommandLine)
s.AutoHeal = pointer.From(appSiteSlotConfig.AutoHealEnabled)
s.AutoHealSettings = flattenAutoHealSettingsLinux(appSiteSlotConfig.AutoHealRules)
s.AutoSwapSlotName = pointer.From(appSiteSlotConfig.AutoSwapSlotName)
s.ContainerRegistryMSI = pointer.From(appSiteSlotConfig.AcrUserManagedIdentityID)
Expand Down Expand Up @@ -1000,7 +984,7 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForCreate(appSettings map[string]str

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.AutoHealEnabled = pointer.To(false)
expanded.FtpsState = pointer.To(webapps.FtpsState(s.FtpsState))
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.LoadBalancing = pointer.To(webapps.SiteLoadBalancing(s.LoadBalancing))
Expand Down Expand Up @@ -1145,6 +1129,7 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForCreate(appSettings map[string]str
}

if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
expanded.AutoHealRules = expandAutoHealSettingsWindows(s.AutoHealSettings)
}
return expanded, nil
Expand All @@ -1158,7 +1143,6 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaD

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.ScmIPSecurityRestrictionsUseMain = pointer.To(s.ScmUseMainIpRestriction)
expanded.LocalMySqlEnabled = pointer.To(s.LocalMysql)
Expand Down Expand Up @@ -1341,6 +1325,10 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaD
}

if metadata.ResourceData.HasChange("site_config.0.auto_heal_setting") {
expanded.AutoHealEnabled = pointer.To(false)
if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
}
expanded.AutoHealRules = expandAutoHealSettingsWindows(s.AutoHealSettings)
}

Expand All @@ -1358,7 +1346,6 @@ func (s *SiteConfigWindowsWebAppSlot) Flatten(appSiteSlotConfig *webapps.SiteCon

s.AlwaysOn = pointer.From(appSiteSlotConfig.AlwaysOn)
s.AppCommandLine = pointer.From(appSiteSlotConfig.AppCommandLine)
s.AutoHeal = pointer.From(appSiteSlotConfig.AutoHealEnabled)
s.AutoHealSettings = flattenAutoHealSettingsWindows(appSiteSlotConfig.AutoHealRules)
s.AutoSwapSlotName = pointer.From(appSiteSlotConfig.AutoSwapSlotName)
s.ContainerRegistryUserMSI = pointer.From(appSiteSlotConfig.AcrUserManagedIdentityID)
Expand Down
25 changes: 7 additions & 18 deletions internal/services/appservice/helpers/windows_web_app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type SiteConfigWindows struct {
ApiManagementConfigId string `tfschema:"api_management_api_id"`
ApiDefinition string `tfschema:"api_definition_url"`
AppCommandLine string `tfschema:"app_command_line"`
AutoHeal bool `tfschema:"auto_heal_enabled"`
AutoHealSettings []AutoHealSettingWindows `tfschema:"auto_heal_setting"`
UseManagedIdentityACR bool `tfschema:"container_registry_use_managed_identity"`
ContainerRegistryUserMSI string `tfschema:"container_registry_managed_identity_client_id"`
Expand Down Expand Up @@ -92,15 +91,6 @@ func SiteConfigSchemaWindows() *pluginsdk.Schema {
Optional: true,
},

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
RequiredWith: []string{
"site_config.0.auto_heal_setting",
},
},

"auto_heal_setting": autoHealSettingSchemaWindows(),

"container_registry_use_managed_identity": {
Expand Down Expand Up @@ -335,11 +325,6 @@ func SiteConfigSchemaWindowsComputed() *pluginsdk.Schema {
Computed: true,
},

"auto_heal_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"auto_heal_setting": autoHealSettingSchemaWindowsComputed(),

"container_registry_use_managed_identity": {
Expand Down Expand Up @@ -483,8 +468,8 @@ func (s *SiteConfigWindows) ExpandForCreate(appSettings map[string]string) (*web
expanded := &webapps.SiteConfig{}

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AutoHealEnabled = pointer.To(false)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.FtpsState = pointer.To(webapps.FtpsState(s.FtpsState))
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.LoadBalancing = pointer.To(webapps.SiteLoadBalancing(s.LoadBalancing))
Expand Down Expand Up @@ -627,6 +612,7 @@ func (s *SiteConfigWindows) ExpandForCreate(appSettings map[string]string) (*web
}

if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
expanded.AutoHealRules = expandAutoHealSettingsWindows(s.AutoHealSettings)
}

Expand All @@ -641,7 +627,6 @@ func (s *SiteConfigWindows) ExpandForUpdate(metadata sdk.ResourceMetaData, exist

expanded.AlwaysOn = pointer.To(s.AlwaysOn)
expanded.AcrUseManagedIdentityCreds = pointer.To(s.UseManagedIdentityACR)
expanded.AutoHealEnabled = pointer.To(s.AutoHeal)
expanded.HTTP20Enabled = pointer.To(s.Http2Enabled)
expanded.ScmIPSecurityRestrictionsUseMain = pointer.To(s.ScmUseMainIpRestriction)
expanded.LocalMySqlEnabled = pointer.To(s.LocalMysql)
Expand Down Expand Up @@ -828,7 +813,12 @@ func (s *SiteConfigWindows) ExpandForUpdate(metadata sdk.ResourceMetaData, exist
}
expanded.Cors = cors
}

if metadata.ResourceData.HasChange("site_config.0.auto_heal_setting") {
expanded.AutoHealEnabled = pointer.To(false)
if len(s.AutoHealSettings) != 0 {
expanded.AutoHealEnabled = pointer.To(true)
}
expanded.AutoHealRules = expandAutoHealSettingsWindows(s.AutoHealSettings)
}

Expand All @@ -843,7 +833,6 @@ func (s *SiteConfigWindows) Flatten(appSiteConfig *webapps.SiteConfig, currentSt
if appSiteConfig != nil {
s.AlwaysOn = pointer.From(appSiteConfig.AlwaysOn)
s.AppCommandLine = pointer.From(appSiteConfig.AppCommandLine)
s.AutoHeal = pointer.From(appSiteConfig.AutoHealEnabled)
s.AutoHealSettings = flattenAutoHealSettingsWindows(appSiteConfig.AutoHealRules)
s.ContainerRegistryUserMSI = pointer.From(appSiteConfig.AcrUserManagedIdentityID)
s.Cors = FlattenCorsSettings(appSiteConfig.Cors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,6 @@ resource "azurerm_linux_web_app" "test" {
container_registry_use_managed_identity = true
container_registry_managed_identity_client_id = azurerm_user_assigned_identity.test.client_id
auto_heal_enabled = true
auto_heal_setting {
trigger {
status_code {
Expand Down
Loading

0 comments on commit 3893142

Please sign in to comment.