Terraform workspace

Terraform workspace enables us to manage multiple set of deployments from the same set of configuration file.

Ex: you have one ec2 instance named AS VM1 and this instance you need for your Prod and dev, in such you no need to created different resources same resource you can use for 2 environments using terraform workspace. additionally each environment have their own state file.

command to list the workspace: Terraform workspace list

to switch for prod environment: Terraform workspace select prod

to create a new workspace: Terraform workspace new ENV-name