PaloAltoNetworks / terraform-provider-panos

Terraform Panos provider
https://www.terraform.io/docs/providers/panos/
Mozilla Public License 2.0
87 stars 71 forks source link

provider doesn't detect duplicate resource names. #251

Closed mantisgb closed 3 years ago

mantisgb commented 3 years ago

Describe the bug

Terraform applies without error but only one EDL is created on the firewall.

resource "panos_edl" "whitelist-customer-a" {
  name        = "whitelist-customer-a "
  description = "The EDL used to whitelist urls for customer a"
  repeat      = "every five minutes"
  source      = "http://${var.domain}/whitelist-customer-a
  type        = "url"
}

resource "panos_edl" "whitelist-customer-b" {
  name        = "whitelist-customer-a "
  description = "The EDL used to whitelist urls for customer b"
  repeat      = "every five minutes"
  source      = "http://${var.domain}/whitelister-customer-b
  type        = "url"
}

Expected behavior

I would expect Terraform to throw an error that two resources have identical names.

Current behavior

What actually happens is only a single EDL is created with the name "whitelist-customer-a" but with the details of the second resource "whitelist-customer-b".

Possible solution

Use of variable definitions might make a typo like this less likely to happen

Steps to reproduce

As per code block above.

Screenshots

Context

Your Environment

Terraform v0.13.4 + provider registry.terraform.io/paloaltonetworks/panos v1.6.3 Panorama 10.0.2

shinmog commented 3 years ago

In order for this type of check to happen, the Terraform plugin SDK would need to provide a hook for me to declare how an individual resource's ID is created. This would allow Terraform to determine if the user's config contains duplicates or not.

The plugin SDK would need to be updated first to allow for the declaration of resource ID construction, but even if/when that happens it would be Terraform itself that does this check, not the provider. The way Terraform providers are invoked, we are never given the full config to be deployed anyways, so this type of check could never live in the provider.