jeremmfr / terraform-provider-junos

Terraform provider for Junos devices
https://registry.terraform.io/providers/jeremmfr/junos
MIT License
62 stars 22 forks source link

Clarify false value in version 2 #532

Closed giulianna14 closed 1 year ago

giulianna14 commented 1 year ago

When migrating the version from 1.33 to version 2, we received some errors on a few resources.

│ Error: Invalid boolean value
│
│ with module.junos_security.security,
│ on ../../modules/security.tf line 4, in resource "junos_security" "security":
│ 4: ftp_disable = false
│
│ Must be true or null, false is not supported
╷
│ Error: Invalid boolean value
│
│ with module.junos_interface_physical.interface,
│ on ../../modules/interfaces.tf line 13, in resource "junos_interface_physical" "interface":
│ 13: vlan_tagging = false
│
│ Must be true or null, false is not supported
╵
│ Error: Invalid boolean value
│
│ with module.junos_security_global_policy.policy,
│ on ../../modules/build_policies.tf line 26, in resource "junos_security_global_policy" "policy":
│ 26: resource "junos_security_global_policy" "policy" {
│
│ Must be true or null, false is not supported

I reviewed the documentation and could not find the default for these specific resources.

Since optional boolean attributes don't accept the value false, is false the default when leaving the attribute out?

Thank you!

computeracer commented 1 year ago

@giulianna14 I did some tests and found that changing from false to removing the value in version 1.33 seems to have no effect on the configuration. Terraform would report:

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your
configuration and found no differences, so no changes are needed.

Perhaps that answers the question, but @jeremmfr may have more input.

jeremmfr commented 1 year ago

Hi @giulianna14 👋 ,

As described in the CHANGELOG.md, optional boolean attributes no longer accept value false when a resource has been migrate to new terraform-plugin-framework.
The default value for all optional attributes is null unless otherwise specified.

The old terraform-plugin-sdk considers the value false and null as the same, and with this plugin, it's difficult to know whether the attribute is set to false or not set in the Terraform configuration. So for greater ease of use, my provider accepted the value false in Terraform configuration and set to false in Terraform state even if null (not set) in Terraform configuration.

The new terraform-plugin-framework no longer considers false and null as the same, so I prohibited false to avoid an infinite plan to change null to false.

giulianna14 commented 1 year ago

@jeremmfr Thank you so much for the response!