Skip to content

Commit

Permalink
Only validate cidr block when the cidr block value is known (#2394)
Browse files Browse the repository at this point in the history
Merged PR #2394.
  • Loading branch information
rileykarson authored and modular-magician committed Oct 1, 2019
1 parent 2be0b17 commit 0727121
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,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 0727121

Please sign in to comment.