# Error: Invalid target: the given target is not valid: resource address must be a valid resource instance

- **ID:** `terraform/targeted-apply-without-plan`
- **Domain:** terraform
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The -target option was used with an incorrectly formatted resource address, such as missing the resource type or name.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.5.0 | active | — | — |
| 1.6.0 | active | — | — |
| 1.7.0 | active | — | — |
| 1.8.0 | active | — | — |

## Workarounds

1. **Use the correct resource address format: terraform apply -target="aws_instance.web". For modules: -target="module.vpc.aws_subnet.public". Verify the address with terraform state list.** (95% success)
   ```
   Use the correct resource address format: terraform apply -target="aws_instance.web". For modules: -target="module.vpc.aws_subnet.public". Verify the address with terraform state list.
   ```
2. **If targeting a resource with count or for_each, include the index: -target="aws_instance.web[0]" or -target='aws_instance.web["key1"]'.** (90% success)
   ```
   If targeting a resource with count or for_each, include the index: -target="aws_instance.web[0]" or -target='aws_instance.web["key1"]'.
   ```
3. **Use terraform plan -target to preview before applying: terraform plan -target="aws_instance.web" -out=tfplan && terraform apply tfplan.** (85% success)
   ```
   Use terraform plan -target to preview before applying: terraform plan -target="aws_instance.web" -out=tfplan && terraform apply tfplan.
   ```

## Dead Ends

- **Use the resource name only without the type, e.g., -target=my_resource.** — Terraform requires the full address format: resource_type.resource_name. A bare name is not recognized. (100% fail)
- **Use -target with a module path that doesn't exist.** — The target must reference an existing resource in the configuration; non-existent paths cause the same error. (90% fail)
- **Run terraform apply without any target, ignoring the need for targeted operations.** — This applies all changes, which may not be desired and could cause unintended side effects. (60% fail)
