Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only validate cidr block when the cidr block value is known #4577

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,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