Ensure we still read/refresh remote state when activate is set to false. #345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
Fixes an edge case in the
fastly_service_*
resources, in which we don't refresh remote state if theactivate
field is set tofalse
. This was introduced in #269, when we refactored the service resources to the "block" model and introduced the base service definition interface.What?
After a couple of bug reports related to
activate = false
via Fastly support, we investigated further and found that if a configuration has theactivate
field set to false AND it has no previous active version the state wasn't being read. This manifested itself as a runtime error in certain situations, such as another resource referencing the state in its configuration.It turns out we were assuming that the service will always have an active version number greater than 0 within the
Read
method and gating the read on that condition.Fixes: hashicorp/terraform#27258
Note:
I've ran the tests I introduced in this PR to confirm this fixes the issue. However still ned to run the full suite before merging, which I'll try and do in the coming days.