terraform-provider-incapsula icon indicating copy to clipboard operation
terraform-provider-incapsula copied to clipboard

incapsula_site.domain_verification is not set when using CNAME verification

Open uduncanu opened this issue 9 months ago • 1 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Imperva provider version

Terraform 1.8.2 Imperva 3.25.0

Affected resource(s)

incapsula_site.domain_verification

Terraform configuration files

resource "incapsula_site" "site" {
  domain = "www.example.com"
  domain_validation = "cname"
  ignore_ssl = true
}
output "ssl_dns" {
  value = "${incapsula_site.site.dns_cname_record_name} CNAME ${incapsula_site.site.domain_verification}." : ""
}

Debug output

I've not managed to get debug outputs.

Panic output

No response

Expected output

The CNAME record value that needs to be created to validate SSL.

Actual output

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Invalid template interpolation value
│
│   on ../../../modules/imperva/base/resources.tf line 29, in output "ssl_dns":
│   29:   value = var.setup ? "${incapsula_site.site.dns_cname_record_name} CNAME ${incapsula_site.site.domain_verification}." : ""
│     ├────────────────
│     │ incapsula_site.site.domain_verification is null
│
│ The expression result is null. Cannot include a null value in a string template.

Steps to reproduce

  1. Create site via terraform using cname DNS verification
  2. Output the domain

Additional factoids

Looking at https://github.com/imperva/terraform-provider-incapsula/blob/1265e78df5858c5ff96e0179321d9cb730435f6a/incapsula/resource_site.go#L471 , I can see how the domain_verification value gets set when using DNS (TXT) verification, but can't see anything for CNAME verification.

On a related note, it would be really useful if the value was always there but empty no matter what type of verification you're using, rather than not existing at all unless you're using DNS verification.

References

No response

uduncanu avatar May 24 '24 15:05 uduncanu