Skip to content

Add DNS_SCOPE_UNSPECIFIED back and fix diffs #9547

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

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .changelog/13348.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: re-added `DNS_SCOPE_UNSPECIFIED` value to the `dns_config.cluster_dns_scope` field in `google_container_cluster` resource and suppressed diffs between `DNS_SCOPE_UNSPECIFIED` in config and empty/null in state
```
16 changes: 12 additions & 4 deletions google-beta/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ func isBeenEnabled(_ context.Context, old, new, _ interface{}) bool {
return false
}

func suppressDiffForClusterDnsScope(k, o, n string, d *schema.ResourceData) bool {
if o == "" && n == "DNS_SCOPE_UNSPECIFIED" {
return true
}
return false
}

func ResourceContainerCluster() *schema.Resource {
return &schema.Resource{
UseJSONNumber: true,
Expand Down Expand Up @@ -2179,10 +2186,11 @@ func ResourceContainerCluster() *schema.Resource {
Optional: true,
},
"cluster_dns_scope": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"CLUSTER_SCOPE", "VPC_SCOPE"}, false),
Description: `The scope of access to cluster DNS records.`,
Optional: true,
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"DNS_SCOPE_UNSPECIFIED", "CLUSTER_SCOPE", "VPC_SCOPE"}, false),
Description: `The scope of access to cluster DNS records.`,
Optional: true,
DiffSuppressFunc: suppressDiffForClusterDnsScope,
},
"cluster_dns_domain": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6042,7 +6042,21 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withAdvancedDNSConfig(clusterName, false, true, true, false, ""),
Config: testAccContainerCluster_withDNSConfigWithoutScope(clusterName),
},
{
ResourceName: "google_container_cluster.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_container_cluster.primary", plancheck.ResourceActionNoop),
},
},
},
{
ResourceName: "google_container_cluster.primary",
Expand All @@ -6054,6 +6068,37 @@ func TestAccContainerCluster_cloudDns_nil_scope(t *testing.T) {
})
}

func testAccContainerCluster_withDNSConfigWithoutScope(clusterName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
initial_node_count = 2
dns_config {
cluster_dns = "CLOUD_DNS"
}

deletion_protection = false
}
`, clusterName)
}

func testAccContainerCluster_withDNSConfigWithUnspecifiedScope(clusterName string) string {
return fmt.Sprintf(`
resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
initial_node_count = 2
dns_config {
cluster_dns = "CLOUD_DNS"
cluster_dns_scope = "DNS_SCOPE_UNSPECIFIED"
}

deletion_protection = false
}
`, clusterName)
}

func TestAccContainerCluster_autopilot_withAdditiveVPCMutation(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ linux_node_config {

* `cluster_dns` - (Optional) Which in-cluster DNS provider should be used. `PROVIDER_UNSPECIFIED` (default) or `PLATFORM_DEFAULT` or `CLOUD_DNS`.

* `cluster_dns_scope` - (Optional) The scope of access to cluster DNS records. `DNS_SCOPE_UNSPECIFIED` (default) or `CLUSTER_SCOPE` or `VPC_SCOPE`.
* `cluster_dns_scope` - (Optional) The scope of access to cluster DNS records. `DNS_SCOPE_UNSPECIFIED` or `CLUSTER_SCOPE` or `VPC_SCOPE`. If the `cluster_dns` field is set to `CLOUD_DNS`, `DNS_SCOPE_UNSPECIFIED` and empty/null behave like `CLUSTER_SCOPE`.

* `cluster_dns_domain` - (Optional) The suffix used for all cluster service records.

Expand Down
Loading