We currently use different workspaces for our DEV and PROD accounts, but the structure is not currently split by environment. I want to move over to a more modular approach as well as having the environments in their own directories.
My question is, if I do this refactoring and change the directory under which the workspace runs, do I need to do anything to also move the location of the state file (as the docs say it is stored in the root of the directory it runs under, and this will now be a subdirectory). Or does the workspace handle this automatically?
In Terraform Cloud, state storage is a part of the workspace. You can freely reconfigure the VCS branch and working directory that Terraform Cloud looks at, whilst keeping your state.
The only thing to watch out for is that you appropriately synchronize your rearrangement commits to Git, and your reconfiguration of Terraform Cloud.
Terraform does have a safety measure, where it refuses to run at all if pointed to a directory that contains no .tf files at all - but accidentally running Terraform against a wrong directory containing some .tf files could lead to lots of undesired changes - including resource destruction.
For that reason, you might want to employ a protective countermeasure, such as locking the workspace, or switching it to manual apply mode, whilst you make the changes, to ensure a Git-triggered Terraform run doesn’t have unwanted consequences.