imperva / terraform-provider-incapsula

This package is a plugin for Terraform, and is designed to be used to auto-provision sites in Incapsula via Incapsula’s API from the terraform cli/yaml configurations.
Mozilla Public License 2.0
44 stars 71 forks source link

incapsula_site.domain_verification is not set when using CNAME verification #426

Open uduncanu opened 3 months ago

uduncanu commented 3 months ago

Confirmation

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

BrachaY commented 3 months ago

Hi @uduncanu

Thank you for opening this issue. We will handle it soon and let you know once we release the fix.