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.1k stars 9.47k forks source link

`terraform validate` allows invalid backend configuration #30955

Open manicminer opened 2 years ago

manicminer commented 2 years ago

Terraform Version

Terraform v1.2.0-beta1
on darwin_amd64
+ provider registry.terraform.io/manicminer/azurerm v10.4.0

Terraform Configuration Files

terraform {
  backend "azurerm" {
    resource_group_name  = "mygroup"
    storage_account_name = "myaccount"
    container_name       = "mycontainer"
    key                  = "terraform.tfstate"
    foo = "bar"
    dfhdfgdgfhdgfhfgh = "dfgsdfgsdfg"
  }

  required_providers {
    azurerm = {
      source  = "manicminer/azurerm"
      version = "= 10.4.0"
    }
  }
}

Debug Output

Show Log ```shellsession 13:46:16 [:~/git/manicminer/terraform-azure-oidc-auth]↥ pr-1(+4/-1)* ± TF_LOG=trace terraform validate 2022-04-28T13:46:27.943+0100 [INFO] Terraform version: 1.2.0 beta1 2022-04-28T13:46:27.943+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0 2022-04-28T13:46:27.943+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0 2022-04-28T13:46:27.943+0100 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 2022-04-28T13:46:27.943+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 2022-04-28T13:46:27.943+0100 [DEBUG] using github.com/zclconf/go-cty v1.10.0 2022-04-28T13:46:27.943+0100 [INFO] Go runtime version: go1.18.1 2022-04-28T13:46:27.943+0100 [INFO] CLI args: []string{"/Users/tom/.tfenv/versions/1.2.0-beta1/terraform", "validate"} 2022-04-28T13:46:27.943+0100 [TRACE] Stdout is a terminal of width 318 2022-04-28T13:46:27.943+0100 [TRACE] Stderr is a terminal of width 318 2022-04-28T13:46:27.943+0100 [TRACE] Stdin is a terminal 2022-04-28T13:46:27.943+0100 [DEBUG] Attempting to open CLI config file: /Users/tom/.terraformrc 2022-04-28T13:46:27.943+0100 [INFO] Loading CLI configuration from /Users/tom/.terraformrc 2022-04-28T13:46:27.943+0100 [INFO] Loading CLI configuration from /Users/tom/.terraform.d/credentials.tfrc.json 2022-04-28T13:46:27.944+0100 [DEBUG] Explicit provider installation configuration is set 2022-04-28T13:46:27.944+0100 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [] 2022-04-28T13:46:27.944+0100 [INFO] CLI command args: []string{"validate"} 2022-04-28T13:46:27.945+0100 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers 2022-04-28T13:46:27.946+0100 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/manicminer/azurerm v10.4.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64 2022-04-28T13:46:27.946+0100 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64 as a candidate package for registry.terraform.io/manicminer/azurerm 10.4.0 2022-04-28T13:46:28.521+0100 [DEBUG] checking for provisioner in "." 2022-04-28T13:46:28.521+0100 [DEBUG] checking for provisioner in "/Users/tom/.tfenv/versions/1.2.0-beta1" 2022-04-28T13:46:28.521+0100 [TRACE] terraform.NewContext: starting 2022-04-28T13:46:28.521+0100 [TRACE] terraform.NewContext: complete 2022-04-28T13:46:28.521+0100 [DEBUG] Building and walking validate graph 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.ConfigTransformer 2022-04-28T13:46:28.521+0100 [TRACE] ConfigTransformer: Starting for path: 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.ConfigTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource ------ 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.RootVariableTransformer 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes) 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes) 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.LocalTransformer 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes) 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.OutputTransformer 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes) 2022-04-28T13:46:28.521+0100 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer 2022-04-28T13:46:28.521+0100 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes) 2022-04-28T13:46:28.524+0100 [TRACE] Executing graph transform *terraform.StateTransformer 2022-04-28T13:46:28.524+0100 [TRACE] StateTransformer: creating nodes for deposed instance objects only 2022-04-28T13:46:28.524+0100 [TRACE] Completed graph transform *terraform.StateTransformer (no changes) 2022-04-28T13:46:28.524+0100 [TRACE] Executing graph transform *terraform.AttachStateTransformer 2022-04-28T13:46:28.524+0100 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) 2022-04-28T13:46:28.524+0100 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer 2022-04-28T13:46:28.524+0100 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes) 2022-04-28T13:46:28.524+0100 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer 2022-04-28T13:46:28.524+0100 [TRACE] AttachResourceConfigTransformer: attaching to "azurerm_resource_group.test" (*terraform.NodeValidatableResource) config from main.tf:23,1-41 2022-04-28T13:46:28.524+0100 [TRACE] AttachResourceConfigTransformer: attaching provider meta configs to azurerm_resource_group.test 2022-04-28T13:46:28.524+0100 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes) 2022-04-28T13:46:28.524+0100 [TRACE] Executing graph transform *terraform.graphTransformerMulti 2022-04-28T13:46:28.524+0100 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer 2022-04-28T13:46:28.524+0100 [TRACE] ProviderConfigTransformer: attaching to "provider[\"registry.terraform.io/manicminer/azurerm\"]" provider configuration from main.tf:19,1-19 2022-04-28T13:46:28.524+0100 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider ------ 2022-04-28T13:46:28.524+0100 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer 2022-04-28T13:46:28.525+0100 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes) 2022-04-28T13:46:28.525+0100 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer 2022-04-28T13:46:28.525+0100 [TRACE] ProviderTransformer: exact match for provider["registry.terraform.io/manicminer/azurerm"] serving azurerm_resource_group.test 2022-04-28T13:46:28.525+0100 [DEBUG] ProviderTransformer: "azurerm_resource_group.test" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/manicminer/azurerm"] 2022-04-28T13:46:28.525+0100 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider ------ 2022-04-28T13:46:28.525+0100 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer 2022-04-28T13:46:28.525+0100 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes) 2022-04-28T13:46:28.525+0100 [TRACE] Completed graph transform *terraform.graphTransformerMulti with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider ------ 2022-04-28T13:46:28.525+0100 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer 2022-04-28T13:46:28.525+0100 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes) 2022-04-28T13:46:28.525+0100 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer 2022-04-28T13:46:28.525+0100 [TRACE] terraform.contextPlugins: Initializing provider "registry.terraform.io/manicminer/azurerm" to read its schema 2022-04-28T13:46:28.525+0100 [DEBUG] created provider logger: level=trace 2022-04-28T13:46:28.526+0100 [INFO] provider: configuring client automatic mTLS 2022-04-28T13:46:28.540+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 args=[.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0] 2022-04-28T13:46:28.555+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 pid=61110 2022-04-28T13:46:28.555+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 2022-04-28T13:46:28.607+0100 [INFO] provider.terraform-provider-azurerm_v10.4.0: configuring server automatic mTLS: timestamp=2022-04-28T13:46:28.607+0100 2022-04-28T13:46:28.644+0100 [DEBUG] provider.terraform-provider-azurerm_v10.4.0: plugin address: address=/var/folders/56/y8d3vjgj1qg6mqv6c_m0cy_w0000gp/T/plugin878249733 network=unix timestamp=2022-04-28T13:46:28.644+0100 2022-04-28T13:46:28.644+0100 [DEBUG] provider: using plugin: version=5 2022-04-28T13:46:28.675+0100 [TRACE] GRPCProvider: GetProviderSchema 2022-04-28T13:46:28.675+0100 [TRACE] provider.stdio: waiting for stdio data 2022-04-28T13:46:28.676+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Received request: @module=sdk.proto tf_provider_addr=provider tf_req_id=23631c72-e18d-21f6-7602-0ee3848a4464 @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:329 tf_proto_version=5 tf_rpc=GetSchema timestamp=2022-04-28T13:46:28.675+0100 2022-04-28T13:46:28.676+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Calling downstream: tf_req_id=23631c72-e18d-21f6-7602-0ee3848a4464 @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:336 @module=sdk.proto tf_proto_version=5 tf_provider_addr=provider tf_rpc=GetSchema timestamp=2022-04-28T13:46:28.676+0100 2022-04-28T13:46:28.692+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Called downstream: @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:342 tf_req_id=23631c72-e18d-21f6-7602-0ee3848a4464 @module=sdk.proto tf_proto_version=5 tf_provider_addr=provider tf_rpc=GetSchema timestamp=2022-04-28T13:46:28.692+0100 2022-04-28T13:46:28.702+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Served request: tf_proto_version=5 tf_provider_addr=provider tf_req_id=23631c72-e18d-21f6-7602-0ee3848a4464 tf_rpc=GetSchema @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:348 @module=sdk.proto timestamp=2022-04-28T13:46:28.702+0100 2022-04-28T13:46:28.763+0100 [TRACE] GRPCProvider: Close 2022-04-28T13:46:28.763+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-04-28T13:46:28.766+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 pid=61110 2022-04-28T13:46:28.767+0100 [DEBUG] provider: plugin exited 2022-04-28T13:46:28.767+0100 [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_resource_group.test 2022-04-28T13:46:28.767+0100 [TRACE] AttachSchemaTransformer: attaching provider config schema to provider["registry.terraform.io/manicminer/azurerm"] 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2022-04-28T13:46:28.767+0100 [DEBUG] ReferenceTransformer: "azurerm_resource_group.test" references: [] 2022-04-28T13:46:28.767+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/manicminer/azurerm\"]" references: [] 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.TargetsTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes) 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.CloseProviderTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.CloseProviderTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] (close) - *terraform.graphNodeCloseProvider azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider ------ 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] (close) - *terraform.graphNodeCloseProvider azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider root - *terraform.nodeCloseModule provider["registry.terraform.io/manicminer/azurerm"] (close) - *terraform.graphNodeCloseProvider ------ 2022-04-28T13:46:28.767+0100 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer 2022-04-28T13:46:28.767+0100 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer with new graph: azurerm_resource_group.test - *terraform.NodeValidatableResource provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/manicminer/azurerm"] (close) - *terraform.graphNodeCloseProvider azurerm_resource_group.test - *terraform.NodeValidatableResource root - *terraform.nodeCloseModule provider["registry.terraform.io/manicminer/azurerm"] (close) - *terraform.graphNodeCloseProvider ------ 2022-04-28T13:46:28.767+0100 [DEBUG] Starting graph walk: walkValidate 2022-04-28T13:46:28.767+0100 [TRACE] vertex "provider[\"registry.terraform.io/manicminer/azurerm\"]": starting visit (*terraform.NodeApplyableProvider) 2022-04-28T13:46:28.767+0100 [DEBUG] created provider logger: level=trace 2022-04-28T13:46:28.767+0100 [INFO] provider: configuring client automatic mTLS 2022-04-28T13:46:28.784+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 args=[.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0] 2022-04-28T13:46:28.799+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 pid=61111 2022-04-28T13:46:28.800+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 2022-04-28T13:46:28.853+0100 [INFO] provider.terraform-provider-azurerm_v10.4.0: configuring server automatic mTLS: timestamp=2022-04-28T13:46:28.852+0100 2022-04-28T13:46:28.887+0100 [DEBUG] provider: using plugin: version=5 2022-04-28T13:46:28.887+0100 [DEBUG] provider.terraform-provider-azurerm_v10.4.0: plugin address: address=/var/folders/56/y8d3vjgj1qg6mqv6c_m0cy_w0000gp/T/plugin233942154 network=unix timestamp=2022-04-28T13:46:28.887+0100 2022-04-28T13:46:28.919+0100 [TRACE] BuiltinEvalContext: Initialized "provider[\"registry.terraform.io/manicminer/azurerm\"]" provider for provider["registry.terraform.io/manicminer/azurerm"] 2022-04-28T13:46:28.919+0100 [TRACE] provider.stdio: waiting for stdio data 2022-04-28T13:46:28.919+0100 [TRACE] NodeApplyableProvider: validating configuration for provider["registry.terraform.io/manicminer/azurerm"] 2022-04-28T13:46:28.919+0100 [TRACE] buildProviderConfig for provider["registry.terraform.io/manicminer/azurerm"]: using explicit config only 2022-04-28T13:46:28.919+0100 [TRACE] GRPCProvider: GetProviderSchema 2022-04-28T13:46:28.920+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Received request: tf_provider_addr=provider tf_rpc=GetSchema @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:329 @module=sdk.proto tf_proto_version=5 tf_req_id=3f90c6e9-3623-9d2e-d6b9-a961e70a24b1 timestamp=2022-04-28T13:46:28.920+0100 2022-04-28T13:46:28.920+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Calling downstream: tf_proto_version=5 tf_req_id=3f90c6e9-3623-9d2e-d6b9-a961e70a24b1 @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:336 tf_provider_addr=provider tf_rpc=GetSchema @module=sdk.proto timestamp=2022-04-28T13:46:28.920+0100 2022-04-28T13:46:28.935+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Called downstream: tf_proto_version=5 tf_provider_addr=provider tf_req_id=3f90c6e9-3623-9d2e-d6b9-a961e70a24b1 tf_rpc=GetSchema @module=sdk.proto @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:342 timestamp=2022-04-28T13:46:28.935+0100 2022-04-28T13:46:28.945+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Served request: tf_provider_addr=provider tf_req_id=3f90c6e9-3623-9d2e-d6b9-a961e70a24b1 @module=sdk.proto tf_proto_version=5 tf_rpc=GetSchema @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:348 timestamp=2022-04-28T13:46:28.945+0100 2022-04-28T13:46:29.001+0100 [TRACE] GRPCProvider: ValidateProviderConfig 2022-04-28T13:46:29.002+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Received request: @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:354 tf_proto_version=5 @module=sdk.proto tf_provider_addr=provider tf_req_id=4d3140e3-2cbd-6015-59d9-11b6bf04d938 tf_rpc=PrepareProviderConfig timestamp=2022-04-28T13:46:29.002+0100 2022-04-28T13:46:29.002+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Calling downstream: @module=sdk.proto @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:361 tf_proto_version=5 tf_provider_addr=provider tf_req_id=4d3140e3-2cbd-6015-59d9-11b6bf04d938 tf_rpc=PrepareProviderConfig timestamp=2022-04-28T13:46:29.002+0100 2022-04-28T13:46:29.070+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Called downstream: tf_proto_version=5 tf_rpc=PrepareProviderConfig @module=sdk.proto tf_provider_addr=provider tf_req_id=4d3140e3-2cbd-6015-59d9-11b6bf04d938 @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:367 timestamp=2022-04-28T13:46:29.070+0100 2022-04-28T13:46:29.070+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Served request: tf_rpc=PrepareProviderConfig @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:373 @module=sdk.proto tf_proto_version=5 tf_provider_addr=provider tf_req_id=4d3140e3-2cbd-6015-59d9-11b6bf04d938 timestamp=2022-04-28T13:46:29.070+0100 2022-04-28T13:46:29.071+0100 [TRACE] vertex "provider[\"registry.terraform.io/manicminer/azurerm\"]": visit complete 2022-04-28T13:46:29.071+0100 [TRACE] vertex "azurerm_resource_group.test": starting visit (*terraform.NodeValidatableResource) 2022-04-28T13:46:29.071+0100 [TRACE] GRPCProvider: ValidateResourceConfig 2022-04-28T13:46:29.072+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Received request: tf_provider_addr=provider tf_rpc=ValidateResourceTypeConfig @module=sdk.proto tf_proto_version=5 tf_req_id=c6a64a7c-1b41-ea42-81d4-8441ffa0661b tf_resource_type=azurerm_resource_group @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:495 timestamp=2022-04-28T13:46:29.072+0100 2022-04-28T13:46:29.072+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Calling downstream: @module=sdk.proto tf_proto_version=5 tf_provider_addr=provider tf_resource_type=azurerm_resource_group @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:502 tf_rpc=ValidateResourceTypeConfig tf_req_id=c6a64a7c-1b41-ea42-81d4-8441ffa0661b timestamp=2022-04-28T13:46:29.072+0100 2022-04-28T13:46:29.072+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Called downstream: @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:508 tf_resource_type=azurerm_resource_group tf_proto_version=5 tf_provider_addr=provider tf_req_id=c6a64a7c-1b41-ea42-81d4-8441ffa0661b tf_rpc=ValidateResourceTypeConfig @module=sdk.proto timestamp=2022-04-28T13:46:29.072+0100 2022-04-28T13:46:29.072+0100 [TRACE] provider.terraform-provider-azurerm_v10.4.0: Served request: tf_proto_version=5 tf_provider_addr=provider tf_req_id=c6a64a7c-1b41-ea42-81d4-8441ffa0661b @module=sdk.proto tf_resource_type=azurerm_resource_group tf_rpc=ValidateResourceTypeConfig @caller=github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:514 timestamp=2022-04-28T13:46:29.072+0100 2022-04-28T13:46:29.072+0100 [TRACE] vertex "azurerm_resource_group.test": visit complete 2022-04-28T13:46:29.072+0100 [TRACE] vertex "provider[\"registry.terraform.io/manicminer/azurerm\"] (close)": starting visit (*terraform.graphNodeCloseProvider) 2022-04-28T13:46:29.072+0100 [TRACE] GRPCProvider: Close 2022-04-28T13:46:29.072+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2022-04-28T13:46:29.076+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/manicminer/azurerm/10.4.0/darwin_amd64/terraform-provider-azurerm_v10.4.0 pid=61111 2022-04-28T13:46:29.076+0100 [DEBUG] provider: plugin exited 2022-04-28T13:46:29.076+0100 [TRACE] vertex "provider[\"registry.terraform.io/manicminer/azurerm\"] (close)": visit complete 2022-04-28T13:46:29.076+0100 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule) 2022-04-28T13:46:29.076+0100 [TRACE] vertex "root": visit complete Success! The configuration is valid. ```

Expected Behavior

Would expect to see an Unsupported Argument error for lines 7-8 of the config, as attributes foo and dfhdfgdgfhdgfhfgh are not valid per the backend schema.

Actual Behavior

Success! The configuration is valid.

terraform plan and terraform apply also seem to run just fine with the invalid config.

Steps to Reproduce

  1. terraform init -backend=false
  2. terraform validate

Additional Context

References

apparentlymart commented 2 years ago

Hi @manicminer! Thanks for reporting this.

Currently it's terraform init that primarily deals with backends, and so I'm not really surprised that terraform validate doesn't catch it (although it potentially could) but I am more concerned that you were able to run terraform plan and terraform apply without an initialized backend; I would've expected Terraform to return an error in that case telling you that you need to run terraform init first in order to initialize the backend before proceeding. (and of course, terraform init would then validate the backend config and refuse to initialize with an invalid one)

We can investigate both here of course, but I think making terraform validate check the backend block is more of an enhancement request than a bug since the current definition of validate explicitly excludes the need for an initialized backend, and so we'd need to make sure that the process of validating the backend doesn't cause Terraform to start requiring various environment variables to be set that would therefore break running terraform validate in an uncredentialed environment.

manicminer commented 2 years ago

Hi @apparentlymart, sorry I should clarify that terraform plan / terraform apply do work but only after initializing the backend with a valid config, and then changing it to an invalid config as per the above.

This makes sense as a feature request if validate is not currently intended to check backend configurations - I had assumed that it would check against the schema (especially as it's built in to the CLI binary). Thanks!

apparentlymart commented 2 years ago

Hi @manicminer,

Yes, just checking against the schema but not actually calling into the backend to validate could well be a suitable compromise here. Currently the backend schema check and subsequent validation are just one part of a big series of steps that effectively require the backend to be fully initialized, so terraform validate intentionally skips all of that to allow using it in situations where you ran terraform init -backend=false as you showed here.

We can investigate whether it's viable to extract out just the schema check portion and treat that as a validation step even though we wouldn't be able to catch situations where the backend has custom validation rules.

Since you mentioned that the terraform plan and terraform apply commands both caught the backend not being initialized, I'm going to reclassify this as an enhancement request. Thanks!