cli: manual AWS terraform state transitions

This commit is designed to be reverted in the future (AB#3248).
Terraform does not implement moved blocks with dynamic targets: https://github.com/hashicorp/terraform/issues/31335 so we have to migrate the terraform state ourselves.
This commit is contained in:
Malte Poll 2023-06-27 13:12:50 +02:00 committed by Malte Poll
parent 22ebdace43
commit 3edc1c3ebb
9 changed files with 183 additions and 6 deletions

View file

@ -204,6 +204,17 @@ func (u *upgradeCheckCmd) upgradeCheck(cmd *cobra.Command, fileHandler file.Hand
u.log.Debugf("Planning Terraform migrations")
// TODO(AB#3248): Remove this migration after we can assume that all existing clusters have been migrated.
var awsZone string
if csp == cloudprovider.AWS {
awsZone = conf.Provider.AWS.Zone
}
manualMigrations := terraformMigrationAWSNodeGroups(csp, awsZone)
for _, migration := range manualMigrations {
u.log.Debugf("Adding manual Terraform migration: %s", migration.DisplayName)
u.checker.AddManualStateMigration(migration)
}
if err := u.checker.CheckTerraformMigrations(fileHandler); err != nil {
return fmt.Errorf("checking workspace: %w", err)
}
@ -729,6 +740,7 @@ type upgradeChecker interface {
PlanTerraformMigrations(ctx context.Context, opts upgrade.TerraformUpgradeOptions) (bool, error)
CheckTerraformMigrations(fileHandler file.Handler) error
CleanUpTerraformMigrations(fileHandler file.Handler) error
AddManualStateMigration(migration terraform.StateMigration)
}
type versionListFetcher interface {