hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.72k stars 9.55k forks source link

erroneous deprecation message during validation from deprecated provider arugment with default value #34605

Closed jcarrothers-sap closed 9 months ago

jcarrothers-sap commented 9 months ago

Terraform Version

Terraform v1.7.2
on windows_amd64
+ provider registry.terraform.io/terraform-provider-openstack/openstack v1.54.1

Terraform Configuration Files

terraform {
  required_version = "1.7.2"
  required_providers {
    openstack = {
      source  = "terraform-provider-openstack/openstack"
      version = "1.54.1"
    }
  }
}

provider "openstack" {
  # At least one provider argument must be set to trigger the bug
  tenant_id = "test"

  # This attribute is the source of the deprecation message.
  # It has a default value of: true
  #use_octavia = true
}

data "openstack_dns_zone_v2" "zone" {
  name     = "example.com"
}

Debug Output

https://gist.github.com/jcarrothers-sap/c8e46dfd8499a89109a8e3cbbceeda16

Expected Behavior

No deprecation error as the deprecated provider argument (use_octavia) is not actually in use.

Actual Behavior

The terraform validate output complains about about a deprecated argument and points to the opening line of the provider block.

>terraform validate
╷
│ Warning: Argument is deprecated
│
│   with provider["registry.terraform.io/terraform-provider-openstack/openstack"],
│   on terraform.tf line 11, in provider "openstack":
│   11: provider "openstack" {
│
│ Users not using loadbalancer resources can ignore this message. Support for neutron-lbaas will be removed on next major release. Octavia will be the only supported method for loadbalancer resources. Users using octavia will have to remove 'use_octavia' option from the provider
│ configuration block. Users using neutron-lbaas will have to migrate/upgrade to octavia.
╵
Success! The configuration is valid, but there were some validation warnings as shown above.

Steps to Reproduce

  1. terraform init
  2. terraform validate

Additional Context

No response

References

No response

jbardin commented 9 months ago

Hi @jcarrothers-sap,

That deprecation warning is coming from the provider itself, and not within the control of Terraform (Terraform actually doesn't know about attribute deprecation messages at all). You would need to file an issue with the provider, but given that they started the message with Users not using loadbalancer resources can ignore this message, it may be there intentionally.

Thanks!

jcarrothers-sap commented 9 months ago

Hi @jbardin,

The message is coming from the provider, but shouldn't it only be surfaced in a terraform validate call if it has actually been defined by the end user? The bug is that the message is surfaced even by a deprecated attribute with a default value. I would have expected terraform validate to filter out such a case.

jbardin commented 9 months ago

Terraform does not know why the provider returned a warning, or how to interpret the text of the message. All we can do is display the diagnostics and try to correlate them with locations in the configuration. If you imagine the inverse, it could have been a warning about not setting a field that will be required in the future. This is probably exacerbated by some of the awkward handling of values in the legacy SDK, and might be easier for them to handle going forward with the new plugin framework.

github-actions[bot] commented 8 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.