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

Redundant diff plan for fastly_service_vcl services that include logging_syslog.tls_ca_cert #588

Open
laynax opened this issue Sep 13, 2022 · 2 comments
Labels
enhancement New feature or request feature request

Comments

@laynax
Copy link

laynax commented Sep 13, 2022

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.
5d2ad298-c703-4161-8959-a4b637f5bd97 (1)

Steps to Reproduce

  1. terraform apply
  2. make change to any field (image above is a result of changing test_service.comment)
  3. terraform plan
@Integralist
Copy link
Collaborator

Thanks for opening this issue. I believe the following comment might be what you need...

#231 (comment)

@laynax
Copy link
Author

laynax commented Sep 13, 2022

@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.

@Integralist Integralist added enhancement New feature or request feature request labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

2 participants