Skip to content

Commit

Permalink
azurerm_nginx_deployment: Deprecate logging_storage_account block (
Browse files Browse the repository at this point in the history
…hashicorp#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 <[email protected]>
  • Loading branch information
puneetsarna and stephybun authored Dec 13, 2024
1 parent 19b66b3 commit 65fd4ea
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 83 deletions.
53 changes: 28 additions & 25 deletions internal/services/nginx/nginx_deployment_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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),
},
}
}
}

Expand Down
82 changes: 44 additions & 38 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

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

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

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

Expand Down
2 changes: 2 additions & 0 deletions website/docs/5.0-upgrade-guide.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
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.

* `network_interface` - A `network_interface` block as defined below.

* `nginx_version` - NGINX version of the Deployment.
Expand Down Expand Up @@ -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.
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 @@ -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`.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 65fd4ea

Please sign in to comment.