-
What are Terraform Workspaces? Overview with Examples
- In this example, I have used the AWS S3 bucket as the remote backend.
- When we look at the contents of the Terraform state S3 bucket, apart from our default terraform.tfstate file, we can see that a new directory named “env:/” is created, within which another directory with the name of our workspace (test_workspace) is created. A new terraform.tfstate file is maintained at this location.
-
Looking closely, the size of the default state file is considerably larger than that of the custom workspace-specific state file. This shows that the new state file is created, but it does not hold any information from the default state file. This is how Terraform creates an isolated environment and maintains its state file differently.
The contents of the test_workspace state file before running
terraform applyare shown below:
-
-
-
- “infrastructure state described by the terraform DSL (Domain Specific-Language) configuration files”: This is the outcome of a devops codifying the infrastructure in a bunch of files
- “actual infrastructure state”: This is the actual infrastructure, which is the result of using terraform to deploy the infrastructure codified in the “terraform DSL configuration files” from the previous step
- “terraform state file”: This an artifact generated by the terraform deployment. It holds information that is otherwise not available anywhere else; it maps the infrastructure components codified in the “terraform DSL configuration files” to the actual manifested infrastructure components. This is usually stored in central store, e.g., AWS S3, etc., accessible to all terraform users so that everyone sees the same state, and it can be locked to prevent simultaneous changes, to avoid state corruption.
When you practice infrastructure-as-code (IaC), e.g., using terraform, there are 3 types of “infrastructure state”
- Comparing ‘terraform plan/apply -refresh-only (refresh)’, ‘terraform plan’, ‘terraform apply’ and their impact
-
-
What does "~>" mean in terraform required_providers version? - Stack Overflow
-
~>: Allows only the rightmost version component to increment. For example, to allow new patch releases within a specific minor release, use the full version number: ~> 1.0.4 will allow installation of 1.0.5 and 1.0.10 but not 1.1.0
-
diigo.to.shak.blogspot.dailiy. 03/29/2024
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment