terraform-provider-fastly
terraform-provider-fastly copied to clipboard
Redundant diff plan for fastly_service_vcl services that include logging_syslog.tls_ca_cert
Hi team
I have a fastly_service_vcl resource including a logging_syslog with tls_ca_cert enabled. Now by making any changes to service, even if it's not related to logging_syslog, I get to see logging_syslog block diff by executing terraform plan.
Digging deeper into the problem, showed it's caused by commiting tls_ca_cert string with a trailing \n (how I passed to it initially) into tfstate. So after each read, terraform compares cert with trailing \n in tfstate with the one without whitespace fetched from fastly-api.
I'm a new comer in GO world and wanted to contribute to your project, but couldn't find a proper way to solve the problem to submit a PR.
Terraform Version
Terraform v1.2.3
on linux_amd64
Affected Resource(s)
fastly_service_vcl
Terraform Configuration Files
resource "fastly_service_vcl" "test_service" {
name = "test_service"
comment = "comment"
domain {
name = "domain.io"
comment = "domain comment"
}
condition {
name = "Response from the Edge"
priority = 10
statement = "fastly.ff.visits_this_service == 0"
type = "RESPONSE"
}
logging_syslog {
name = "rsyslog"
response_condition = "Response from the Edge"
address = "rsyslog-nlb-7538ba8d23954192.elb.us-east-2.amazonaws.com"
port = 6514
use_tls = true
tls_ca_cert = <<-EOF
-----BEGIN CERTIFICATE-----
XXXX
-----END CERTIFICATE-----
EOF
tls_hostname = "tlshostname.host"
format = "%h %l %u %t \"%r\" %\u003es %b"
format_version = 2
message_type = "loggly"
placement = "none"
}
}
Expected Behavior
Changing service comment must be the only modified line in terraform plan
Actual Behavior
Redundant diff on logging_syslog block.

Steps to Reproduce
terraform apply- make change to any field (image above is a result of changing
test_service.comment) terraform plan
Thanks for opening this issue. I believe the following comment might be what you need...
https://github.com/fastly/terraform-provider-fastly/issues/231#issuecomment-632840094
@Integralist Thanks for your respond. Yes, using trimspace() would do the trick too. However, I was trying to fix this on provider side.
More details on my digging: I tried using DiffSuppressFunc and StateFunc but them both didn't work (in case of doing such, we receive a newVal here with 2 elements which the second one is not filled with data and causes erorr). I think the reason for that is SetType is not supported by terraform any more.