{"record":{"id":"626b49b2d0f3297e","repo":"hashicorp/terraform","slug":"no-instance-found-for-the-given-address-this-com","errorCode":null,"errorMessage":"No instance found for the given address!\n\nThis command requires that the address references one specific instance.\nTo view the available instances, use \"terraform state list\". Please modify\nthe address to reference a specific instance.","messagePattern":"No instance found for the given address!\n\nThis command requires that the address references one specific instance\\.\nTo view the available instances, use \"terraform state list\"\\. Please modify\nthe address to reference a specific instance\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/state_show.go","lineNumber":130,"sourceCode":"\tstateMgr, sDiags := b.StateMgr(env)\n\tif sDiags.HasErrors() {\n\t\tdiags = diags.Append(fmt.Errorf(errStateLoadingState, sDiags.Err()))\n\t\treturn view.DisplayResourceInstanceState(jsonformat.State{}, diags)\n\t}\n\tif err := stateMgr.RefreshState(); err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to refresh state: %s\\n\", err))\n\t\treturn view.DisplayResourceInstanceState(jsonformat.State{}, diags)\n\t}\n\n\tstate := stateMgr.State()\n\tif state == nil {\n\t\tdiags = diags.Append(errors.New(errStateNotFound))\n\t\treturn view.DisplayResourceInstanceState(jsonformat.State{}, diags)\n\t}\n\n\tis := state.ResourceInstance(addr)\n\tif !is.HasCurrent() {\n\t\tdiags = diags.Append(errors.New(errNoInstanceFound))\n\t\treturn view.DisplayResourceInstanceState(jsonformat.State{}, diags)\n\t}\n\n\t// check if the resource has a configured provider, otherwise this will use the default provider\n\trs := state.Resource(addr.ContainingResource())\n\tabsPc := addrs.AbsProviderConfig{\n\t\tProvider: rs.ProviderConfig.Provider,\n\t\tAlias:    rs.ProviderConfig.Alias,\n\t\tModule:   addrs.RootModule,\n\t}\n\tsingleInstance := states.NewState()\n\tsingleInstance.EnsureModule(addr.Module).SetResourceInstanceCurrent(\n\t\taddr.Resource,\n\t\tis.Current,\n\t\tabsPc,\n\t)\n\n\tmockFile := statefile.New(singleInstance, \"\", 0)","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/state_show.go#L112-L148","documentation":"Returned by `terraform state show` when the state exists and refreshes fine, but the requested resource address either does not exist in state or has no current instance object (`!is.HasCurrent()`). The message tells the user the address must reference one specific instance and suggests `terraform state list`.","triggerScenarios":"`state.ResourceInstance(addr)` returns an instance whose `HasCurrent()` is false — the resource was never created, was destroyed, the address is misspelled, or a counted/for-each resource was asked for without an index.","commonSituations":"Asking for `aws_instance.web` when it is actually `aws_instance.web[0]`; resource was `terraform destroy`-ed; typo in the address; the provider has not yet created the resource (pre-apply).","solutions":["Run `terraform state list` and copy the exact address (including `[index]` for counted/for-each resources).","If the resource was destroyed or never applied, run `terraform apply` to create it.","Confirm you are targeting the right workspace whose state contains that resource."],"exampleFix":"# before\nterraform state show aws_instance.web   # counted resource -> error\n# after\nterraform state list   # see exact address\nterraform state show aws_instance.web[0]","handlingStrategy":"validation","validationCode":"// Validate the instance exists and is current before showing:\nis := state.ResourceInstance(addr)\nif is == nil || !is.HasCurrent() {\n    return errors.New(errNoInstanceFound)\n}","typeGuard":"// hasCurrentInstance reports whether an address resolves to a live instance.\nfunc hasCurrentInstance(s *states.Sync, addr addrs.AbsResourceInstance) bool {\n    is := s.ResourceInstance(addr)\n    return is != nil && is.HasCurrent()\n}","tryCatchPattern":null,"preventionTips":["Always `terraform state list` first and copy the exact address.","Include `[index]` / `[\"key\"]` for counted/for-each resources.","Confirm the resource has been applied in the selected workspace."],"tags":["state","state-show","resource-address","instance","terraform-cli"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}