Learn Terraform configuration language by example. Write configurations to manage multiple pieces of infrastructure and iterate over structured data. Deploy and manage related infrastructure by referring to resources in other configurations.
Create an EC2 instance, then use the Terraform Registry to create a security group to make it publicly accessible. Learn how Terraform resources define infrastructure as code through arguments, attributes, and dependencies.
21min
Perform CRUD operations with providers
Learn how Terraform providers interact with resources by serving as a bridge between Terraform and target APIs.
19min
Customize Terraform configuration with variables
Customize infrastructure for a web application with Terraform. In this tutorial, you will use Terraform input variables, including lists, maps, strings, and booleans, to make the configuration for your infrastructure more flexible.
13min
Protect sensitive input variables
Protect sensitive values from accidental exposure using Terraform sensitive input variables. Provision a web application with Terraform, and mark input variables as sensitive to restrict when Terraform prints them out to the console.
10min
Simplify Terraform configuration with locals
Use Terraform local values to simplify your configuration and avoid duplication of reused expressions.
10min
Output data from Terraform
Use output values to export data about the resources Terraform manages. Hide sensitive output values.
14min
Query data sources
Use a data source to configure an EC2 instance with an appropriate AMI for the current region. Use a remote state data source to share data between Terraform projects and to support multiple availability zones.
10min
Create resource dependencies
Create an implicit dependency between an EC2 instance and its Elastic IP using variable interpolation. Create explicit dependencies on an S3 Bucket and SQS Queue with depends_on. Learn how Terraform creates independent resources in parallel.
10min
Manage similar resources with count
Manage similar Terraform resources using the count argument. Create a VPC with a load balancer and EC2 instances. Then use count to manage a configurable number of similar AWS EC2 instances across multiple subnets.
15min
Manage similar resources with for each
Provision similar infrastructure components by iterating over a data structure with the for_each argument. Duplicate an entire VPC including a load balancer and multiple EC2 instances for each project defined in a map.
12min
Perform dynamic operations with functions
Use templatefile and lookup functions to generate dynamic user data for an EC2 instance and find a region-specific AMI.
11min
Create dynamic expressions
Make your Terraform configurations more dynamic and reusable with expressions. Use locals to assign expressions to variables for reuse, conditionals to declare if/then scenarios, and the splat expression to return attributes from complex value types.
11min
Lock and upgrade provider versions
Manage your provider versions using the dependency lock file. Use version constraints to filter provider versions compatible with your configuration. Update your lock file to use a new provider version.
15min
Troubleshoot Terraform
Interpret and fix a Terraform configuration with common configuration language errors and deploy an EC2 instance with security groups in AWS. Learn best practices for logging application errors and reporting bugs.
10min
Manage Terraform versions
Update an existing configuration to work with a newer version of Terraform. Use the required_version setting to pin the Terraform versions for your projects. Manage different versions of Terraform across your team.
14min
Use configuration to move resources
Use the configuration-driven workflow to change Terraform resource IDs. Refactor configuration to move resources into modules using the `moved` block.
16min
Validate modules with custom conditions
Add condition blocks to a module that deploys an application in an AWS VPC to validate that DNS and EBS support are enabled, and that the appropriate number of subnets are configured.
17min
Customize modules with object attributes
Refactor a local module to organize related attributes with objects and make some attributes optional for module users.
14min
Use checks to validate infrastructure
Use check blocks to define and evaluate assertions about your environment and resources.
10min
Write Terraform Tests
Write tests to validate the behavior of your module configuration.