- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Parameterize Infrastructure Configurations Using Terraform Variables and Outputs
In this lab, you'll practice parameterizing infrastructure configurations using Terraform variables and outputs to transform static configuration values into reusable, environment-driven inputs and outputs. When you're finished, you will have successfully declared and used typed input variables, applied expressions and built-in functions, demonstrated variable precedence, and produced sensitive and non-sensitive outputs.
Lab Info
Table of Contents
-
Challenge
Access the Terminal
- Use the Lab Credentials and Instant Terminal to log into the terminal.
- Verify the Terraform status.
-
Challenge
Define Typed Input Variables with Default, Required, and Sensitive Values
- Set up the project directory and create Terraform configuration files with providers.
- Define input variables of various types, with default, required, and sensitive values.
- Initialize the workspace and run terraform plan to see how variables are used.
-
Challenge
Use Expressions and Functions to Create Dynamic Values
- Construct dynamic values using interpolation and template syntax.
- Use functions (
length,join,lookup,upper,format) to transform data. - Use conditional (ternary) expressions for environment-aware configs.
-
Challenge
Explore Variable Precedence with Variable Files and CLI Overrides
- Create
terraform.tfvarsand environment-specific variable files (for example,dev.tfvarsandprod.tfvars). - Override variables using
-varand-var-filefrom the CLI. - Apply configs with different variable sources to verify precedence.
- Create
-
Challenge
Produce and View Sensitive and Non-Sensitive Outputs
- Define outputs referencing resource attributes and computed values.
- Mark outputs as sensitive to hide confidential data.
- Retrieve outputs using terraform output, including sensitive ones with
-json.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.