Part 1 - Intro to Terraform & Apstra
Estimated Time: 60 minutes.
If you are comfortable with Terraform you may want to skip to section 2 of the lab. |
What is Terraform?
Terraform is an infrastructure as code toolset that can be used to provision and manage all (everything from servers, application delivery controllers, firewalls, and much more!) of your infrastructure throughout its lifecycle. Terraform was created by HashiCorp and is open source. Users define and provide data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL)
Terraform’s primary function is to create, modify, and destroy infrastructure resources to match the desired state in a Terraform configuration.
Would you like more information in a video format? Take a look at this video which is a quick intro to Terraform.
Terraform Fundamental Concepts
Terraform manages resources with Providers.
Providers
Providers are used to enable interaction with various APIs and services. These providers are configured in the Terraform configuration code. The provider we will be interacting with in the lab is the Juniper Apstra Terraform Provider.
Declarative vs Imperative
The Terraform language is declarative, describing an intended goal rather than the steps to reach that goal.
Imperative: Your car is dirty, and you then need to go through all of the detail steps to clean the car and make sure you follow the correct procedure.
Declarative: The car should be clean.
Here is a great video that may help you to realize the value of Declarative vs Imperative.
Apstra Cloud Lab with Terraform
We will be using an existing Apstra CloudLabs environment to create our terraform lab. To do this we will first start up a topology, and take it from there. Here are the steps we will follow to complete the tasks of setting up a blueprint with Terraform & Apstra.
Terraform Resources
Terraform uses resources to define the desired state. These resource blocks describe infrastructure objects.
An example of a resource block in the Terraform Apstra provider may be something like:
resource "apstra_ipv4_pool" "lab_guide" {
name = "apstra-pool"
subnets = [
{ network = "4.0.0.0/24" },
{ network = "4.0.1.0/24" },
]
}
We will be exploring much more about resources in the next lab sections.
The Apstra Terraform Provider
We have created our own Apstra Terraform Provider for your use. It can be found at the following URL in Hashicorp’s Provider Registry:
You should be able to find the documentation for the Provider there. Its strongly suggested to review the Provider, and within the provider documentation you will find certain key information to using the Provider with Apstra.