Skip to content

Commit 3ef67a0

Browse files
chrisstmodular-magician
authored andcommitted
Allow duration to be updatable and force new
1 parent 0385bfc commit 3ef67a0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

google/resource_monitoring_uptime_check_config.go

+19
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
455455
obj["monitoredResource"] = monitoredResourceProp
456456
}
457457

458+
obj, err = resourceMonitoringUptimeCheckConfigUpdateEncoder(d, meta, obj)
459+
458460
url, err := replaceVars(d, config, "https://monitoring.googleapis.com/v3/{{name}}")
459461
if err != nil {
460462
return err
@@ -1057,3 +1059,20 @@ func expandMonitoringUptimeCheckConfigMonitoredResourceLabels(v interface{}, d *
10571059
}
10581060
return m, nil
10591061
}
1062+
1063+
func resourceMonitoringUptimeCheckConfigUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
1064+
// Even thought uptimeCheckConfig is modified with a PATCH call it still requires `duration` to
1065+
// be sent on every request. Also if duration has changed the resource needs to be recreated. This
1066+
// is a pattern we're not planning on supporting and this should be removed and `duration` no longer
1067+
// marked as `input: true` if this is fixed upstream.
1068+
config := meta.(*Config)
1069+
1070+
periodProp, err := expandMonitoringUptimeCheckConfigPeriod(d.Get("period"), d, config)
1071+
if err != nil {
1072+
return nil, err
1073+
} else if v, ok := d.GetOkExists("period"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, periodProp)) {
1074+
obj["period"] = periodProp
1075+
}
1076+
1077+
return obj, nil
1078+
}

0 commit comments

Comments
 (0)