From 65fd4ea60b482eeb1867652ad4560e7e2d90d09c Mon Sep 17 00:00:00 2001 From: Puneet Singh Sarna Date: Fri, 13 Dec 2024 03:23:24 -0800 Subject: [PATCH] `azurerm_nginx_deployment`: Deprecate `logging_storage_account` block (#27894) * `azurerm_nginx_deployment`: Deprecate `logging_storage_account` block NGINXaaS for Azure is deprecating the use of `logging_storage_account` block in favor of using Azure native logging configured via Azure Diagnostic Settings. * add deprecated logging_storage_account block for nginx deployment resource to 5.0 upgrade guide --------- Co-authored-by: Steph --- .../nginx/nginx_deployment_data_source.go | 53 ++++++------ .../nginx/nginx_deployment_resource.go | 82 ++++++++++--------- website/docs/5.0-upgrade-guide.html.markdown | 2 + website/docs/d/nginx_deployment.html.markdown | 10 --- website/docs/r/nginx_deployment.html.markdown | 10 --- 5 files changed, 74 insertions(+), 83 deletions(-) diff --git a/internal/services/nginx/nginx_deployment_data_source.go b/internal/services/nginx/nginx_deployment_data_source.go index 052ebffc5229..50d56dcc7c2f 100644 --- a/internal/services/nginx/nginx_deployment_data_source.go +++ b/internal/services/nginx/nginx_deployment_data_source.go @@ -32,7 +32,7 @@ type DeploymentDataSourceModel struct { DiagnoseSupportEnabled bool `tfschema:"diagnose_support_enabled"` Email string `tfschema:"email"` IpAddress string `tfschema:"ip_address"` - LoggingStorageAccount []LoggingStorageAccount `tfschema:"logging_storage_account"` + LoggingStorageAccount []LoggingStorageAccount `tfschema:"logging_storage_account,removedInNextMajorVersion"` FrontendPublic []FrontendPublic `tfschema:"frontend_public"` FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"` NetworkInterface []NetworkInterface `tfschema:"network_interface"` @@ -115,24 +115,6 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema { Computed: true, }, - "logging_storage_account": { - Type: pluginsdk.TypeList, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "container_name": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, - }, - }, - "frontend_public": { Type: pluginsdk.TypeList, Computed: true, @@ -199,6 +181,25 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Computed: true, } + + dataSource["logging_storage_account"] = &pluginsdk.Schema{ + Deprecated: "The `logging_storage_account` block has been deprecated and will be removed in v5.0 of the AzureRM Provider.", + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "container_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + } } return dataSource } @@ -253,12 +254,14 @@ func (m DeploymentDataSource) Read() sdk.ResourceFunc { output.NginxVersion = pointer.ToString(props.NginxVersion) output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport) - if props.Logging != nil && props.Logging.StorageAccount != nil { - output.LoggingStorageAccount = []LoggingStorageAccount{ - { - Name: pointer.ToString(props.Logging.StorageAccount.AccountName), - ContainerName: pointer.ToString(props.Logging.StorageAccount.ContainerName), - }, + if !features.FivePointOhBeta() { + if props.Logging != nil && props.Logging.StorageAccount != nil { + output.LoggingStorageAccount = []LoggingStorageAccount{ + { + Name: pointer.ToString(props.Logging.StorageAccount.AccountName), + ContainerName: pointer.ToString(props.Logging.StorageAccount.ContainerName), + }, + } } } diff --git a/internal/services/nginx/nginx_deployment_resource.go b/internal/services/nginx/nginx_deployment_resource.go index 521344f92bb2..f627e17b8868 100644 --- a/internal/services/nginx/nginx_deployment_resource.go +++ b/internal/services/nginx/nginx_deployment_resource.go @@ -72,7 +72,7 @@ type DeploymentModel struct { DiagnoseSupportEnabled bool `tfschema:"diagnose_support_enabled"` Email string `tfschema:"email"` IpAddress string `tfschema:"ip_address"` - LoggingStorageAccount []LoggingStorageAccount `tfschema:"logging_storage_account"` + LoggingStorageAccount []LoggingStorageAccount `tfschema:"logging_storage_account,removedInNextMajorVersion"` FrontendPublic []FrontendPublic `tfschema:"frontend_public"` FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"` NetworkInterface []NetworkInterface `tfschema:"network_interface"` @@ -156,24 +156,6 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: validation.StringIsNotEmpty, }, - "logging_storage_account": { - Type: pluginsdk.TypeList, - Optional: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Optional: true, - }, - - "container_name": { - Type: pluginsdk.TypeString, - Optional: true, - }, - }, - }, - }, - "frontend_public": { Type: pluginsdk.TypeList, Optional: true, @@ -261,8 +243,26 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema { Computed: true, ValidateFunc: validation.StringIsNotEmpty, } - } + resource["logging_storage_account"] = &pluginsdk.Schema{ + Deprecated: "The `logging_storage_account` block has been deprecated and will be removed in v5.0 of the AzureRM Provider. To enable logs, use the `azurerm_monitor_diagnostic_setting` resource instead.", + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Optional: true, + }, + + "container_name": { + Type: pluginsdk.TypeString, + Optional: true, + }, + }, + }, + } + } return resource } @@ -322,12 +322,14 @@ func (m DeploymentResource) Create() sdk.ResourceFunc { prop := &nginxdeployment.NginxDeploymentProperties{} - if len(model.LoggingStorageAccount) > 0 { - prop.Logging = &nginxdeployment.NginxLogging{ - StorageAccount: &nginxdeployment.NginxStorageAccount{ - AccountName: pointer.To(model.LoggingStorageAccount[0].Name), - ContainerName: pointer.To(model.LoggingStorageAccount[0].ContainerName), - }, + if !features.FivePointOhBeta() { + if len(model.LoggingStorageAccount) > 0 { + prop.Logging = &nginxdeployment.NginxLogging{ + StorageAccount: &nginxdeployment.NginxStorageAccount{ + AccountName: pointer.FromString(model.LoggingStorageAccount[0].Name), + ContainerName: pointer.FromString(model.LoggingStorageAccount[0].ContainerName), + }, + } } } @@ -462,12 +464,14 @@ func (m DeploymentResource) Read() sdk.ResourceFunc { output.NginxVersion = pointer.ToString(props.NginxVersion) output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport) - if props.Logging != nil && props.Logging.StorageAccount != nil { - output.LoggingStorageAccount = []LoggingStorageAccount{ - { - Name: pointer.ToString(props.Logging.StorageAccount.AccountName), - ContainerName: pointer.ToString(props.Logging.StorageAccount.ContainerName), - }, + if !features.FivePointOhBeta() { + if props.Logging != nil && props.Logging.StorageAccount != nil { + output.LoggingStorageAccount = []LoggingStorageAccount{ + { + Name: pointer.ToString(props.Logging.StorageAccount.AccountName), + ContainerName: pointer.ToString(props.Logging.StorageAccount.ContainerName), + }, + } } } @@ -571,12 +575,14 @@ func (m DeploymentResource) Update() sdk.ResourceFunc { } req.Properties = &nginxdeployment.NginxDeploymentUpdateProperties{} - if meta.ResourceData.HasChange("logging_storage_account") && len(model.LoggingStorageAccount) > 0 { - req.Properties.Logging = &nginxdeployment.NginxLogging{ - StorageAccount: &nginxdeployment.NginxStorageAccount{ - AccountName: pointer.To(model.LoggingStorageAccount[0].Name), - ContainerName: pointer.To(model.LoggingStorageAccount[0].ContainerName), - }, + if !features.FivePointOhBeta() { + if meta.ResourceData.HasChange("logging_storage_account") && len(model.LoggingStorageAccount) > 0 { + req.Properties.Logging = &nginxdeployment.NginxLogging{ + StorageAccount: &nginxdeployment.NginxStorageAccount{ + AccountName: pointer.FromString(model.LoggingStorageAccount[0].Name), + ContainerName: pointer.FromString(model.LoggingStorageAccount[0].ContainerName), + }, + } } } diff --git a/website/docs/5.0-upgrade-guide.html.markdown b/website/docs/5.0-upgrade-guide.html.markdown index ad99f58f0470..04e287f8bda0 100644 --- a/website/docs/5.0-upgrade-guide.html.markdown +++ b/website/docs/5.0-upgrade-guide.html.markdown @@ -126,6 +126,7 @@ Please follow the format in the example below for listing breaking changes in re ### `azurerm_nginx_deployment` +* The deprecated `logging_storage_account` block has been removed in favour of the `azurerm_monitor_diagnostic_setting` resource. * The deprecated `managed_resource_group` property has been removed. ### `azurerm_sentinel_alert_rule_fusion` @@ -168,6 +169,7 @@ Please follow the format in the example below for listing breaking changes in da ### `azurerm_nginx_deployment` +* The deprecated `logging_storage_account` block has been removed. * The deprecated `managed_resource_group` property has been removed. ### `azurerm_storage_container` diff --git a/website/docs/d/nginx_deployment.html.markdown b/website/docs/d/nginx_deployment.html.markdown index cb0e85326b06..2a93449c1021 100644 --- a/website/docs/d/nginx_deployment.html.markdown +++ b/website/docs/d/nginx_deployment.html.markdown @@ -55,8 +55,6 @@ In addition to the Arguments listed above - the following Attributes are exporte * `location` - The Azure Region where the NGINX Deployment exists. -* `logging_storage_account` - A `logging_storage_account` block as defined below. - * `network_interface` - A `network_interface` block as defined below. * `nginx_version` - NGINX version of the Deployment. @@ -93,14 +91,6 @@ A `identity` block exports the following: --- -A `logging_storage_account` block exports the following: - -* `container_name` - The container name of Storage Account for logging. - -* `name` - The account name of the StorageAccount for logging. - ---- - A `network_interface` block exports the following: * `subnet_id` - The subnet resource ID of the NGINX Deployment. diff --git a/website/docs/r/nginx_deployment.html.markdown b/website/docs/r/nginx_deployment.html.markdown index ae83afcbe3d2..e8f95429b887 100644 --- a/website/docs/r/nginx_deployment.html.markdown +++ b/website/docs/r/nginx_deployment.html.markdown @@ -107,8 +107,6 @@ The following arguments are supported: * `frontend_public` - (Optional) A `frontend_public` block as defined below. Changing this forces a new NGINX Deployment to be created. -* `logging_storage_account` - (Optional) One or more `logging_storage_account` blocks as defined below. - * `network_interface` - (Optional) One or more `network_interface` blocks as defined below. Changing this forces a new NGINX Deployment to be created. * `automatic_upgrade_channel` - (Optional) Specify the automatic upgrade channel for the NGINX deployment. Defaults to `stable`. The possible values are `stable` and `preview`. @@ -143,14 +141,6 @@ A `frontend_public` block supports the following: --- -A `logging_storage_account` block supports the following: - -* `container_name` - (Optional) Specify the container name in the Storage Account for logging. - -* `name` - (Optional) The name of the StorageAccount for NGINX Logging. - ---- - A `network_interface` block supports the following: * `subnet_id` - (Required) Specify The Subnet Resource ID for this NGINX Deployment. Changing this forces a new NGINX Deployment to be created.