Skip to content

Latest commit

 

History

History
132 lines (79 loc) · 3 KB

File metadata and controls

132 lines (79 loc) · 3 KB

Lab: Taint and Debugging

Help for the VSCode editor.

  1. Which environment variable should be used to export the logs to a specific path?

    Refer to the documentation

    Reveal

    TF_LOG_PATH

  2. Can you export the debug logs from terraform just by setting TF_LOG_PATH environment variable and providing a path as the value to this variable?

    Refer to the documentation

    Reveal

    `NO'

    This variable sets the path for log files to be written. It has no effect unless TF_LOG is also set.

  3. We have a configuration directory called /root/terraform-projects/ProjectA. Enable logging with the log level set to ERROR and then export the logs the path /tmp/ProjectA.log.
    1. Set the environment variables

      Reveal
      cd /root/terraform-projects/ProjectA
      export TF_LOG=ERROR
      export TF_LOG_PATH=/tmp/ProjectA.log

      This variable sets the path for log files to be written. It has no effect unless TF_LOG is also set.

    2. Deploy

      terraform init
      terraform apply
      
  4. Which Log Level provides the most details when you run terraform commands?

    Refer to the documentation

    Reveal

    TRACE

  5. Now navigate to /root/terraform-projects/ProjectB. We already have a main.tf file created for provisioning an AWS EC2 instance

    Apply the resource

    cd /root/terraform-projects/ProjectB
    terraform init
    terraform apply
  6. Now, try running a terraform plan again. What is the effect?
    terraform plan

    Note what will happen from the output of the above

  7. Why is the resource called ProjectB being replaced?

    Again, examine the plan output. The reason for replacement will be found there.

    Reveal

    Reource is tainted

  8. Untaint the resource called ProjectB so that the resource is not replaced any more.
    Reveal
    terraform untaint aws_instance.ProjectB
    

    You can run terraform plan again the verify.