13. Managing Multiple Environments
Approaches
1. Workspaces
Multiple named sections within a single backend
Pros
easy to get started
convinient terraform.workspace expression
minimizes code duplication
Cons
prone to human error
state stored with same backend
codebase doesn't unambigously show deployment configurations
2. File Structure
Directory layout provides seperation, modules provide reuse
Pros
isolation of backends
improved security
decreased potential for human error
codebase fully represents deployed state
referencing resources acrodd configurations is possible using
terraform_remote_state
Cons
multiple terraform apply required to provision environments
more code duplication, but can be minimized with modules
Last updated