From 514e05c7e225344e7e0fef2755f2bce923ff0749 Mon Sep 17 00:00:00 2001
From: sarna
Date: Tue, 5 Nov 2024 14:29:48 +0530
Subject: [PATCH] `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.
---
.../nginx/nginx_deployment_data_source.go | 15 +++--
.../nginx/nginx_deployment_resource.go | 63 +++++++++++++------
website/docs/d/nginx_deployment.html.markdown | 10 ---
website/docs/r/nginx_deployment.html.markdown | 10 ---
4 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/internal/services/nginx/nginx_deployment_data_source.go b/internal/services/nginx/nginx_deployment_data_source.go
index 9c5da8d88362..031e02256d37 100644
--- a/internal/services/nginx/nginx_deployment_data_source.go
+++ b/internal/services/nginx/nginx_deployment_data_source.go
@@ -13,6 +13,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-06-01-preview/nginxdeployment"
+ "github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
@@ -249,12 +250,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 bc56ba27ac78..9f9a5fd4ac71 100644
--- a/internal/services/nginx/nginx_deployment_resource.go
+++ b/internal/services/nginx/nginx_deployment_resource.go
@@ -264,6 +264,27 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
"tags": commonschema.Tags(),
}
+ if !features.FivePointOhBeta() {
+ 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 `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,
+ },
+ },
+ },
+ }
+ }
+
if !features.FourPointOhBeta() {
resource["capacity"].Default = defaultCapacity
@@ -396,12 +417,14 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
prop := &nginxdeployment.NginxDeploymentProperties{}
prop.ManagedResourceGroup = pointer.FromString(model.ManagedResourceGroup)
- 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),
- },
+ 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),
+ },
+ }
}
}
@@ -561,12 +584,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),
+ },
+ }
}
}
@@ -712,12 +737,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.FromString(model.LoggingStorageAccount[0].Name),
- ContainerName: pointer.FromString(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/d/nginx_deployment.html.markdown b/website/docs/d/nginx_deployment.html.markdown
index 4b8d11f8bb4e..1f77282f601e 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.
-
* `managed_resource_group` - Auto-generated managed resource group for the NGINX Deployment.
* `network_interface` - A `network_interface` block as defined below.
@@ -95,14 +93,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 4219600cda6e..64eaf2837451 100644
--- a/website/docs/r/nginx_deployment.html.markdown
+++ b/website/docs/r/nginx_deployment.html.markdown
@@ -110,8 +110,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`.
@@ -146,14 +144,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.