Terraform Workspaces VS Modules


Terraform Workspaces VS Terraform Modules

Terraform Workspaces!

Contents of Terraform Workspace [Image by Author]

Note: Variables & Persistent storage are not compulsory if just entry-level scripts are prepared in Terraform, but they are highly recommended to use. But in production-grade scripts, they are highly used.

A scenario where the Terraform Workspace can/will be used:

  1. Developer
  2. Pre-Production
  3. Production

But if the workspaces are used in the Terraform, then very easily this hectic management task can be eliminated, as workspaces provide us a way to switch on the workspace/environment on which we are working.

Terraform Modules!

  1. Networking Requirements like VPC in AWS, Virtual Networks in Azure, etc
  2. Developer requirements like ALB, BeanStalk, Lambda in AWS, Traffic Manager, WebApps in Azure.
  3. Database Requirements like RDS in AWS, Azure SQL Database in Azure.
  4. Security Perspective like Security Group & IAM in AWS, Active Directories, policies in Azure.
  5. CDN services like CloudFront in AWS, CDN in Azure.

How Modules can be used / What are the benefits of using the Modules?

  1. Reusable codes in the different apps/work/workspaces requiring the same basic requirements.
  2. To serve the purpose of creating an isolated entity for any purpose in provisioning.
  3. Better Infrastructure Management than writing all the code again & again.
  4. Promotes Open Source development and helps the community as modules can be published by anyone on Terraform Registry, & from there they can be used by anyone.
  5. Promotes Standardization.

How Modules & Workspaces are related?

Relation between Modules & Workspaces [Image by Author]



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store