Terraform
The tf-migrate stacks execute command directs Terraform to run the init, plan, and apply commands on the configuration generated with the tf-migrate stacks prepare command and migrate your HCP Terraform workspace and state to a Stack.
Usage
$ tf-migrate stacks execute
Description
The tf-migrate stacks execute command creates the project and Stack in HCP Terraform and migrates the existing state.
When tf-migrate completes the migration, it displays a link to the Stack it created and the project it created it in.
Example
The tf-migrate execute command automatically performs the migration and code updates.
$ tf-migrate stacks execute
✓ Stack configuration path found: /tmp/my-workspace/modularized_config/_stacks_generated
✓ Successfully validated stack configuration found in dir: /tmp/my-workspace/modularized_config/_stacks_generated
✓ Using dir: /tmp/my-workspace/modularized_config/stacks_migration_infra for terraform operations
✓ Init command ran successfully
✓ Plan command ran successfully and changes are detected
✓ Apply command ran successfully in 55.73248925s
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Migration Summary
┌─────────┬────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Item │ URL │
├─────────┼────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Project │ https://app.terraform.io/app/<ORG>/projects/prj-a1b2c3d4e5f6g7h8 │
│ Stack │ https://app.terraform.io/app/<ORG>/projects/prj-a1b2c3d4e5f6g7h8/stacks/st-a1b2c3d4e5f6g7h8 │
└─────────┴────────────────────────────────────────────────────────────────────────────────────────────────┘
Terraform Migrate has successfully executed the migration plan for your stack.
Please verify the migration in the HCP Terraform UI.
Next Steps:
1. Visit https://app.terraform.io/app/<ORG>/projects/prj-a1b2c3d4e5f6g7h8/stacks/st-a1b2c3d4e5f6g7h8.
2. Review the uploaded configuration and confirm it has been applied successfully.
3. Ensure all deployments under the stacks have completed. You may need to approve some plans.
4. If you encounter issues, refer to the diagnostics in the UI and follow this troubleshooting guide:
a. If there are configuration errors, review your stack configurations in _stacks_generated and resolve them.
b. Delete the stack and project from the HCP Terraform UI if necessary.
c. Remove the `.terraform` and `terraform.tfstate` files from the stacks_migration_infra directory on your local machine.
d. Run `tf-migrate stacks execute` again to re-create the stacks and upload the corrected configuration.
5. For post-migration guidance, see: https://developer.hashicorp.com/terraform/migrate/v2.0.x/stacks#next-steps