All hands-on labs

Premium Hands-on labbeginnerAWS

Terraform Variables and Outputs

Split a single-file S3 bucket configuration into provider, variables, main, and output files, then deploy and destroy it to check that nothing broke.

  • 8 guided tasks
  • Terminal in the browser

Scenario

This lab is part of the Terraform on AWS course. It continues the Working with regional services in AWS lesson, which ends with the S3 bucket main.tf file that you'll split into several files here. If you completed that lesson in your own terminal, open its directory and continue to the next task.

Until now, we've been writing our code into a single file, main.tf. While this works, it's not best practice. Best practice would be to take advantage of the other file types that Terraform offers which will ultimately make our code easier to understand and more manageable. In this lab, you'll split the S3 bucket code into these files, deploy it to check that nothing broke, and then destroy it.

What you will learn

  • Split a single-file Terraform configuration into provider, variables, main, and output files.
  • Replace hard-coded values with variables that other files reference.
  • Output S3 bucket attributes after a deployment.
  • Deploy and destroy the updated code to check that nothing broke.
Hands-on lab

Terraform Variables and Outputs

Included in Cybr Premium.