moved: error if not targeting a resource address #35850
Merged
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.
This PR updates the parsing of targets (such as within import and moved blocks) so that they respect the keywords reserved by the top level references within Terraform.
These keywords include things like
local
,each
,count
,self
, andterraform
. Previously it was possible to reference these from withinmoved
as resource types without prefixing them with the normally requiredresource.
identifier to differentiate between a resource with the type namelocal
and just referencing alocal
variable.I'm not backporting this change, as it is technically a breaking change though I doubt anyone will be affected. Anyone who uses a resource that is simple called
local
(or any other reserved keyword) would previously have been able to reference it directly from amoved
block. This will start failing, and they must add in the.resource
prefix to make things work again.The purpose of this change is to protect users from trying to reference input or local variables, which currently makes Terraform just ignore the moved block. I don't think many (if any) providers have actually made resource types that match keywords so this should hopefully not breaking anything.
Fixes #35840
Target Release
1.10.x
Draft CHANGELOG entry
UPGRADE NOTES
moved
blocks: Moved blocks now respect reserved keywords when parsing resource addresses. Configurations that reference resources with type names that match top level blocks and keywords will need to be updated to