mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
Change all fields for monitored resource to force recreation (#3160)
<!-- This change is generated by MagicModules. --> /cc @chrisst
This commit is contained in:
parent
9fa1d462d2
commit
549203976f
|
@ -150,17 +150,20 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
|
|||
"monitored_resource": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"labels": {
|
||||
Type: schema.TypeMap,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -175,6 +178,7 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
|
|||
"resource_group": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -187,6 +191,7 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
|
|||
"resource_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"RESOURCE_TYPE_UNSPECIFIED", "INSTANCE", "AWS_ELB_LOAD_BALANCER", ""}, false),
|
||||
},
|
||||
},
|
||||
|
@ -450,18 +455,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
|
|||
} else if v, ok := d.GetOkExists("tcp_check"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, tcpCheckProp)) {
|
||||
obj["tcpCheck"] = tcpCheckProp
|
||||
}
|
||||
resourceGroupProp, err := expandMonitoringUptimeCheckConfigResourceGroup(d.Get("resource_group"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("resource_group"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, resourceGroupProp)) {
|
||||
obj["resourceGroup"] = resourceGroupProp
|
||||
}
|
||||
monitoredResourceProp, err := expandMonitoringUptimeCheckConfigMonitoredResource(d.Get("monitored_resource"), d, config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if v, ok := d.GetOkExists("monitored_resource"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, monitoredResourceProp)) {
|
||||
obj["monitoredResource"] = monitoredResourceProp
|
||||
}
|
||||
|
||||
url, err := replaceVars(d, config, "https://monitoring.googleapis.com/v3/{{name}}")
|
||||
if err != nil {
|
||||
|
@ -502,14 +495,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte
|
|||
if d.HasChange("tcp_check") {
|
||||
updateMask = append(updateMask, "tcpCheck")
|
||||
}
|
||||
|
||||
if d.HasChange("resource_group") {
|
||||
updateMask = append(updateMask, "resourceGroup")
|
||||
}
|
||||
|
||||
if d.HasChange("monitored_resource") {
|
||||
updateMask = append(updateMask, "monitoredResource")
|
||||
}
|
||||
// updateMask is a URL parameter but not present in the schema, so replaceVars
|
||||
// won't set it
|
||||
url, err = addQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
func TestAccMonitoringUptimeCheckConfig_update(t *testing.T) {
|
||||
t.Parallel()
|
||||
project := getTestProjectFromEnv()
|
||||
host := "192.168.1.1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -18,7 +19,7 @@ func TestAccMonitoringUptimeCheckConfig_update(t *testing.T) {
|
|||
CheckDestroy: testAccCheckMonitoringUptimeCheckConfigDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("mypath", "password1", project),
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("mypath", "password1", project, host),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_monitoring_uptime_check_config.http",
|
||||
|
@ -27,7 +28,7 @@ func TestAccMonitoringUptimeCheckConfig_update(t *testing.T) {
|
|||
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password"},
|
||||
},
|
||||
{
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("", "password2", project),
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("", "password2", project, host),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_monitoring_uptime_check_config.http",
|
||||
|
@ -39,7 +40,49 @@ func TestAccMonitoringUptimeCheckConfig_update(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func testAccMonitoringUptimeCheckConfig_update(path, project, pwd string) string {
|
||||
// The second update should force a recreation of the uptime check because 'monitored_resource' isn't
|
||||
// updatable in place
|
||||
func TestAccMonitoringUptimeCheckConfig_changeNonUpdatableFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
project := getTestProjectFromEnv()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckMonitoringUptimeCheckConfigDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("mypath", "password1", project, "192.168.1.1"),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_monitoring_uptime_check_config.http",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password"},
|
||||
},
|
||||
{
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("mypath", "password1", project, "192.168.1.2"),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_monitoring_uptime_check_config.http",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password"},
|
||||
},
|
||||
{
|
||||
Config: testAccMonitoringUptimeCheckConfig_update("mypath", "password2", project, "192.168.1.2"),
|
||||
},
|
||||
{
|
||||
ResourceName: "google_monitoring_uptime_check_config.http",
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"http_check.0.auth_info.0.password"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccMonitoringUptimeCheckConfig_update(path, project, pwd, host string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_monitoring_uptime_check_config" "http" {
|
||||
display_name = "http-uptime-check-%s"
|
||||
|
@ -58,7 +101,7 @@ resource "google_monitoring_uptime_check_config" "http" {
|
|||
type = "uptime_url"
|
||||
labels = {
|
||||
project_id = "%s"
|
||||
host = "192.168.1.1"
|
||||
host = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +109,6 @@ resource "google_monitoring_uptime_check_config" "http" {
|
|||
content = "example"
|
||||
}
|
||||
}
|
||||
`, acctest.RandString(4), path, project, pwd,
|
||||
`, acctest.RandString(4), path, project, pwd, host,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user