Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on terraform validate since version 0.15.2 #29093

Closed
BzSpi opened this issue Jul 5, 2021 · 3 comments · Fixed by #29208
Closed

Regression on terraform validate since version 0.15.2 #29093

BzSpi opened this issue Jul 5, 2021 · 3 comments · Fixed by #29208
Labels
bug config confirmed a Terraform Core team member has reproduced this issue upstream

Comments

@BzSpi
Copy link

BzSpi commented Jul 5, 2021

The terraform validate command behavior seems to have changed since version 0.15.2 and do not fail anymore for unknown attributes in a dynamic block that depends from a variable.

Terraform Version

0.15.2 and above

Terraform Configuration Files

provider "azurerm" {
  features {}
}

variable "test" {
  type = bool
}

resource "azurerm_app_service_plan" "example" {
  name                = "test-plan"
  location            = "West Europe"
  resource_group_name = "test-rg"

  dynamic "sku" {
    for_each = var.test ? ["_"] : []

    content {
      tier = "Standard"
      size = "S1"

      unknown_attribute = "foobar"
    }
  }
}
...

Expected Behavior

Test with Terraform 0.15.1

$ terraform version
Terraform v0.15.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.66.0

Your version of Terraform is out of date! The latest version
is 1.0.1. You can update by downloading from https://www.terraform.io/downloads.html

$ terraform validate
╷
│ Error: Unsupported argument
│ 
│   on test2.tf line 21, in resource "azurerm_app_service_plan" "example":
│   21:       unknown_attribute = "foobar"
│ 
│ An argument named "unknown_attribute" is not expected here.
╵

Actual Behavior

Test with Terraform 0.15.2

$ terraform version
Terraform v0.15.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.66.0

Your version of Terraform is out of date! The latest version
is 1.0.1. You can update by downloading from https://www.terraform.io/downloads.html

$ terraform validate
Success! The configuration is valid.

Same with Terraform 1.0.1

$ terraform version
Terraform v1.0.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.66.0

$ terraform validate
Success! The configuration is valid.

Steps to Reproduce

1. `terraform init`
2. `terraform validate`
@BzSpi BzSpi added bug new new issue not yet triaged labels Jul 5, 2021
@BzSpi BzSpi changed the title Regression on terraform validate sonce version 0.15.2 Regression on terraform validate since version 0.15.2 Jul 5, 2021
@pdecat
Copy link
Contributor

pdecat commented Jul 5, 2021

Probably related to:

core: Update HCL to allow better planning of dynamic blocks (#28424)

https://github.com/hashicorp/terraform/releases/tag/v0.15.2

@jbardin
Copy link
Member

jbardin commented Jul 6, 2021

Hi @BzSpi, thanks for filing the issue. The change @pdecat pointed to is the change which would have caused this. While the use of dynamic will effectively create a block which only expects for_each, iterator and content, I suspect there is still a way to validate the structure earlier.

@jbardin jbardin added config upstream confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Jul 6, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug config confirmed a Terraform Core team member has reproduced this issue upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants