mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-05 17:52:38 +00:00
Allow updating google_container_cluster.monitoring_service
(#598)
This commit is contained in:
parent
081e675d3d
commit
62eb5ceedf
|
@ -173,7 +173,6 @@ func resourceContainerCluster() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"network": {
|
||||
|
@ -647,6 +646,31 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
d.SetPartial("enable_legacy_abac")
|
||||
}
|
||||
|
||||
if d.HasChange("monitoring_service") {
|
||||
desiredMonitoringService := d.Get("monitoring_service").(string)
|
||||
|
||||
req := &container.UpdateClusterRequest{
|
||||
Update: &container.ClusterUpdate{
|
||||
DesiredMonitoringService: desiredMonitoringService,
|
||||
},
|
||||
}
|
||||
op, err := config.clientContainer.Projects.Zones.Clusters.Update(
|
||||
project, zoneName, clusterName, req).Do()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait until it's updated
|
||||
waitErr := containerOperationWait(config, op, project, zoneName, "updating GKE cluster monitoring service", timeoutInMinutes, 2)
|
||||
if waitErr != nil {
|
||||
return waitErr
|
||||
}
|
||||
log.Printf("[INFO] Monitoring service for GKE cluster %s has been updated to %s", d.Id(),
|
||||
desiredMonitoringService)
|
||||
|
||||
d.SetPartial("monitoring_service")
|
||||
}
|
||||
|
||||
if n, ok := d.GetOk("node_pool.#"); ok {
|
||||
for i := 0; i < n.(int); i++ {
|
||||
if err := nodePoolUpdate(d, meta, clusterName, fmt.Sprintf("node_pool.%d.", i), timeoutInMinutes); err != nil {
|
||||
|
|
|
@ -306,6 +306,36 @@ func TestAccContainerCluster_withLogging(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccContainerCluster_withMonitoring(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
clusterName := fmt.Sprintf("cluster-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckContainerClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccContainerCluster_withMonitoring(clusterName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckContainerCluster(
|
||||
"google_container_cluster.with_monitoring"),
|
||||
resource.TestCheckResourceAttr("google_container_cluster.with_monitoring", "monitoring_service", "monitoring.googleapis.com"),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: testAccContainerCluster_updateMonitoring(clusterName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckContainerCluster(
|
||||
"google_container_cluster.with_monitoring"),
|
||||
resource.TestCheckResourceAttr("google_container_cluster.with_monitoring", "monitoring_service", "none"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccContainerCluster_withNodePoolBasic(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
@ -1065,6 +1095,28 @@ resource "google_container_cluster" "with_logging" {
|
|||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_withMonitoring(clusterName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_monitoring" {
|
||||
name = "cluster-test-%s"
|
||||
zone = "us-central1-a"
|
||||
initial_node_count = 1
|
||||
|
||||
monitoring_service = "monitoring.googleapis.com"
|
||||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_updateMonitoring(clusterName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_monitoring" {
|
||||
name = "cluster-test-%s"
|
||||
zone = "us-central1-a"
|
||||
initial_node_count = 1
|
||||
|
||||
monitoring_service = "none"
|
||||
}`, clusterName)
|
||||
}
|
||||
|
||||
func testAccContainerCluster_withNodePoolBasic(cluster, nodePool string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_container_cluster" "with_node_pool" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user