DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Review Terraform Destroy Plans, Choose count or for_each, and Place JSON Comments

Terraform’s JSON comment convention depends on object placement. Choose count or for_each by instance identity, and verify every address and action in a destroy plan before approval.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Terraform destroy count is a proposed plan outcome, not proof that the planned deletion is correct. Review the exact resource addresses and actions, and confirm the configuration, state, workspace, and intended scope before approving anything. For generated configuration, comment rules depend on whether the file is .tf.json or native .tf syntax: JSON’s special // property is ignored only at the configuration root or in objects representing block bodies—not inside expression objects.

Start by identifying the configuration format

Terraform accepts native syntax in .tf files and JSON syntax in .tf.json files. The JSON form is intended mainly for programmatic generation and consumption; HashiCorp does not recommend hand-editing it. See Terraform JSON configuration syntax.

As an Amazon Associate I earn from qualifying purchases.

That distinction matters when a generated file contains a comment. Native Terraform has comment syntax; JSON does not, so Terraform provides a limited convention for JSON configuration instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Place comments according to the object’s meaning

In a .tf.json file, a property named // is ignored when it appears in an object representing a block body. It may also appear at the configuration file’s root. It is not a general-purpose comment marker: inside an object interpreted as an expression, // is an ordinary attribute name. The surrounding structure—not just the property name—determines whether Terraform treats it as a comment.

{
  "resource": {
    "aws_instance": {
      "example": {
        "//": "Generated resource for scheduled tasks",
        "instance_type": "t2.micro",
        "ami": "ami-abc123"
      }
    }
  }
}

Here, the property is inside the resource block body. If the same property is placed inside an expression object, it is not covered by the comment convention. Without the actual file and its nesting, it is not possible to identify a specific parse error or say exactly what Terraform will report.

In native .tf files, use # or // for line comments, or /* ... */ for a block comment. Terraform’s style guide recommends # as the default line-comment style. See Terraform language style conventions.

Choose count or for_each based on instance identity

Both meta-arguments create multiple instances from one resource or module block, but they identify those instances differently. A block can use count or for_each, not both.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Consideration count for_each
Input A whole number known before Terraform performs remote operations A map or a set of strings
Instance identity Zero-based numeric index, such as resource.name[0] Map key or set member, such as resource.name["api"]
Per-instance reference count.index each.key and each.value
Good fit Near-identical instances where position is an adequate identity Instances with meaningful stable keys or values that differ by item

Use count when the instances are effectively interchangeable and a numeric position is appropriate. Use for_each when a name or key represents the instance’s identity, or when arguments are associated with particular map entries. The choice affects resource addresses, so inspect references and the resulting plan when changing from one model to the other. See Terraform meta-arguments, count, and for_each.

Interpret the destroy count as a proposal

Plan symbols describe proposed actions: + creates, - destroys, ~ updates in place, and -/+ replaces. A destroy-mode plan aims to destroy managed objects represented by the selected configuration. terraform plan -destroy previews that proposed destruction; terraform destroy is a convenience form of applying a destroy-mode plan. See the plan command, destroy command, and Terraform plan tutorial.

Before approving a plan, compare every listed address and action with the intended deletion scope. For repeated resources, check the specific count indexes or for_each keys, rather than relying on the total alone. Confirm that the active configuration, workspace, inputs, and state context are the ones you intend to use.

  • If an address is unexpected, stop and investigate why Terraform considers that instance managed or why it is absent from the selected configuration.
  • If an action is unexpected, determine whether it is a destroy, replacement, or another change before proceeding.
  • Do not approve solely because the destroy total looks plausible. A number without its addresses and actions does not establish that the target set is correct.

There is no configuration, state, workspace, or plan available here to diagnose a particular destroy count. The documentation explains how to read and create plans; it cannot verify an unseen plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check generated configuration and plan data safely

  1. Confirm the file type. Establish whether the generated artifact uses native .tf syntax or JSON in a .tf.json file.
  2. Inspect comment placement. In JSON, check whether the object containing // is the configuration root, a block body, or an expression object.
  3. Check repetition and addresses. Identify whether the block uses count or for_each, and make sure the resulting indexed or keyed addresses fit the intended model.
  4. Run configuration checks where applicable. Use terraform fmt to format configuration and terraform validate to validate it. These checks complement—but do not replace—review of the planned changes. See terraform fmt and terraform validate.
  5. Review the complete plan. Examine addresses and actions, especially destruction and replacement, before applying. Do not infer safety from the headline count.

For automated inspection, Terraform can render a plan file as machine-readable JSON with terraform show -json. Plan JSON represents configuration and planned changes, but its format has version behavior that consumers must account for. Plan files and their JSON output can contain sensitive values; protect them and do not commit them to version control. See Terraform JSON output format.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.