Skip to content

Commit

Permalink
Terraform: Fix issue with FQDN SSL Managed certs causing a diff
Browse files Browse the repository at this point in the history
  • Loading branch information
drebes committed Apr 27, 2019
1 parent 78694ff commit 5d49073
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
{{description}}
These are in the same namespace as the managed SSL certificates.
managed.domains: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'absoluteDomainSuppress'
SslCertificate: !ruby/object:Overrides::Terraform::ResourceOverride
docs: !ruby/object:Provider::Terraform::Docs
optional_properties: |
Expand Down
7 changes: 4 additions & 3 deletions provider/terraform_object_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def generate_resource(data)
def compile_common_files(output_folder, version_name = 'ga')
Google::LOGGER.info 'Compiling common files.'
compile_file_list(output_folder, [
['google/config.go', 'third_party/terraform/utils/config.go.erb']
['google/config.go',
'third_party/terraform/utils/config.go.erb'],
['google/utils.go',
'third_party/terraform/utils/utils.go.erb']
], version_name)
end

Expand Down Expand Up @@ -88,8 +91,6 @@ def copy_common_files(output_folder, _version_name)
'third_party/terraform/utils/field_helpers.go'],
['google/self_link_helpers.go',
'third_party/terraform/utils/self_link_helpers.go'],
['google/utils.go',
'third_party/terraform/utils/utils.go'],
['google/transport.go',
'third_party/terraform/utils/transport.go'],
['google/bigtable_client_factory.go',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resource "google_compute_managed_ssl_certificate" "default" {
name = "<%= ctx[:vars]['cert_name'] %>"

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% autogen_exception -%>
// Contains functions that don't really belong anywhere else.

package google
Expand Down Expand Up @@ -466,3 +467,13 @@ func paginatedListRequest(baseUrl string, config *Config, flattener func(map[str

return ls, nil
}

<% unless version == 'ga' -%>
// 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
}
<% end -%>

0 comments on commit 5d49073

Please sign in to comment.