Is it at all possible apply a plan with no changes? (Refresh output)

I have noticed that if I run a terraform apply with the following environment

  • remote state in in Terraform Enterprise/Cloud
  • the plan shows “no changes”

The apply will not run with the above scenario. I can see why this is the case since if there is no changes, there is no point running it.

Previously in other remote states, I would apply a plan with no changes when I am add/updating TF outputs.

How can I do this when I am now using the remote backend of TFE/Cloud? Is it at all possible to add new outputs to a tfstate without running an apply?

1 Like

Sounds like you just want the terraform output command.

At the moment the only way to update outputs without applying a change is to run terraform refresh from the CLI, which will also synchronize the state with any changes to remote infrastructure and re-read any data sources. There isn’t a Terraform Cloud web-based equivalent for that operation.

There is a GitHub issue #15419 representing that limitation and some documentation of some earlier design work for a solution to it. That work is currently on hold due to priorities being elsewhere, but we use :+1: reactions on the opening comments of issues as one input into prioritization, and you can watch that issue if you’d like to see future updates on it.

2 Likes

So… does this mean there’s actually no way to add and deploy a new output to a config in Terraform Cloud? (to be used with terraform_remote_state in another config, for example - this is what I need to add an output for)

I guess a workaround would be to… make some minor change to the config to force an update? Or is there any other, better workaround?

I think at the moment with Terraform 0.13.x, TF will apply a plan with there is a change in output. This is what I am encountering at the moment and Terroform Enteprise (and by extension TF Cloud) seems to apply a run when there is also a change in output.

The workaround I did if there is no output change even is that i use a “random_uuid” resource with a version parameter. When I need to force apply it, i just bump the version number in the random_uuid.

1 Like

My post over a year ago was true about Terraform 0.12, but Terraform 0.13 included a partial solution to the issue I mentioned which treats changes to root module outputs as a special case that will cause Terraform to prompt to apply changes, specifically so you can plan to add new data that is available for consumption elsewhere using terraform_remote_state.

The issue remains open because it was calling for a more complete solution that also reports any drift Terraform detected and prompts for whether those should be committed to the state, but it seems like this topic is focused specifically on root module outputs, and so that should now be resolved if you are using Terraform v0.13.0 or later.

1 Like

Very helpful! Thank you both :slight_smile:

I am actually still using TF 0.12 on my config currently, but it’s great to hear that particular issue has been solved - I’ll have to look into upgrading soon.

Incidentally, I was able to work around it using a slight variation on mechastorm’s solution - just adding this to my config:

resource "null_resource" "touch" {
  # Used to refresh the outputs in the state without changing infrastructure
  triggers = {
    how_many_fingers = "1" # changing this triggers outputs to be updated
  }
}