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

Terraform: Skip diffs when managed certs are specified with absolute FQDNs #591

Merged
merged 1 commit into from
Apr 29, 2019
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
9 changes: 5 additions & 4 deletions google-beta/resource_compute_managed_ssl_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ func resourceComputeManagedSslCertificate() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"domains": {
Type: schema.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
Type: schema.TypeList,
Required: true,
ForceNew: true,
DiffSuppressFunc: absoluteDomainSuppress,
MaxItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "google_compute_managed_ssl_certificate" "default" {
name = "test-cert-%{random_suffix}"

managed {
domains = ["sslcert.tf-test.club"]
domains = ["sslcert.tf-test.club."]
}
}

Expand Down
8 changes: 8 additions & 0 deletions google-beta/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,11 @@ func paginatedListRequest(baseUrl string, config *Config, flattener func(map[str

return ls, nil
}

// For managed SSL certs, if new is an absolute FQDN (trailing '.') but old isn't, treat them as equals.
func absoluteDomainSuppress(k, old, new string, _ *schema.ResourceData) bool {
if k == "managed.0.domains.0" {
return old == strings.TrimRight(new, ".")
}
return old == new
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ resource "google_compute_managed_ssl_certificate" "default" {
name = "test-cert"

managed {
domains = ["sslcert.tf-test.club"]
domains = ["sslcert.tf-test.club."]
}
}

Expand Down