Skip to content

Resource addresses in prior state of a json plan lacking indexes #24110

@mwhooker

Description

@mwhooker

Terraform Version

0.12.20

Terraform Configuration Files

resource "null_resource" "cluster" {
  count = 3
}

Expected Behavior

I expect there to be symmetry between prior state and proposed state. The proposed state looks like

{
  "format_version": "0.1",
  "terraform_version": "0.12.20",
  "planned_values": {
    "root_module": {
      "resources": [
        {
          "address": "null_resource.cluster[0]",
          "mode": "managed",
          "type": "null_resource",
          "name": "cluster",
          "index": 0,
          "provider_name": "null",
          "schema_version": 0,
          "values": {
            "triggers": null
          }
        },
...

Actual Behavior

The prior state, if I delete the resources, looks like

  "prior_state": {
    "format_version": "0.1",
    "terraform_version": "0.12.20",
    "values": {
      "root_module": {
        "resources": [
          {
            "address": "null_resource.cluster",
            "mode": "managed",
            "type": "null_resource",
            "name": "cluster",
            "index": 0,
            "provider_name": "null",
            "schema_version": 0,
            "values": {
              "id": "7039102915404397285",
              "triggers": null
            }
          },
...

Steps to Reproduce

  1. Use example input
  2. terraform init
  3. terraform apply
  4. delete resource
  5. tf plan -out terraform.tfplan; tf show -json terraform.tfplan

Note that the resource addresses in the prior state do not contain an index.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions