Skip to content

Latest commit

 

History

History
124 lines (79 loc) · 4.42 KB

01-terraform-providers.md

File metadata and controls

124 lines (79 loc) · 4.42 KB

Lab: Terraform Providers

Help for the VSCode editor.

  1. We have a new configuration directory located at the path /root/terraform-projects/things-to-do. Inspect this directory and find out the number of providers initialized within this directory.

    Konw that when a configuration is initialized with terraform init, a subdirectory .terraform is created by the init process.

    Inspect /root/terraform-projects/things-to-do directory as directed and look for .terraform there. If it doesn't exist, then no providers are initialized.

  2. How about now? How many provider plugins are installed in this configuration directory?

    The .terraform directory now exists. Expand this in the Explorer pane of the VSCode editor, and see that there is an entry
    registry.terraform.io/hashicorp/local/2.3.0/linux_amd64/
    This represents a single provider plugin.

  3. How many configuration files exist in the directory: /root/terraform-projects/things-to-do ?

    Configuration files are genrally files with a .tf file extension. Count them.

  4. How many resources are configured in this configuration directory?

    Count all the resource blocks used.

    We can see two resources: things-to-do and more-things-to-do

  5. What is the version of the plugin for the local provider that has been downloaded for this configuration?

    Referring back to what we did io Q2, we can see the version as part of the path
    registry.terraform.io/hashicorp/local/2.3.0/linux_amd64/

  6. Now, go ahead and create these resources using terraform!

    Run the following

    cd /root/terraform-projects/things-to-do
    terraform plan
    terraform apply

    Note that we didn't do terraform init here. That was done for you by the setup phase of Q2.

  7. Information only

  8. How many resources are configured within this configuration directory?
    1. Navigate to christmas-wishlist in the Eplorer pane.
    2. Open each of the .tf files in turn
    3. Count the resource blocks in each file.
    4. Sum the results
  9. What is the filename that will be created by the resource called cyberpunk?

    Check the value for filename argument in cyberpunk.tf

  10. Create a new configuration file within the same directory called xbox.tf. This file should make use of the same local_file resource type with the below requirements:
    • Resource name: xbox

    • filename: root/xbox.txt

    • content: Wouldn't mind an XBox either!

      Reveal code
      resource "local_file" "xbox" {
          filename = "/root/xbox.txt"
          content = "Wouldn't mind an XBox either!"
      }

    Now run the following in the terminal

    cd /root/terraform-projects/christmas-wishlist
    terraform init
    terraform plan
    terraform apply
  11. Now, navigate to the directory /root/terraform-projects/provider-a. We have downloaded a plugin in this directory. Identify the name and type of provider.
    1. You can look in the .terraform directory beneath provider-a in the Explorer pane. Here we see linode
    2. Go to https://registry.terraform.io and search for linode, then click on the result.
    3. Now we see that the provder is "by: linode" and that linode is a partner. This means it is "verified". Official providers are "by: Hashicorp".
  12. Now, navigate to the directory /root/terraform-projects/provider-b. We have downloaded a plugin in this directory. Identify the name and type of provider.

    Just as for the previous question, find the provider on terraform registry. Since it is neither by Hashicorp, nor by Ansible themselves and marked as Partner, it is therefore a community provider.

    Anyone with golang programming skills can create a community provider and publish it to the registry.