Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Using Terraform Dynamic Blocks and Built-in Functions to Deploy to AWS

Terraform offers a strong set of features to help optimize your Terraform code. Two really useful features are dynamic blocks, which allow you to generate static repeated blocks within resources in Terraform; and built-in functions, which help you manipulate variables and data to suit your needs and help make your Terraform deployments better automated and more fault resilient.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 1h 15m
Published
Clock icon Mar 29, 2021

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Check Terraform Status

    1. Check that Terraform is installed and functioning properly using the terraform version command.

      Note: You do not need to worry about the version of Terraform being used in this lab.

  2. Challenge

    Clone Terraform Code and Switch to Proper Directory

    1. The Terraform code required for this lab has already been cloned onto the provided VM.
    2. Switch to the section7-HoL-TF-DynBlocks-Funcs directory where the code is located to perform the remaining tasks.
    3. View the files in the directory.
  3. Challenge

    Examine the Code in the Files

    1. Closely examine the code in the main.tf file.
    2. Review the contents of the variables.tf, script.sh, and outputs.tf files.
  4. Challenge

    Review and Deploy the Terraform Code

    1. Format the code using the terraform fmt command.
    2. Initialize the working directory and download the required providers.
    3. Validate the code using the terraform validate command.
    4. Review the actions that will be performed when you deploy the code using the terraform plan command.
    5. Deploy the code with the terraform apply --auto-approve command.
  5. Challenge

    Test Out the Deployment and Clean Up

    1. View the outputs of the deployment within the CLI immediately upon successful execution.
    2. Verify that your resources were created as intended in the AWS Management Console.
    3. Verify that the webserver is up and running using the URL generated as an output.
    4. Tear down the infrastructure using the terraform destroy --auto-approve command.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans