Skip to content

init: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation#560

Merged
SarahFrench merged 5 commits intomainfrom
add-state-migration-support
Feb 3, 2026
Merged

init: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation#560
SarahFrench merged 5 commits intomainfrom
add-state-migration-support

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Jan 21, 2026

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-copy flag 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 with yes.

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

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

N/A

@SarahFrench SarahFrench requested review from a team as code owners January 21, 2026 19:14
@SarahFrench SarahFrench changed the title Add state migration support docs: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation Jan 21, 2026
@SarahFrench SarahFrench changed the title docs: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation init: Add godoc comments for ForceCopy to mention that it's equivalent to -migrate-state in automation Jan 21, 2026
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the unit tests still need fixing - unsure why

@SarahFrench SarahFrench merged commit e9f5952 into main Feb 3, 2026
107 checks passed
@SarahFrench SarahFrench deleted the add-state-migration-support branch February 3, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants