Terraform
The tf-migrate modules create command moves all resources in the root module into a new child module so that you can deploy it as a Stack.
Usage
$ tf-migrate modules create [options]
Description
The tf-migrate modules create command wraps your root module into a child module so that you can deploy it as a Stack. This command does not modify your state, instead it makes a copy of your configuration in a directory named modularized_config. Ensure that a directory named modularized_config does not exist in the current directory before you run this command.
Example
The following example makes a copy of the configuration in the modularized_config subdirectory and converts the root module into a child module.
$ tf-migrate modules create
✓ Found 1 terraform files in the root directory
✓ Extracted HCP Terraform data to identify the workspaces controlled by the configuration.
You're about to begin the modularization process. read the following important notes carefully:
1. A folder named modularized_config will be created to store the modularized configuration generated from your current setup.
2. All directories containing locally referenced modules will be copied into the modularized_config folder.
3. The modularized_config folder must not already exist in the current working directory.
4. All folders for locally referenced modules must be located within the current working directory where Terraform Migrate is being run.
Kindly confirm that you have read and understood the warning message above. Do you want to proceed ... ?
Only 'yes' or 'no' will be accepted as input.
Type 'yes' to approve proceed with modularization process
Type 'no' to abort the modularization process
Enter a value: yes
✓ Found 1 HCP Terraform workspaces associated with the configuration.
✓ Successfully generated modularized config in modularized_config
✓ Modularization process completed successfully
Available options
You can include the following flags when you run the tf-migrate modules create command:
| Option | Description | Default | Required |
|---|---|---|---|
-config-file | Specifies the path to an optional configuration file. Refer to tf-migrate configuration file reference for more information. | None | No |
Troubleshooting
If your Terraform configuration references external files, such as scripts, or local modules outside of the current working directory, tf-migrate does not automatically include these files automatically. After you run this command, review the modularized_config/terraform_modules directory to verify that it contains all files required to deploy your configuration.