Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
Terraform allows configuring its behavior using various environment variables. These variables control logging, input handling, workspace management, and registry discovery settings. Below is a detailed guide with use cases and examples.
Description: Defines patterns for files and directories that Terraform should ignore.
Example:export TF_IGNORE='*.bak'
2. Terraform Predefined and Meta Variables Reference
Terraform provides a set of predefined variables that allow access to system metadata.
Built-in Variable
Description
terraform.workspace
Returns the current workspace name.
path.module
Returns the current module path.
path.root
Returns the root module path.
path.cwd
Returns the current working directory.
count.index
Current index in a count loop.
each.key, each.value
Current key-value in a for_each loop.
var.<variable_name>
References an input variable.
local.<local_variable>
References a local variable.
module.<module_name>.<output>
Retrieves an output from a child module.
self
Refers to the current resource instance.
depends_on
Explicitly sets dependencies between resources.
env.<ENV_VAR>
Retrieves environment variables from the shell.
Example Usage:
output "workspace" {
value = terraform.workspace
}
output "current_path" {
value = path.module
}
By understanding and utilizing these Terraform environment variables and predefined expressions, users can optimize their infrastructure as code (IaC) workflows efficiently.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:
DevOps Certification - Learn the fundamentals and advanced concepts of DevOps practices and tools.
SRE Certification - Gain expertise in Site Reliability Engineering and ensure reliability at scale.
MLOps Certification - Dive into Machine Learning Operations and streamline ML workflows.
AiOps Certification - Discover AI-driven operations management for next-gen IT environments.
Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.