From c8b71af83a5f81fdd5037a9031d678ff0038954d Mon Sep 17 00:00:00 2001
From: sarna
Date: Mon, 28 Oct 2024 06:16:48 +0530
Subject: [PATCH] `azurerm_nginx_deployment`: Deprecate
`managed_resource_group` field
This field was deprecated by the service provider
a long time back. This commit just deprectes the
same field in terrform in the next provider
version.
---
.../nginx/nginx_deployment_data_source.go | 18 +++++++++------
.../nginx/nginx_deployment_resource.go | 22 ++++++++++---------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/internal/services/nginx/nginx_deployment_data_source.go b/internal/services/nginx/nginx_deployment_data_source.go
index cdfa5968041f3..7533a319eae8f 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-09-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"
@@ -56,7 +57,7 @@ func (m DeploymentDataSource) Arguments() map[string]*pluginsdk.Schema {
}
func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
- return map[string]*pluginsdk.Schema{
+ dataSource := map[string]*pluginsdk.Schema{
"nginx_version": {
Type: pluginsdk.TypeString,
Computed: true,
@@ -69,11 +70,6 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},
- "managed_resource_group": {
- Type: pluginsdk.TypeString,
- Computed: true,
- },
-
"location": commonschema.LocationComputed(),
"capacity": {
@@ -196,6 +192,15 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
"tags": commonschema.TagsDataSource(),
}
+
+ if !features.FivePointOhBeta() {
+ dataSource["managed_resource_group"] = &pluginsdk.Schema{
+ Deprecated: "The `managed_resource_group` field has been deprecated and will be removed in v5.0 of the AzureRM Provider.",
+ Type: pluginsdk.TypeString,
+ Computed: true,
+ }
+ }
+ return dataSource
}
func (m DeploymentDataSource) ModelObject() interface{} {
@@ -245,7 +250,6 @@ func (m DeploymentDataSource) Read() sdk.ResourceFunc {
output.Identity = *flattenedIdentity
if props := model.Properties; props != nil {
output.IpAddress = pointer.ToString(props.IPAddress)
- output.ManagedResourceGroup = pointer.ToString(props.ManagedResourceGroup)
output.NginxVersion = pointer.ToString(props.NginxVersion)
output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport)
diff --git a/internal/services/nginx/nginx_deployment_resource.go b/internal/services/nginx/nginx_deployment_resource.go
index 8e1b9ab8c3dbb..fa06c03ec538c 100644
--- a/internal/services/nginx/nginx_deployment_resource.go
+++ b/internal/services/nginx/nginx_deployment_resource.go
@@ -14,6 +14,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-09-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"
@@ -107,14 +108,6 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
"identity": commonschema.SystemAssignedUserAssignedIdentityOptional(),
- "managed_resource_group": {
- Type: pluginsdk.TypeString,
- Optional: true,
- Computed: true,
- ForceNew: true,
- ValidateFunc: validation.StringIsNotEmpty,
- },
-
"location": commonschema.Location(),
"capacity": {
@@ -260,6 +253,17 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
"tags": commonschema.Tags(),
}
+ if !features.FivePointOhBeta() {
+ resource["managed_resource_group"] = &pluginsdk.Schema{
+ Deprecated: "The `managed_resource_group` field has been deprecated and will be removed in v5.0 of the AzureRM Provider.",
+ Type: pluginsdk.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ ValidateFunc: validation.StringIsNotEmpty,
+ }
+ }
+
return resource
}
@@ -318,7 +322,6 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
}
prop := &nginxdeployment.NginxDeploymentProperties{}
- prop.ManagedResourceGroup = pointer.To(model.ManagedResourceGroup)
if len(model.LoggingStorageAccount) > 0 {
prop.Logging = &nginxdeployment.NginxLogging{
@@ -457,7 +460,6 @@ func (m DeploymentResource) Read() sdk.ResourceFunc {
if props := model.Properties; props != nil {
output.IpAddress = pointer.ToString(props.IPAddress)
- output.ManagedResourceGroup = pointer.ToString(props.ManagedResourceGroup)
output.NginxVersion = pointer.ToString(props.NginxVersion)
output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport)