Terraform workspace, locals and variables.

Using workspace you can provision more than one environments. To do this using workspaces, you first create a workspace called dev using the terraform workspace new command:

$ terraform workspace new prod

terraform workspace new prod

terraform apply

… output trimmed..

As you can see new workspace ‘prod’ is created and new infrastructure is provisioned.

Note: * prod (* is showing current workspace).

terraform workspace select default

Now there are 6 instances up and running…

Question: How to change the server names and tags in PROD?

All commands will be applicable to current worspace.

After destroying prod, still you will be there. If you want to work in another env, change to it.

Leave a Reply

Your email address will not be published. Required fields are marked *