Skip to content

Commit

Permalink
azurerm_nginx_deployment: Deprecate logging_storage_account block
Browse files Browse the repository at this point in the history
NGINXaaS for Azure is deprecating the use of
`logging_storage_account` block in favor of using
Azure native logging configured via Azure
Diagnostic Settings.
  • Loading branch information
puneetsarna committed Nov 5, 2024
1 parent a4aa6c6 commit 514e05c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 44 deletions.
15 changes: 9 additions & 6 deletions internal/services/nginx/nginx_deployment_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
},
}
}
}

Expand Down
63 changes: 45 additions & 18 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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),
},
}
}
}

Expand Down Expand Up @@ -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),
},
}
}
}

Expand Down Expand Up @@ -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),
},
}
}
}

Expand Down
10 changes: 0 additions & 10 deletions website/docs/d/nginx_deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions website/docs/r/nginx_deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 514e05c

Please sign in to comment.