Terraform: Terraform state is not refreshed with new outputs value after apply

Created on 27 Aug 2019  ·  15Comments  ·  Source: hashicorp/terraform

Terraform Version

0.12.7

Terraform Configuration Files


Terraform (I am using Terraform Cloud, so this might be limited only to that) doesn't see updates in outputs.tf. I am using 2 workspaces, referencing output with data source in the second one and if I push new commit to VCS adding additional output value, Terraform Cloud workspace reports that there are no changes and stops after plan. After the state doesn't refresh with new output value.

output "aws_region" {
        value = "${var.aws_region}"
}

Debug Output

Crash Output

Expected Behavior


State should refresh with new output value

Actual Behavior


Terraform (I am using Terraform Cloud, so this might be limited only to that) doesn't see updates in outputs.tf. I am using 2 workspaces, referencing output with data source in the second one and if I push new commit to VCS adding additional output value, Terraform Cloud workspace reports that there are no changes and stops after plan. After the state doesn't refresh with new output value.

Steps to Reproduce

  1. Add output value to workspace's outputs, ran plan/apply
  2. Reference that value with data.terraform_remote_state.networking-dev.outputs.aws_region] from another workspace

Additional Context


Terraform Cloud environment.
I have to do any changes, even modify a tag to get new refreshed state.

References

bug core v0.12

Most helpful comment

This should be addressed by #25047, which will be included in the forthcoming v0.13.0 release.

All 15 comments

This is hitting me as well. Ideally the remote backend would just support refresh ?

Same here: I added a new outputs.tf in one workspace and require these outputs to be read by the remote_state data source in another workspace in terraform cloud. I have no clue how to force a refresh of the outputs section in the state without actually randomly modifying the resource.

For now.. i am just adding a random "foo=1" tag to a resource. Sucks, but works until this issue is addressed.

I am having the same issue, any updates on how can this be fixed?
Thanks :)

Please do not post "+1" comments here, since it creates noise for others watching the issue and ultimately doesn't influence our prioritization because we can't actually report on these. Instead, react to the original issue comment with +1, which we _can_ and _do_ report on.

Has anyone found a decent workaround to this until the terraform team get around to sorting this issue? I am aware that you can add random tags to resources, but I would rather not go through this method. Thanks

Probably #15419 is related to this issue

This is still an issue as of mid April. The other thread mentioned trying "terraform refresh" but it's not supported in TF cloud

The "remote" backend does not support the "OperationTypeRefresh" operation.

Do I actually have to make some random unnecessary change to get it to take the newly added outputs?

EDIT: I switched the settings in TF cloud from "remote" to "local" and then I was able to do a local "terraform apply" that, while finding no changes, DID update the "outputs" with my new output.

There is a workaround that we used for this situation not so long ago - https://github.com/hashicorp/terraform/issues/23247#issuecomment-584861344

Plz 2 fix
Because of this I gotta make a new ec2 instance and then delete them like a chump, each for four different workspaces

This support article mentions this issue and recommends null_resource, which I agree is the best workaround for Terraform Cloud:

https://support.hashicorp.com/hc/en-us/articles/360000958148-Terraform-outputs-fail-to-update-in-Terraform-Enterprise

Running locally with your workspace in local execution mode will work, and in fact you can just terraform refresh and not even apply. But as noted in the article the more complicated your workspace configuration gets (or the larger the team) the more impractical this becomes.

I'm thinking of working on a GitHub action that detects guaranteed output-only changes, where the diff only includes lines in output blocks. The action would comment on the PR informing the user of the required workaround. Would be nice to have one-click opt in and auto-write a generated change, but I haven't found a way to do that via Actions yet.

Anyone figured this out yet or still an issue ?

This is going to involve Terraform Cloud changes as well as possible changes to core. Please 👍 and subscribe to the issue rather than adding +1 or "any updates" comments to avoid notifying other subscribers.

This should be addressed by #25047, which will be included in the forthcoming v0.13.0 release.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings