init: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation#560
Merged
SarahFrench merged 5 commits intomainfrom Feb 3, 2026
Merged
Conversation
…list matching the flags asserted via `assertCmd`
… use instead of -migrate-state
SarahFrench
commented
Jan 21, 2026
ForceCopy to mention that it's equivalent to -migrate-state in automation
ForceCopy to mention that it's equivalent to -migrate-state in automationForceCopy to mention that it's equivalent to -migrate-state in automation
radeksimko
approved these changes
Feb 2, 2026
radeksimko
requested changes
Feb 2, 2026
Member
radeksimko
left a comment
There was a problem hiding this comment.
Looks like the unit tests still need fixing - unsure why
radeksimko
approved these changes
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issue
N/A
Description
I was investigating #355 (and #460) and realised that the ability to migrate state is already present in terraform-exec via the -force-copy flag.
There are potentially some behaviour changes to consider for very old Terraform versions; looks like init used to always attempt a state migration but then that feature was made optional behind
-migrate-state. By then the-force-copyflag had already existed for several years. That makes sense; it allowed the older, automatic migration behaviour to work in automation. Once that automatic migration was removed it began representing consent to do the migration as well as suppressing prompts withyes.In terms of terraform-exec I think we don't need to have any special consideration of the above and we can simply check that -force-copy is used in a compatible version of Terraform. It was added in TF v0.9.2 (see commit hashicorp/terraform@ddb9c51481e302d6cfde62f8475f5f8aaed90e35's associated tags)
In this PR
I've added some godoc comments to help users realise that -migrate-state isn't needed.
Also, I've updated some tests to assert that the flag can be changed to a non default value.
Rollback Plan
Changes to Security Controls
N/A