<p>Running <code>terraform apply -refresh-only</code> should take care of any new outputs. It will read the latest data from each resource and then update all of the outputs in terms of those updates, which includes re-evaluating your output expressions to incorporate any changes.</p>

CC BY-SA 4.0
2022-02-17T13:44:29.633Z
2023-01-24T19:31:29.147Z
2023-01-24T19:31:29.147Z
Joan Serra
<p>You cannot use resource targeting in this way as an output is not a resource, you can however run a simple apply, as terraform is idempotent that should not change any existing infrastructure but simply put in your output into terraform state.</p>
<p>you can test this with a simple terraform plan. Tested with terraform 1.0. With nothing else in your statefile you will end up with this, after apply:</p>
<pre><code>{
  &quot;version&quot;: 4,
  &quot;terraform_version&quot;: &quot;1.0.0&quot;,
  &quot;serial&quot;: 1,
  &quot;lineage&quot;: &quot;d79eacc7-51eb-2bf4-5ec6-cf8dca57348d&quot;,
  &quot;outputs&quot;: {
    &quot;environment_information&quot;: {
      &quot;value&quot;: {
        &quot;bar&quot;: &quot;value2&quot;,
        &quot;foo&quot;: &quot;value1&quot;
      },
      &quot;type&quot;: [
        &quot;object&quot;,
        {
          &quot;bar&quot;: &quot;string&quot;,
          &quot;foo&quot;: &quot;string&quot;
        }
      ]
    }
  },
  &quot;resources&quot;: []
}
</code></pre>
<p>If you have other non applied/half applied updates you can do one of two things, roll back your code to when they were not there and then remove any associated resources from state (keep a backup) then run apply again, or manually edit the statefile, either way update your hash in the locking db. If its only a couple of outputs i'd go with editing the statefile, just follow the syntax and always always have yourstate versioned and pull a copy just in case.</p>

CC BY-SA 4.0
2021-07-14T12:57:18.357Z
Thanks for the answer. I know it does not make sense, but we have a non-applied updates in the terraform. I need a solution to apply only the output part without touching/applying other stuff.
Turkdogan Tasdelen
CC BY-SA 4.0
2021-07-13T09:43:38.323Z
2021-08-12T09:11:52.650Z
2021-08-12T09:11:52.650Z
krystan honour
<p>I'm trying to apply only the output variable definition. Here is the &quot;output&quot; I want to apply.</p>
<pre><code>output &quot;environment_information&quot; {
   value = {
      foo = &quot;value1&quot;
      bar = &quot;value2&quot;
   }
}
</code></pre>
<p>Altough I added the &quot;bar&quot; as a new variable, I cannot see anything when I applied it by using the following Terraform command:</p>
<pre><code>terraform apply -target=output.environment_information
</code></pre>
<p>Any idea? Is it possible to apply output without any resource/module definition? Thank you.</p>

<terraform>
Terraform apply output only
Turkdogan Tasdelen
# Terraform apply output only

(Asked by: username_0 on 2021-07-07)

I'm trying to apply only the output variable definition. Here is the "output" I want to apply.
output "environment_information" {
   value = {
      foo = "value1"
      bar = "value2"
   }
}

Altough I added the "bar" as a new variable, I cannot see anything when I applied it by using the following Terraform command:
terraform apply -target=output.environment_information

Any idea? Is it possible to apply output without any resource/module definition? Thank you.

**Tags:** terraform


---

## 2 answers

### Answer by username_1 on 2022-02-17. Score: 27 | Accepted answer

Running `terraform apply -refresh-only` should take care of any new outputs. It will read the latest data from each resource and then update all of the outputs in terms of those updates, which includes re-evaluating your output expressions to incorporate any changes.


---

### Answer by username_2 on 2021-07-13. Score: 2

You cannot use resource targeting in this way as an output is not a resource, you can however run a simple apply, as terraform is idempotent that should not change any existing infrastructure but simply put in your output into terraform state.
you can test this with a simple terraform plan. Tested with terraform 1.0. With nothing else in your statefile you will end up with this, after apply:
{
  "version": 4,
  "terraform_version": "1.0.0",
  "serial": 1,
  "lineage": "d79eacc7-51eb-2bf4-5ec6-cf8dca57348d",
  "outputs": {
    "environment_information": {
      "value": {
        "bar": "value2",
        "foo": "value1"
      },
      "type": [
        "object",
        {
          "bar": "string",
          "foo": "string"
        }
      ]
    }
  },
  "resources": []
}

If you have other non applied/half applied updates you can do one of two things, roll back your code to when they were not there and then remove any associated resources from state (keep a backup) then run apply again, or manually edit the statefile, either way update your hash in the locking db. If its only a couple of outputs i'd go with editing the statefile, just follow the syntax and always always have yourstate versioned and pull a copy just in case.

> **Comments:**
> **username_0**: Thanks for the answer. I know it does not make sense, but we have a non-applied updates in the terraform. I need a solution to apply only the output part without touching/applying other stuff.  

---

