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.68k stars 9.55k forks source link

Terraform wants to destroy the wrong resource when using modules, for_each and -target together #29116

Open mivok opened 3 years ago

mivok commented 3 years ago

Terraform Version

> terraform version
Terraform v1.0.2
on darwin_amd64
+ provider registry.terraform.io/hashicorp/local v2.1.0

I've also observed this on 0.14.6

Terraform Configuration Files

main.tf:

module "foo" {
  source = "./foo"
  for_each = toset([
    "foo",
    "bar"
  ])
  filename = each.key
}

foo/main.tf:

variable "filename" {
  type = string
}

resource "local_file" "example" {
  content  = "Hello world"
  filename = "${var.filename}.txt"
}

Debug Output

TF_LOG=trace terraform apply -target='module.foo["baz"]' -no-color 2>&1 | tee debug.txt ``` 2021-07-07T17:34:18.412-0400 [DEBUG] Adding temp file log sink: /var/folders/t0/fdl29c0s73g97g_rrff8m0v80000gp/T/terraform-log651780678 2021-07-07T17:34:18.412-0400 [INFO] Terraform version: 1.0.2 2021-07-07T17:34:18.412-0400 [INFO] Go runtime version: go1.16.4 2021-07-07T17:34:18.412-0400 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/2.1.0/versions/1.0.2/terraform", "apply", "-target=module.foo[\"baz\"]", "-no-color"} 2021-07-07T17:34:18.412-0400 [TRACE] Stdout is not a terminal 2021-07-07T17:34:18.412-0400 [TRACE] Stderr is not a terminal 2021-07-07T17:34:18.412-0400 [TRACE] Stdin is a terminal 2021-07-07T17:34:18.412-0400 [DEBUG] Attempting to open CLI config file: /Users/markharrison/.terraformrc 2021-07-07T17:34:18.412-0400 [INFO] Loading CLI configuration from /Users/markharrison/.terraformrc 2021-07-07T17:34:18.413-0400 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2021-07-07T17:34:18.413-0400 [DEBUG] ignoring non-existing provider search directory /Users/markharrison/.terraform.d/plugins 2021-07-07T17:34:18.413-0400 [DEBUG] ignoring non-existing provider search directory /Users/markharrison/Library/Application Support/io.terraform/plugins 2021-07-07T17:34:18.413-0400 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins 2021-07-07T17:34:18.413-0400 [INFO] CLI command args: []string{"apply", "-target=module.foo[\"baz\"]", "-no-color"} 2021-07-07T17:34:18.414-0400 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config 2021-07-07T17:34:18.414-0400 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory 2021-07-07T17:34:18.414-0400 [DEBUG] New state was assigned lineage "9b42fa73-b588-ff24-3c30-a860324f38b5" 2021-07-07T17:34:18.414-0400 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend) 2021-07-07T17:34:18.414-0400 [TRACE] Meta.Backend: instantiated backend of type 2021-07-07T17:34:18.415-0400 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers 2021-07-07T17:34:18.415-0400 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/local v2.1.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64 2021-07-07T17:34:18.415-0400 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/local 2.1.0 2021-07-07T17:34:18.460-0400 [DEBUG] checking for provisioner in "." 2021-07-07T17:34:18.460-0400 [DEBUG] checking for provisioner in "/usr/local/Cellar/tfenv/2.1.0/versions/1.0.2" 2021-07-07T17:34:18.460-0400 [INFO] Failed to read plugin lock file .terraform/plugins/darwin_amd64/lock.json: open .terraform/plugins/darwin_amd64/lock.json: no such file or directory 2021-07-07T17:34:18.460-0400 [TRACE] Meta.Backend: backend does not support operations, so wrapping it in a local backend 2021-07-07T17:34:18.461-0400 [INFO] backend/local: starting Apply operation 2021-07-07T17:34:18.461-0400 [TRACE] backend/local: requesting state manager for workspace "default" 2021-07-07T17:34:18.461-0400 [TRACE] backend/local: state manager for workspace "default" will: - read initial snapshot from terraform.tfstate - write new snapshots to terraform.tfstate - create any backup at terraform.tfstate.backup 2021-07-07T17:34:18.461-0400 [TRACE] backend/local: requesting state lock for workspace "default" 2021-07-07T17:34:18.461-0400 [TRACE] statemgr.Filesystem: preparing to manage state snapshots at terraform.tfstate 2021-07-07T17:34:18.462-0400 [TRACE] statemgr.Filesystem: existing snapshot has lineage "e47c04be-7980-7452-ae79-6d5243db59fd" serial 14 2021-07-07T17:34:18.462-0400 [TRACE] statemgr.Filesystem: locking terraform.tfstate using fcntl flock 2021-07-07T17:34:18.462-0400 [TRACE] statemgr.Filesystem: writing lock metadata to .terraform.tfstate.lock.info 2021-07-07T17:34:18.462-0400 [TRACE] backend/local: reading remote state for workspace "default" 2021-07-07T17:34:18.463-0400 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate 2021-07-07T17:34:18.463-0400 [TRACE] statemgr.Filesystem: read snapshot with lineage "e47c04be-7980-7452-ae79-6d5243db59fd" serial 14 2021-07-07T17:34:18.463-0400 [TRACE] backend/local: retrieving local state snapshot for workspace "default" 2021-07-07T17:34:18.463-0400 [TRACE] backend/local: building context for current working directory 2021-07-07T17:34:18.463-0400 [TRACE] terraform.NewContext: starting 2021-07-07T17:34:18.463-0400 [TRACE] terraform.NewContext: loading provider schemas 2021-07-07T17:34:18.463-0400 [TRACE] LoadSchemas: retrieving schema for provider type "registry.terraform.io/hashicorp/local" 2021-07-07T17:34:18.464-0400 [DEBUG] created provider logger: level=trace 2021-07-07T17:34:18.464-0400 [INFO] provider: configuring client automatic mTLS 2021-07-07T17:34:18.505-0400 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5] 2021-07-07T17:34:18.508-0400 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80579 2021-07-07T17:34:18.508-0400 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 2021-07-07T17:34:18.518-0400 [INFO] provider.terraform-provider-local_v2.1.0_x5: configuring server automatic mTLS: timestamp=2021-07-07T17:34:18.518-0400 2021-07-07T17:34:18.553-0400 [DEBUG] provider.terraform-provider-local_v2.1.0_x5: plugin address: address=/var/folders/t0/fdl29c0s73g97g_rrff8m0v80000gp/T/plugin056773358 network=unix timestamp=2021-07-07T17:34:18.553-0400 2021-07-07T17:34:18.553-0400 [DEBUG] provider: using plugin: version=5 2021-07-07T17:34:18.592-0400 [TRACE] GRPCProvider: GetProviderSchema 2021-07-07T17:34:18.592-0400 [TRACE] provider.stdio: waiting for stdio data 2021-07-07T17:34:18.593-0400 [TRACE] GRPCProvider: Close 2021-07-07T17:34:18.593-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2021-07-07T17:34:18.595-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80579 2021-07-07T17:34:18.595-0400 [DEBUG] provider: plugin exited 2021-07-07T17:34:18.595-0400 [TRACE] terraform.NewContext: complete 2021-07-07T17:34:18.595-0400 [TRACE] backend/local: finished building terraform.Context 2021-07-07T17:34:18.595-0400 [TRACE] backend/local: requesting interactive input, if necessary 2021-07-07T17:34:18.595-0400 [TRACE] Context.Input: Prompting for provider arguments 2021-07-07T17:34:18.595-0400 [TRACE] backend/local: running validation operation 2021-07-07T17:34:18.595-0400 [INFO] terraform: building graph: GraphTypeValidate 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.ConfigTransformer 2021-07-07T17:34:18.595-0400 [TRACE] ConfigTransformer: Starting for path: 2021-07-07T17:34:18.595-0400 [TRACE] ConfigTransformer: Starting for path: module.foo 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.ConfigTransformer with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource ------ 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.RootVariableTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable ------ 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.LocalTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.OutputTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.StateTransformer 2021-07-07T17:34:18.595-0400 [TRACE] StateTransformer: state is empty, so nothing to do 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.StateTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.AttachStateTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer 2021-07-07T17:34:18.595-0400 [TRACE] AttachResourceConfigTransformer: attaching to "module.foo.local_file.example" (*terraform.NodeValidatableResource) config from foo/main.tf:5,1-32 2021-07-07T17:34:18.595-0400 [TRACE] AttachResourceConfigTransformer: attaching provider meta configs to module.foo.local_file.example 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.graphTransformerMulti 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable ------ 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer 2021-07-07T17:34:18.595-0400 [DEBUG] adding implicit provider configuration provider["registry.terraform.io/hashicorp/local"], implied first by module.foo.local_file.example 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer 2021-07-07T17:34:18.595-0400 [TRACE] ProviderTransformer: module.foo.local_file.example uses inherited configuration provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.595-0400 [DEBUG] ProviderTransformer: "module.foo.local_file.example" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer 2021-07-07T17:34:18.595-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.graphTransformerMulti with new graph: module.foo.local_file.example - *terraform.NodeValidatableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer 2021-07-07T17:34:18.595-0400 [TRACE] AttachSchemaTransformer: attaching resource schema to module.foo.local_file.example 2021-07-07T17:34:18.595-0400 [TRACE] AttachSchemaTransformer: attaching provider config schema to provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes) 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer 2021-07-07T17:34:18.595-0400 [TRACE] ModuleExpansionTransformer: Added module.foo as *terraform.nodeValidateModule 2021-07-07T17:34:18.595-0400 [TRACE] ModuleExpansionTransformer: module.foo.local_file.example must wait for expansion of module.foo 2021-07-07T17:34:18.595-0400 [TRACE] ModuleExpansionTransformer: module.foo.var.filename (expand) must wait for expansion of module.foo 2021-07-07T17:34:18.595-0400 [TRACE] ModuleExpansionTransformer: module.foo (close) must wait for expansion of module.foo 2021-07-07T17:34:18.595-0400 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer with new graph: module.foo (close) - *terraform.nodeCloseModule module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.595-0400 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2021-07-07T17:34:18.596-0400 [DEBUG] ReferenceTransformer: "module.foo.local_file.example" references: [module.foo.var.filename (expand)] 2021-07-07T17:34:18.596-0400 [INFO] ReferenceTransformer: reference not found: "each.key" 2021-07-07T17:34:18.596-0400 [DEBUG] ReferenceTransformer: "module.foo.var.filename (expand)" references: [] 2021-07-07T17:34:18.596-0400 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/hashicorp/local\"]" references: [] 2021-07-07T17:34:18.596-0400 [DEBUG] ReferenceTransformer: "module.foo (expand)" references: [] 2021-07-07T17:34:18.596-0400 [DEBUG] ReferenceTransformer: "module.foo (close)" references: [] 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.ReferenceTransformer with new graph: module.foo (close) - *terraform.nodeCloseModule module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes) 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes) 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.TargetsTransformer 2021-07-07T17:34:18.596-0400 [DEBUG] Removing "module.foo (close)", filtered by targeting. 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.TargetsTransformer with new graph: module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes) 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.CountBoundaryTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.CountBoundaryTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.CloseProviderTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.CloseProviderTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example - *terraform.NodeValidatableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example - *terraform.NodeValidatableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider root - *terraform.nodeCloseModule meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider ------ 2021-07-07T17:34:18.596-0400 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer 2021-07-07T17:34:18.596-0400 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo.local_file.example - *terraform.NodeValidatableResource module.foo (expand) - *terraform.nodeValidateModule module.foo.local_file.example - *terraform.NodeValidatableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeValidateModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example - *terraform.NodeValidatableResource root - *terraform.nodeCloseModule meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider ------ 2021-07-07T17:34:18.596-0400 [DEBUG] Starting graph walk: walkValidate 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo (expand)": starting visit (*terraform.nodeValidateModule) 2021-07-07T17:34:18.596-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"]": starting visit (*terraform.NodeApplyableProvider) 2021-07-07T17:34:18.596-0400 [DEBUG] created provider logger: level=trace 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo (expand)": visit complete 2021-07-07T17:34:18.596-0400 [INFO] provider: configuring client automatic mTLS 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo.var.filename (expand)": starting visit (*terraform.nodeExpandModuleVariable) 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo.var.filename (expand)": expanding dynamic subgraph 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo.var.filename (expand)": entering dynamic subgraph 2021-07-07T17:34:18.596-0400 [TRACE] vertex "module.foo.var.filename": starting visit (*terraform.nodeModuleVariable) 2021-07-07T17:34:18.597-0400 [TRACE] evalVariableValidations: not active for module.foo.var.filename, so skipping 2021-07-07T17:34:18.597-0400 [TRACE] vertex "module.foo.var.filename": visit complete 2021-07-07T17:34:18.597-0400 [TRACE] vertex "module.foo.var.filename (expand)": dynamic subgraph completed successfully 2021-07-07T17:34:18.597-0400 [TRACE] vertex "module.foo.var.filename (expand)": visit complete 2021-07-07T17:34:18.626-0400 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5] 2021-07-07T17:34:18.628-0400 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80580 2021-07-07T17:34:18.629-0400 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 2021-07-07T17:34:18.638-0400 [INFO] provider.terraform-provider-local_v2.1.0_x5: configuring server automatic mTLS: timestamp=2021-07-07T17:34:18.638-0400 2021-07-07T17:34:18.670-0400 [DEBUG] provider: using plugin: version=5 2021-07-07T17:34:18.670-0400 [DEBUG] provider.terraform-provider-local_v2.1.0_x5: plugin address: network=unix address=/var/folders/t0/fdl29c0s73g97g_rrff8m0v80000gp/T/plugin071381347 timestamp=2021-07-07T17:34:18.670-0400 2021-07-07T17:34:18.707-0400 [TRACE] provider.stdio: waiting for stdio data 2021-07-07T17:34:18.707-0400 [TRACE] BuiltinEvalContext: Initialized "provider[\"registry.terraform.io/hashicorp/local\"]" provider for provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.708-0400 [TRACE] buildProviderConfig for provider["registry.terraform.io/hashicorp/local"]: no configuration at all 2021-07-07T17:34:18.708-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"]": visit complete 2021-07-07T17:34:18.708-0400 [TRACE] vertex "module.foo.local_file.example": starting visit (*terraform.NodeValidatableResource) 2021-07-07T17:34:18.708-0400 [TRACE] GRPCProvider: ValidateResourceConfig 2021-07-07T17:34:18.708-0400 [TRACE] GRPCProvider: GetProviderSchema 2021-07-07T17:34:18.709-0400 [TRACE] vertex "module.foo.local_file.example": visit complete 2021-07-07T17:34:18.709-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"] (close)": starting visit (*terraform.graphNodeCloseProvider) 2021-07-07T17:34:18.709-0400 [TRACE] GRPCProvider: Close 2021-07-07T17:34:18.709-0400 [TRACE] vertex "meta.count-boundary (EachMode fixup)": starting visit (*terraform.NodeCountBoundary) 2021-07-07T17:34:18.709-0400 [TRACE] vertex "meta.count-boundary (EachMode fixup)": visit complete 2021-07-07T17:34:18.710-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2021-07-07T17:34:18.711-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80580 2021-07-07T17:34:18.711-0400 [DEBUG] provider: plugin exited 2021-07-07T17:34:18.711-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"] (close)": visit complete 2021-07-07T17:34:18.711-0400 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule) 2021-07-07T17:34:18.711-0400 [TRACE] vertex "root": visit complete 2021-07-07T17:34:18.711-0400 [INFO] backend/local: apply calling Plan 2021-07-07T17:34:18.711-0400 [INFO] terraform: building graph: GraphTypePlan 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.ConfigTransformer 2021-07-07T17:34:18.711-0400 [TRACE] ConfigTransformer: Starting for path: 2021-07-07T17:34:18.711-0400 [TRACE] ConfigTransformer: Starting for path: module.foo 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.ConfigTransformer with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource ------ 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.RootVariableTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable ------ 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.LocalTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.LocalTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.OutputTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.OutputTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.StateTransformer 2021-07-07T17:34:18.711-0400 [TRACE] StateTransformer: creating nodes for deposed instance objects only 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.StateTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.AttachStateTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer 2021-07-07T17:34:18.711-0400 [TRACE] AttachResourceConfigTransformer: attaching to "module.foo.local_file.example (expand)" (*terraform.nodeExpandPlannableResource) config from foo/main.tf:5,1-32 2021-07-07T17:34:18.711-0400 [TRACE] AttachResourceConfigTransformer: attaching provider meta configs to module.foo.local_file.example (expand) 2021-07-07T17:34:18.711-0400 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes) 2021-07-07T17:34:18.711-0400 [TRACE] Executing graph transform *terraform.graphTransformerMulti 2021-07-07T17:34:18.711-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer 2021-07-07T17:34:18.711-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable ------ 2021-07-07T17:34:18.711-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer 2021-07-07T17:34:18.711-0400 [DEBUG] adding implicit provider configuration provider["registry.terraform.io/hashicorp/local"], implied first by module.foo.local_file.example (expand) 2021-07-07T17:34:18.712-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer 2021-07-07T17:34:18.712-0400 [TRACE] ProviderTransformer: module.foo.local_file.example (expand) uses inherited configuration provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.712-0400 [DEBUG] ProviderTransformer: "module.foo.local_file.example (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.712-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer 2021-07-07T17:34:18.712-0400 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.graphTransformerMulti with new graph: module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer 2021-07-07T17:34:18.712-0400 [TRACE] AttachSchemaTransformer: attaching resource schema to module.foo.local_file.example (expand) 2021-07-07T17:34:18.712-0400 [TRACE] AttachSchemaTransformer: attaching provider config schema to provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer 2021-07-07T17:34:18.712-0400 [TRACE] ModuleExpansionTransformer: Added module.foo as *terraform.nodeExpandModule 2021-07-07T17:34:18.712-0400 [TRACE] ModuleExpansionTransformer: module.foo (close) must wait for expansion of module.foo 2021-07-07T17:34:18.712-0400 [TRACE] ModuleExpansionTransformer: module.foo.local_file.example (expand) must wait for expansion of module.foo 2021-07-07T17:34:18.712-0400 [TRACE] ModuleExpansionTransformer: module.foo.var.filename (expand) must wait for expansion of module.foo 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer with new graph: module.foo (close) - *terraform.nodeCloseModule module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2021-07-07T17:34:18.712-0400 [DEBUG] ReferenceTransformer: "module.foo.local_file.example (expand)" references: [module.foo.var.filename (expand)] 2021-07-07T17:34:18.712-0400 [INFO] ReferenceTransformer: reference not found: "each.key" 2021-07-07T17:34:18.712-0400 [DEBUG] ReferenceTransformer: "module.foo.var.filename (expand)" references: [] 2021-07-07T17:34:18.712-0400 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/hashicorp/local\"]" references: [] 2021-07-07T17:34:18.712-0400 [DEBUG] ReferenceTransformer: "module.foo (expand)" references: [] 2021-07-07T17:34:18.712-0400 [DEBUG] ReferenceTransformer: "module.foo (close)" references: [] 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.ReferenceTransformer with new graph: module.foo (close) - *terraform.nodeCloseModule module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer 2021-07-07T17:34:18.712-0400 [TRACE] AttachDependenciesTransformer: module.foo.local_file.example depends on [] 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.TargetsTransformer 2021-07-07T17:34:18.712-0400 [DEBUG] Removing "module.foo (close)", filtered by targeting. 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.TargetsTransformer with new graph: module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer 2021-07-07T17:34:18.712-0400 [TRACE] ForcedCBDTransformer: "module.foo.local_file.example (expand)" (*terraform.nodeExpandPlannableResource) has no CBD descendent, so skipping 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes) 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.CountBoundaryTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.CountBoundaryTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.CloseProviderTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.CloseProviderTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider root - *terraform.nodeCloseModule meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider ------ 2021-07-07T17:34:18.712-0400 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer 2021-07-07T17:34:18.712-0400 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer with new graph: meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo (expand) - *terraform.nodeExpandModule module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider module.foo.var.filename (expand) - *terraform.nodeExpandModuleVariable module.foo (expand) - *terraform.nodeExpandModule provider["registry.terraform.io/hashicorp/local"] - *terraform.NodeApplyableProvider provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider module.foo.local_file.example (expand) - *terraform.nodeExpandPlannableResource root - *terraform.nodeCloseModule meta.count-boundary (EachMode fixup) - *terraform.NodeCountBoundary provider["registry.terraform.io/hashicorp/local"] (close) - *terraform.graphNodeCloseProvider ------ 2021-07-07T17:34:18.713-0400 [DEBUG] Starting graph walk: walkPlan 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo (expand)": starting visit (*terraform.nodeExpandModule) 2021-07-07T17:34:18.713-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"]": starting visit (*terraform.NodeApplyableProvider) 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo (expand)": visit complete 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo.var.filename (expand)": starting visit (*terraform.nodeExpandModuleVariable) 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo.var.filename (expand)": expanding dynamic subgraph 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo.var.filename (expand)": entering dynamic subgraph 2021-07-07T17:34:18.713-0400 [DEBUG] created provider logger: level=trace 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo[\"foo\"].var.filename": starting visit (*terraform.nodeModuleVariable) 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo[\"baz\"].var.filename": starting visit (*terraform.nodeModuleVariable) 2021-07-07T17:34:18.713-0400 [INFO] provider: configuring client automatic mTLS 2021-07-07T17:34:18.713-0400 [TRACE] evalVariableValidations: not active for module.foo["foo"].var.filename, so skipping 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo[\"foo\"].var.filename": visit complete 2021-07-07T17:34:18.713-0400 [TRACE] evalVariableValidations: not active for module.foo["baz"].var.filename, so skipping 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo[\"baz\"].var.filename": visit complete 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo.var.filename (expand)": dynamic subgraph completed successfully 2021-07-07T17:34:18.713-0400 [TRACE] vertex "module.foo.var.filename (expand)": visit complete 2021-07-07T17:34:18.742-0400 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5] 2021-07-07T17:34:18.745-0400 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80581 2021-07-07T17:34:18.745-0400 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 2021-07-07T17:34:18.753-0400 [INFO] provider.terraform-provider-local_v2.1.0_x5: configuring server automatic mTLS: timestamp=2021-07-07T17:34:18.753-0400 2021-07-07T17:34:18.786-0400 [DEBUG] provider.terraform-provider-local_v2.1.0_x5: plugin address: address=/var/folders/t0/fdl29c0s73g97g_rrff8m0v80000gp/T/plugin420469968 network=unix timestamp=2021-07-07T17:34:18.786-0400 2021-07-07T17:34:18.786-0400 [DEBUG] provider: using plugin: version=5 2021-07-07T17:34:18.824-0400 [TRACE] provider.stdio: waiting for stdio data 2021-07-07T17:34:18.824-0400 [TRACE] BuiltinEvalContext: Initialized "provider[\"registry.terraform.io/hashicorp/local\"]" provider for provider["registry.terraform.io/hashicorp/local"] 2021-07-07T17:34:18.824-0400 [TRACE] buildProviderConfig for provider["registry.terraform.io/hashicorp/local"]: no configuration at all 2021-07-07T17:34:18.824-0400 [TRACE] GRPCProvider: GetProviderSchema 2021-07-07T17:34:18.824-0400 [TRACE] GRPCProvider: ValidateProviderConfig 2021-07-07T17:34:18.825-0400 [TRACE] GRPCProvider: ConfigureProvider 2021-07-07T17:34:18.825-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"]": visit complete 2021-07-07T17:34:18.825-0400 [TRACE] vertex "module.foo.local_file.example (expand)": starting visit (*terraform.nodeExpandPlannableResource) 2021-07-07T17:34:18.825-0400 [TRACE] vertex "module.foo.local_file.example (expand)": expanding dynamic subgraph 2021-07-07T17:34:18.825-0400 [TRACE] vertex "module.foo.local_file.example (expand)": entering dynamic subgraph 2021-07-07T17:34:18.825-0400 [TRACE] vertex "module.foo[\"foo\"].local_file.example": starting visit (*terraform.NodePlannableResource) 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": starting visit (*terraform.NodePlannableResource) 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"foo\"].local_file.example": expanding dynamic subgraph 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": expanding dynamic subgraph 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"bar\"].local_file.example (orphan)": starting visit (*terraform.NodePlannableResourceInstanceOrphan) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.ResourceCountTransformer 2021-07-07T17:34:18.826-0400 [TRACE] readResourceInstanceState: reading state for module.foo["bar"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] ResourceCountTransformer: adding module.foo["foo"].local_file.example as *terraform.NodePlannableResourceInstance 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.ResourceCountTransformer with new graph: module.foo["foo"].local_file.example - *terraform.NodePlannableResourceInstance ------ 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceCountTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceCountTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.AttachStateTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.TargetsTransformer 2021-07-07T17:34:18.826-0400 [DEBUG] Removing "module.foo[\"foo\"].local_file.example", filtered by targeting. 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.TargetsTransformer with new graph: ------ 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.RootTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.RootTransformer with new graph: root - terraform.graphNodeRoot ------ 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"foo\"].local_file.example": entering dynamic subgraph 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.ResourceCountTransformer 2021-07-07T17:34:18.826-0400 [TRACE] vertex "root": starting visit (terraform.graphNodeRoot) 2021-07-07T17:34:18.826-0400 [TRACE] upgradeResourceState: schema version of module.foo["bar"].local_file.example is still 0; calling provider "local" for any other minor fixups 2021-07-07T17:34:18.826-0400 [TRACE] GRPCProvider: UpgradeResourceState 2021-07-07T17:34:18.826-0400 [TRACE] ResourceCountTransformer: adding module.foo["baz"].local_file.example as *terraform.NodePlannableResourceInstance 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.ResourceCountTransformer with new graph: module.foo["baz"].local_file.example - *terraform.NodePlannableResourceInstance ------ 2021-07-07T17:34:18.826-0400 [TRACE] vertex "root": visit complete 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceCountTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceCountTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"foo\"].local_file.example": dynamic subgraph completed successfully 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"foo\"].local_file.example": visit complete 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.AttachStateTransformer 2021-07-07T17:34:18.826-0400 [DEBUG] Resource instance state not found for node "module.foo[\"baz\"].local_file.example", instance module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.TargetsTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2021-07-07T17:34:18.826-0400 [INFO] ReferenceTransformer: reference not found: "var.filename" 2021-07-07T17:34:18.826-0400 [DEBUG] ReferenceTransformer: "module.foo[\"baz\"].local_file.example" references: [] 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] Executing graph transform *terraform.RootTransformer 2021-07-07T17:34:18.826-0400 [TRACE] Completed graph transform *terraform.RootTransformer (no changes) 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": entering dynamic subgraph 2021-07-07T17:34:18.826-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": starting visit (*terraform.NodePlannableResourceInstance) 2021-07-07T17:34:18.826-0400 [TRACE] readResourceInstanceState: reading state for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] readResourceInstanceState: no state present for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to prevRunState for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] states.SyncState: pruning module.foo["baz"] because it is empty 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to refreshState for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] states.SyncState: pruning module.foo["baz"] because it is empty 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResourceInstance.refresh for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [DEBUG] refresh: module.foo["baz"].local_file.example: no state, so not refreshing 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to refreshState for module.foo["baz"].local_file.example 2021-07-07T17:34:18.826-0400 [TRACE] states.SyncState: pruning module.foo["baz"] because it is empty 2021-07-07T17:34:18.826-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to prevRunState for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.foo["baz"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to refreshState for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResourceInstance.refresh for module.foo["bar"].local_file.example module.foo["bar"].local_file.example: Refreshing state... [id=7b502c3a1f48c8609ae212cdfb639dee39673f5e] 2021-07-07T17:34:18.827-0400 [TRACE] GRPCProvider: ReadResource 2021-07-07T17:34:18.827-0400 [TRACE] Re-validating config for "module.foo[\"baz\"].local_file.example" 2021-07-07T17:34:18.827-0400 [TRACE] GRPCProvider: ValidateResourceConfig 2021-07-07T17:34:18.827-0400 [TRACE] GRPCProvider: PlanResourceChange 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to refreshState for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] writeChange: recorded Delete change for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] states.SyncState: pruning module.foo["bar"] because it is empty 2021-07-07T17:34:18.827-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.foo["bar"].local_file.example 2021-07-07T17:34:18.827-0400 [TRACE] vertex "module.foo[\"bar\"].local_file.example (orphan)": visit complete 2021-07-07T17:34:18.828-0400 [WARN] Provider "registry.terraform.io/hashicorp/local" produced an invalid plan for module.foo["baz"].local_file.example, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .directory_permission: planned value cty.StringVal("0777") for a non-computed attribute - .file_permission: planned value cty.StringVal("0777") for a non-computed attribute 2021-07-07T17:34:18.828-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.foo["baz"].local_file.example 2021-07-07T17:34:18.828-0400 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.foo["baz"].local_file.example 2021-07-07T17:34:18.828-0400 [TRACE] writeChange: recorded Create change for module.foo["baz"].local_file.example 2021-07-07T17:34:18.828-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": visit complete 2021-07-07T17:34:18.828-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": dynamic subgraph completed successfully 2021-07-07T17:34:18.828-0400 [TRACE] vertex "module.foo[\"baz\"].local_file.example": visit complete 2021-07-07T17:34:18.828-0400 [TRACE] vertex "module.foo.local_file.example (expand)": dynamic subgraph completed successfully 2021-07-07T17:34:18.828-0400 [TRACE] vertex "module.foo.local_file.example (expand)": visit complete 2021-07-07T17:34:18.828-0400 [TRACE] vertex "meta.count-boundary (EachMode fixup)": starting visit (*terraform.NodeCountBoundary) 2021-07-07T17:34:18.828-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"] (close)": starting visit (*terraform.graphNodeCloseProvider) 2021-07-07T17:34:18.828-0400 [TRACE] GRPCProvider: Close 2021-07-07T17:34:18.828-0400 [TRACE] vertex "meta.count-boundary (EachMode fixup)": visit complete 2021-07-07T17:34:18.828-0400 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing" 2021-07-07T17:34:18.830-0400 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.1.0/darwin_amd64/terraform-provider-local_v2.1.0_x5 pid=80581 2021-07-07T17:34:18.830-0400 [DEBUG] provider: plugin exited 2021-07-07T17:34:18.830-0400 [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/local\"] (close)": visit complete 2021-07-07T17:34:18.830-0400 [TRACE] vertex "root": starting visit (*terraform.nodeCloseModule) 2021-07-07T17:34:18.830-0400 [TRACE] vertex "root": visit complete Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create - destroy Terraform will perform the following actions: # module.foo["bar"].local_file.example will be destroyed - resource "local_file" "example" { - content = "Hello world" -> null - directory_permission = "0777" -> null - file_permission = "0777" -> null - filename = "bar.txt" -> null - id = "7b502c3a1f48c8609ae212cdfb639dee39673f5e" -> null } # module.foo["baz"].local_file.example will be created + resource "local_file" "example" { + content = "Hello world" + directory_permission = "0777" + file_permission = "0777" + filename = "baz.txt" + id = (known after apply) } Plan: 1 to add, 0 to change, 1 to destroy. Warning: Resource targeting is in effect You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration. The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message. 2021-07-07T17:34:18.830-0400 [DEBUG] command: asking for input: "\nDo you want to perform these actions?" Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: Apply cancelled. 2021-07-07T17:34:20.328-0400 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info 2021-07-07T17:34:20.328-0400 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock ```

Steps to Reproduce

Expected Behavior

Actual Behavior

$ terraform plan -target='module.foo["baz"]'
module.foo["bar"].local_file.example: Refreshing state... [id=7b502c3a1f48c8609ae212cdfb639dee39673f5e]

Terraform used the selected providers to generate the following execution plan. Resource actions
are indicated with the following symbols:
  + create
  - destroy

Terraform will perform the following actions:

  # module.foo["bar"].local_file.example will be destroyed
  - resource "local_file" "example" {
      - content              = "Hello world" -> null
      - directory_permission = "0777" -> null
      - file_permission      = "0777" -> null
      - filename             = "bar.txt" -> null
      - id                   = "7b502c3a1f48c8609ae212cdfb639dee39673f5e" -> null
    }

  # module.foo["baz"].local_file.example will be created
  + resource "local_file" "example" {
      + content              = "Hello world"
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "baz.txt"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 1 to destroy.
╷
│ Warning: Resource targeting is in effect
│
│ You are creating a plan with the -target option, which means that the result of this plan may not
│ represent all of the changes requested by the current configuration.
│
│ The -target option is not for routine use, and is provided only for exceptional situations such
│ as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part
│ of an error message.
╵

───────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take
exactly these actions if you run "terraform apply" now.

Additional Context

This is a minimal example, using local_file and a simple text file.

It only appears to happen when using for_each on a module. If I do the same thing, but with the for_each directly on a local_file resource, terraform correctly allows targeting just a specific instance of the resource.

jbardin commented 3 years ago

Thanks for filing the issue @mivok, you can see some more details on a similar issue in #25836. I'll leave this one open for now, since it has the same root cause but arrives there via a slightly different use case.

skeggse commented 2 years ago

Is there a workaround for this problem, @jbardin? Finding the right workspace structure to allow targeted applies for divergent branches is hard, and modules containing linked resources seemed like it would be sufficient. Clearly not a well-supported use-case, which is probably fair, but sometimes still necessary.

jbardin commented 2 years ago

@skeggse a workaround would depend on the specific use case. Some situations are not really solvable in the general sense, because the targeting can create unknown values which require the changes to be evaluated during apply. Since -target is only intended to be a temporary workaround for problems when a complete config cannot be applied, the shortcomings appear differently depending on the problem at hand. The only advice I could offer other than restructuring the config to be applied as a whole, would be to try and use multiple applies with more narrowly defined-target values.

skeggse commented 2 years ago

Interestingly, from recent experience, the plan does not match the apply. If I apply a targeted plan such as those described in this thread, only the -targeted resources get applied, and some subset of the plan gets ignored. In other words, the "Plan: 1 to add, 0 to change, 1 to destroy." does not match the final counts.