plan and apply commands to update individual resources without affecting the rest of your infrastructure.
Example Configuration
Below is a sample HCL configuration that generates a random string and launches an AWS EC2 instance tagged with that string:The
aws_instance.web resource uses the interpolation ${random_string.server-suffix.id} to append the generated suffix to the Name tag.Applying Changes Normally
If you change the random string’s length from6 to 5 and run:
Targeting a Single Resource
To update only the random string and leave the EC2 instance untouched, use the-target flag:
Using resource targeting can leave your state incomplete. Reserve this feature for urgent fixes or small, isolated changes.