Only set remove_default_node_pool for import if false - fixes TF tests (#3169)

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2019-03-01 15:45:21 -08:00 committed by emily
parent 255b75467e
commit 84902cc34e
2 changed files with 3 additions and 6 deletions

View File

@ -1813,11 +1813,8 @@ func resourceContainerClusterStateImporter(d *schema.ResourceData, meta interfac
_, err := config.clientContainerBeta.Projects.Locations.Clusters.NodePools.Get(nodePool).Do()
if err != nil && isGoogleApiErrorWithCode(err, 404) {
d.Set("remove_default_node_pool", true)
} else {
d.Set("remove_default_node_pool", false)
if err != nil {
log.Printf("[WARN] Unable to import value for remove_default_node_pool, got error while trying to get default node pool: %s", err)
}
} else if err != nil {
log.Printf("[WARN] Unable to import value for remove_default_node_pool, got error while trying to get default node pool: %s", err)
}
return []*schema.ResourceData{d}, nil

View File

@ -589,4 +589,4 @@ $ terraform import google_container_cluster.mycluster us-east1-a/my-cluster
For example:
- `min_master_version` will not be set on import and will show a no-op diff if set in config.
- `remove_default_node_pool`: If the default node pool exists at import, this value will be set to false in state (or true if non-existant). If set to true in config but the node pool exists, a follow-up diff/apply will delete the default node pool.
- `remove_default_node_pool`: If the default node pool does not exist at import, this value will be set to true in state, but it will not be set otherwise. Thus, you may see a no-op diff if set to false in config, or a diff if set to true in config when the default node pool still exists.