-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_eventhub
- deprecate namespace_name
and resource_group_name
in favour of namespace_id
#28055
azurerm_eventhub
- deprecate namespace_name
and resource_group_name
in favour of namespace_id
#28055
Changes from 5 commits
9c3fe47
b404816
244ec13
85b2ff5
a3906b6
647122e
3e26c46
e60b082
ad8d0d1
05f0ef1
1efcd20
08a148d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ import ( | |||||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2022-01-01-preview/namespaces" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/internal/features" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/validate" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||||||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" | ||||||
|
@@ -25,7 +26,7 @@ import ( | |||||
var eventHubResourceName = "azurerm_eventhub" | ||||||
|
||||||
func resourceEventHub() *pluginsdk.Resource { | ||||||
return &pluginsdk.Resource{ | ||||||
r := &pluginsdk.Resource{ | ||||||
Create: resourceEventHubCreate, | ||||||
Read: resourceEventHubRead, | ||||||
Update: resourceEventHubUpdate, | ||||||
|
@@ -51,11 +52,11 @@ func resourceEventHub() *pluginsdk.Resource { | |||||
ValidateFunc: validate.ValidateEventHubName(), | ||||||
}, | ||||||
|
||||||
"namespace_name": { | ||||||
"namespace_id": { | ||||||
Type: pluginsdk.TypeString, | ||||||
Required: true, | ||||||
ForceNew: true, | ||||||
ValidateFunc: validate.ValidateEventHubNamespaceName(), | ||||||
ValidateFunc: namespaces.ValidateNamespaceID, | ||||||
}, | ||||||
|
||||||
"resource_group_name": commonschema.ResourceGroupName(), | ||||||
|
@@ -163,6 +164,27 @@ func resourceEventHub() *pluginsdk.Resource { | |||||
}, | ||||||
}, | ||||||
} | ||||||
|
||||||
if !features.FivePointOhBeta() { | ||||||
r.Schema["namespace_id"] = &pluginsdk.Schema{ | ||||||
Type: pluginsdk.TypeString, | ||||||
Optional: true, | ||||||
Computed: true, | ||||||
ExactlyOneOf: []string{"namespace_id", "namespace_name"}, | ||||||
ValidateFunc: namespaces.ValidateNamespaceID, | ||||||
} | ||||||
|
||||||
r.Schema["namespace_name"] = &pluginsdk.Schema{ | ||||||
Type: pluginsdk.TypeString, | ||||||
Optional: true, | ||||||
Computed: true, | ||||||
ValidateFunc: validate.ValidateEventHubNamespaceName(), | ||||||
ExactlyOneOf: []string{"namespace_id", "namespace_name"}, | ||||||
Deprecated: "`namespace_name` has been deprecated in favour of `namespace_id`", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't believe I didn't catch this in the previous review, but could we update this so it's consistent with other deprecation messages in the provider and also clear in that it will be removed in the next major release
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
return r | ||||||
} | ||||||
|
||||||
func resourceEventHubCreate(d *pluginsdk.ResourceData, meta interface{}) error { | ||||||
|
@@ -173,7 +195,19 @@ func resourceEventHubCreate(d *pluginsdk.ResourceData, meta interface{}) error { | |||||
|
||||||
log.Printf("[INFO] preparing arguments for Azure ARM EventHub creation.") | ||||||
|
||||||
id := eventhubs.NewEventhubID(subscriptionId, d.Get("resource_group_name").(string), d.Get("namespace_name").(string), d.Get("name").(string)) | ||||||
namespaceName := "" | ||||||
if v := d.Get("namespace_id").(string); v != "" { | ||||||
namespaceId, err := namespaces.ParseNamespaceID(v) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
namespaceName = namespaceId.NamespaceName | ||||||
} | ||||||
if !features.FivePointOhBeta() && namespaceName == "" { | ||||||
namespaceName = d.Get("namespace_name").(string) | ||||||
} | ||||||
|
||||||
id := eventhubs.NewEventhubID(subscriptionId, d.Get("resource_group_name").(string), namespaceName, d.Get("name").(string)) | ||||||
|
||||||
if d.IsNewResource() { | ||||||
existing, err := client.Get(ctx, id) | ||||||
|
@@ -218,7 +252,10 @@ func resourceEventHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error { | |||||
|
||||||
log.Printf("[INFO] preparing arguments for Azure ARM EventHub update.") | ||||||
|
||||||
id := eventhubs.NewEventhubID(subscriptionId, d.Get("resource_group_name").(string), d.Get("namespace_name").(string), d.Get("name").(string)) | ||||||
id, err := eventhubs.ParseEventhubID(d.Id()) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
if d.HasChange("partition_count") { | ||||||
o, n := d.GetChange("partition_count") | ||||||
|
@@ -253,7 +290,7 @@ func resourceEventHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error { | |||||
parameters.Properties.CaptureDescription = expandEventHubCaptureDescription(d) | ||||||
} | ||||||
|
||||||
if _, err := client.CreateOrUpdate(ctx, id, parameters); err != nil { | ||||||
if _, err := client.CreateOrUpdate(ctx, *id, parameters); err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
|
@@ -282,9 +319,15 @@ func resourceEventHubRead(d *pluginsdk.ResourceData, meta interface{}) error { | |||||
} | ||||||
|
||||||
d.Set("name", id.EventhubName) | ||||||
d.Set("namespace_name", id.NamespaceName) | ||||||
d.Set("resource_group_name", id.ResourceGroupName) | ||||||
|
||||||
if !features.FivePointOhBeta() { | ||||||
d.Set("namespace_name", id.NamespaceName) | ||||||
} | ||||||
|
||||||
namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) | ||||||
d.Set("namespace_id", namespaceId.ID()) | ||||||
|
||||||
if model := resp.Model; model != nil { | ||||||
if props := model.Properties; props != nil { | ||||||
d.Set("partition_count", props.PartitionCount) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/features" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/validate" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
"github.com/hashicorp/terraform-provider-azurerm/utils" | ||
|
@@ -360,7 +361,8 @@ func (EventHubResource) Exists(ctx context.Context, clients *clients.Client, sta | |
} | ||
|
||
func (EventHubResource) basic(data acceptance.TestData, partitionCount int) string { | ||
return fmt.Sprintf(` | ||
if !features.FivePointOhBeta() { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
@@ -384,6 +386,32 @@ resource "azurerm_eventhub" "test" { | |
partition_count = %d | ||
message_retention = 1 | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, partitionCount) | ||
} | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-eventhub-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_eventhub_namespace" "test" { | ||
name = "acctesteventhubnamespace-%d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
sku = "Basic" | ||
} | ||
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctesteventhub-%d" | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming all the test configs have been updated to use
|
||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = %d | ||
message_retention = 1 | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, partitionCount) | ||
} | ||
|
||
|
@@ -394,7 +422,7 @@ func (EventHubResource) requiresImport(data acceptance.TestData) string { | |
|
||
resource "azurerm_eventhub" "import" { | ||
name = azurerm_eventhub.test.name | ||
namespace_name = azurerm_eventhub.test.namespace_name | ||
namespace_id = azurerm_eventhub.test.namespace_id | ||
resource_group_name = azurerm_eventhub.test.resource_group_name | ||
partition_count = azurerm_eventhub.test.partition_count | ||
message_retention = azurerm_eventhub.test.message_retention | ||
|
@@ -422,7 +450,7 @@ resource "azurerm_eventhub_namespace" "test" { | |
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctesteventhub-%d" | ||
namespace_name = azurerm_eventhub_namespace.test.name | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = 10 | ||
message_retention = 1 | ||
|
@@ -450,7 +478,7 @@ resource "azurerm_eventhub_namespace" "test" { | |
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctest-EH-%d" | ||
namespace_name = azurerm_eventhub_namespace.test.name | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = 2 | ||
message_retention = 7 | ||
|
@@ -493,7 +521,7 @@ resource "azurerm_eventhub_namespace" "test" { | |
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctest-EH%d" | ||
namespace_name = azurerm_eventhub_namespace.test.name | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = 2 | ||
message_retention = 7 | ||
|
@@ -536,7 +564,7 @@ resource "azurerm_eventhub_namespace" "test" { | |
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctest-EH-%d" | ||
namespace_name = azurerm_eventhub_namespace.test.name | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = 2 | ||
message_retention = 5 | ||
|
@@ -564,7 +592,7 @@ resource "azurerm_eventhub_namespace" "test" { | |
|
||
resource "azurerm_eventhub" "test" { | ||
name = "acctesteventhub-%d" | ||
namespace_name = azurerm_eventhub_namespace.test.name | ||
namespace_id = azurerm_eventhub_namespace.test.id | ||
resource_group_name = azurerm_resource_group.test.name | ||
partition_count = 5 | ||
message_retention = 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,22 @@ Please follow the format in the example below for listing breaking changes in re | |
* The `example_property_with_changed_default` property now defaults to `NewDefault`. | ||
``` | ||
|
||
### `azurerm_cdn_frontdoor_custom_domain` | ||
|
||
* The `tls.minimum_tls_version` property no longer accepts `TLS10` as a value. | ||
|
||
### `azurerm_eventhub` | ||
|
||
* The deprecated `namespace_name` property has been removed in favour of the `namespace_id` property. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add a line for the |
||
|
||
### `azurerm_mssql_database` | ||
|
||
* The properties `weekly_retention`, `monthly_retention` and `yearly_retention` now default to `PT0S`. | ||
|
||
### `azurerm_mssql_managed_database` | ||
|
||
* The properties `weekly_retention`, `monthly_retention` and `yearly_retention` now default to `PT0S`. | ||
|
||
### `azurerm_sentinel_alert_rule_fusion` | ||
|
||
* The deprecated `name` property has been removed. | ||
|
@@ -76,18 +92,6 @@ Please follow the format in the example below for listing breaking changes in re | |
* The deprecated `storage_account_name` property has been removed in favour of the `storage_account_id` property. | ||
* The deprecated `resource_manager_id` property has been removed in favour of the `id` property. | ||
|
||
### `azurerm_cdn_frontdoor_custom_domain` | ||
|
||
* The `tls.minimum_tls_version` property no longer accepts `TLS10` as a value. | ||
|
||
### `azurerm_mssql_database` | ||
|
||
* The properties `weekly_retention`, `monthly_retention` and `yearly_retention` now default to `PT0S`. | ||
|
||
### `azurerm_mssql_managed_database` | ||
|
||
* The properties `weekly_retention`, `monthly_retention` and `yearly_retention` now default to `PT0S`. | ||
|
||
## Breaking Changes in Data Sources | ||
|
||
Please follow the format in the example below for listing breaking changes in data sources: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@catriona-m as pointed out by @CorrenSoft this probably wants to be deprecated as well