Skip to content

Latest commit

 

History

History
108 lines (69 loc) · 2.72 KB

07-output-variables.md

File metadata and controls

108 lines (69 loc) · 2.72 KB

Lab: Output Variables

Help for the VSCode editor.

  1. Navigate to indicated directory in the Explorer pane.

  2. Which provider is used by the configuration files in this directory?

    Know that you can determine provider names from the reource type property of a resource block. The type is of the form provider_type.

    Here we can see two distinct resource types:

    • random_uuid
    • random_integer

    From this, we can determine that there is only one provder in use:

    random

  3. Which two resource types are configured in the configuration files?

    In determining the answer to Q2, we've also determined the answer to this question.

  4. Inspect output.tf

  5. Run terraform init, plan and apply to create these resources.
    cd /root/terraform-projects/data
    terraform init
    terraform plan
    terraform apply
  6. What is the value of the output variable called id2 ?

    Note that we can acutally see all the outputs from the terraform apply, however if the screen had been cleared or we were to come back later (in a real environment), we use terraform output command.

    terraform output id2

    The value for id2 will be printed.

  7. What is the value of the output variable called order1 ?
    terraform output order1
  8. We have a new configuration directory located at the path /root/terraform-projects/output. Inspect the configuration files that are created in this directory.

    Note that there is a terraform.tfstate file in this directory (more on this in later lectures). This means that terraform apply has already been run.

    cd /root/terraform-projects/output
    terraform output pet-name
  9. We have just updated the main.tf file in this directory with a new resource block. Add a new output variable...
    • Output Variable Name: welcome_message
    • Value: content of the resource called welcome
    1. Add the output variable block

      Reveal
      output "welcome_message" {
          value = local_file.welcome.content
      }
      
    2. Deploy

      cd /root/terraform-projects/output
      terraform init
      terraform plan
      terraform apply