Skip to content

Commit

Permalink
Only validate cidr block when the cidr block value is known (hashicor…
Browse files Browse the repository at this point in the history
…p#1211)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and rileykarson committed Oct 1, 2019
1 parent ac398ca commit e840dba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,13 @@ func containerClusterPrivateClusterConfigCustomDiff(d *schema.ResourceDiff, meta
config := pccList[0].(map[string]interface{})
if config["enable_private_nodes"].(bool) == true {
block := config["master_ipv4_cidr_block"]
if block == nil || block == "" {

// We can only apply this validation if we know the final value of the field, and we may
// not know the final value if users feed the value into their config in unintuitive ways.
// https://github.com/terraform-providers/terraform-provider-google/issues/4186
blockValueKnown := d.NewValueKnown("private_cluster_config.0.master_ipv4_cidr_block")

if blockValueKnown && (block == nil || block == "") {
return fmt.Errorf("master_ipv4_cidr_block must be set if enable_private_nodes == true")
}
}
Expand Down

0 comments on commit e840dba

Please sign in to comment.