image
hands-on labSimplifying Terraform Configurations Using Dynamic Blocks
Beginner
40m
16
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Lab steps
Deploying AWS Resources Using Dynamic Blocks
Lab description

Applying the software development principle of DRY (Don't Repeat Yourself) is considered a best practice when using Terraform. For example, multiple instances of the same resource can be created using the for_each or count meta-arguments.

Some resource types include repeatable nested blocks representing separate resources or attributes that are embedded within the resource. These nested blocks can be defined using the dynamic block type, which can further improve the maintainability of your Terraform template.

In this lab, you will refactor a Terraform template to use dynamic blocks. You will also learn how dynamic blocks differ from Terraform meta-arguments.

Learning objectives

Upon completion of this intermediate-level lab, you will be able to:

  • Identify when to use dynamic blocks in Terraform
  • Refactor an AWS configuration to use dynamic blocks

Intended audience

  • Individuals studying for the HashiCorp Certified: Terraform Associate exam
  • Cloud Engineers
  • DevOps Engineers

Prerequisites

Familiarity with the following will be beneficial but is not required:

  • Terraform Loops

The following content can be used to fulfill the prerequisites:

Environment before
environment before preview
Environment after
environment after preview
About the author
Avatar
Jun Fritz
Cloud Labs Developer
Students
34,114
Labs
89
Courses
1
Learning Paths
6

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics