Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform state is not refreshed with new outputs value after apply #22607

Closed
ghost opened this issue Aug 27, 2019 · 15 comments
Closed

Terraform state is not refreshed with new outputs value after apply #22607

ghost opened this issue Aug 27, 2019 · 15 comments
Labels
bug core v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@ghost
Copy link

ghost commented Aug 27, 2019

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

@hashibot hashibot added bug core v0.12 Issues (primarily bugs) reported against v0.12 releases labels Aug 27, 2019
@Geethree
Copy link

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

@phfeustel
Copy link

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.

@Geethree
Copy link

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

@juank11memphis
Copy link

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

@teamterraform
Copy link
Contributor

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.

@hugorut
Copy link

hugorut commented Nov 8, 2019

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

@qrilka
Copy link
Contributor

qrilka commented Feb 18, 2020

Probably #15419 is related to this issue

@luckyvalentine
Copy link

luckyvalentine commented Apr 15, 2020

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.

@qrilka
Copy link
Contributor

qrilka commented Apr 16, 2020

There is a workaround that we used for this situation not so long ago - #23247 (comment)

@hugbubby
Copy link

hugbubby commented Apr 18, 2020

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

@bendrucker
Copy link
Contributor

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.

@ghost
Copy link

ghost commented May 15, 2020

Anyone figured this out yet or still an issue ?

@bendrucker
Copy link
Contributor

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.

@apparentlymart
Copy link
Contributor

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

@ghost
Copy link

ghost commented Jul 11, 2020

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.

@ghost ghost locked and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug core v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests