Skip to content

Commit f58b94c

Browse files
Make google_monitoring_metric_descriptor.labels ForceNew (#8914) (#15988)
Signed-off-by: Modular Magician <[email protected]>
1 parent 4151f8e commit f58b94c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.changelog/8914.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:breaking-change
2+
monitoring: made `labels` immutable in `google_monitoring_metric_descriptor`
3+
```
4+
```release-note:bug
5+
monitoring: fixed an issue where `metadata` was not able to be updated in `google_monitoring_metric_descriptor`
6+
```

google/services/monitoring/resource_monitoring_metric_descriptor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource {
8888
"labels": {
8989
Type: schema.TypeSet,
9090
Optional: true,
91+
ForceNew: true,
9192
Description: `The set of labels that can be used to describe a specific instance of this metric type. In order to delete a label, the entire resource must be deleted, then created with the desired labels.`,
9293
Elem: monitoringMetricDescriptorLabelsSchema(),
9394
// Default schema.HashSchema is used.
@@ -102,7 +103,6 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource {
102103
"metadata": {
103104
Type: schema.TypeList,
104105
Optional: true,
105-
ForceNew: true,
106106
Description: `Metadata which can be used to guide usage of the metric.`,
107107
MaxItems: 1,
108108
Elem: &schema.Resource{

google/services/monitoring/resource_monitoring_metric_descriptor_test.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
)
1212

1313
func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
14-
// TODO: Fix requires a breaking change https://github.com/hashicorp/terraform-provider-google/issues/12139
15-
t.Skip()
1614

1715
t.Parallel()
1816
acctest.VcrTest(t, resource.TestCase{
@@ -21,8 +19,7 @@ func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
2119
CheckDestroy: testAccCheckMonitoringMetricDescriptorDestroyProducer(t),
2220
Steps: []resource.TestStep{
2321
{
24-
Config: testAccMonitoringMetricDescriptor_update("key1", "STRING",
25-
"description1", "30s", "30s"),
22+
Config: testAccMonitoringMetricDescriptor_update("30s", "30s"),
2623
},
2724
{
2825
ResourceName: "google_monitoring_metric_descriptor.basic",
@@ -31,8 +28,7 @@ func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
3128
ImportStateVerifyIgnore: []string{"metadata", "launch_stage"},
3229
},
3330
{
34-
Config: testAccMonitoringMetricDescriptor_update("key2", "INT64",
35-
"description2", "60s", "60s"),
31+
Config: testAccMonitoringMetricDescriptor_update("60s", "60s"),
3632
},
3733
{
3834
ResourceName: "google_monitoring_metric_descriptor.basic",
@@ -44,8 +40,7 @@ func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
4440
})
4541
}
4642

47-
func testAccMonitoringMetricDescriptor_update(key, valueType, description,
48-
samplePeriod, ingestDelay string) string {
43+
func testAccMonitoringMetricDescriptor_update(samplePeriod, ingestDelay string) string {
4944
return fmt.Sprintf(`
5045
resource "google_monitoring_metric_descriptor" "basic" {
5146
description = "Daily sales records from all branch stores."
@@ -55,16 +50,16 @@ resource "google_monitoring_metric_descriptor" "basic" {
5550
value_type = "DOUBLE"
5651
unit = "{USD}"
5752
labels {
58-
key = "%s"
59-
value_type = "%s"
60-
description = "%s"
53+
key = "key"
54+
value_type = "STRING"
55+
description = "description"
6156
}
6257
launch_stage = "BETA"
6358
metadata {
6459
sample_period = "%s"
6560
ingest_delay = "%s"
6661
}
6762
}
68-
`, key, valueType, description, samplePeriod, ingestDelay,
63+
`, samplePeriod, ingestDelay,
6964
)
7065
}

0 commit comments

Comments
 (0)