Skip to content

Latest commit

 

History

History
125 lines (77 loc) · 3.78 KB

File metadata and controls

125 lines (77 loc) · 3.78 KB

Lab: Terraform Commands

Help for the VSCode editor.

  1. Which command can be used to create a visual representation of our terraform resources?

    terraform graph

  2. We have created a configuration directory /root/terraform-projects/project-shazam. The configuration file inside will be used to create an RSA type private key and then a certificate signing request or a csr using this key.

    However, there is an error with the configuration. Use the terraform validate command, troubleshoot, and fix the issue.

    You don't have to create the resources yet! You only need to fix the errors reported by terraform validate.

    1. Get details about the error

      cd /root/terraform-projects/project-shazam
      terraform validate

      It tells us the error with the private_key resource

    2. Use the documentation to determine what the correct attribute name should be.

    3. Try validating again

      terraform validate
      

      Success!

  3. Great! If you completed the previous question correctly, terraform validate should have passed! Now run terraform plan and generate a configuration plan.
    terraform plan
    

    YES

  4. Now, try creating the resources with a terraform apply.
    terraform apply
    

    NO

  5. Information only

  6. The error in the configuration is inside the resource block for the tls_cert_request type resource

    NOTE: The question statement about the cause of the error is currently incorrect, as there has been a change to the tls provider since the questions were written. To pass this question, do the following

    • Remove the line rsa_bits = 4096
  7. Now format the main.tf file into a canonical format.
    terraform fmt
  8. Now, navigate to the directory /root/terraform-projects/project-a. We have already created the resources specified in this configuration.
    1. Navigate to the given directory in the Explorer pane
    2. Open the file terraform.tfstate
    3. Find the filename attribute and note its value for the answer.
  9. In these terraform labs, we have used multiple providers so far. But, what are providers?
    • Providers are plugins for the terraform program.
    • terraform init downloads these based on the content of your configuration files.
    • Other terraform commands which process your configuration load these plugins and call the code within them to process each resource specific to a given provider.
  10. Which one is a valid sub-command of the terraform providers command?

    A sub-command is the value that comes next on the command line.

    To list valid sub-commands of terraform providers do

    terraform providers --help
  11. A new configuration directory /root/terraform-projects/provider has been created. We have already run the terraform init command.
    Now check the provider plugins that have been downloaded from the command line utility

    Running terraform providers without a sub-command will give us the answer.

    cd /root/terraform-projects/provider
    terraform providers