Part 7 - Apstra Templates in Terraform
Create template in Terraform.
Let’s now create the templates inside of Apstra’s design system. To do this we will use another Terraform file and our existing new Racks that we have created in the previous steps.
You may want to refer to the following page in the step by step GUI based lab guide for reference: Lab Guide 1 - Juniper |
-
Create a
template.tf
file in the working directory. -
Populate the file with the following text content.
# Create a template using previously looked-up (data) spine info and previously # created (resource) rack types. resource "apstra_template_rack_based" "lab_guide" { name = "apstra_junos" asn_allocation_scheme = "unique" overlay_control_protocol = "evpn" spine = { count = 2 logical_device_id = data.apstra_logical_device.lab_guide_switch.id } rack_infos = { (apstra_rack_type.lab_guide_esi.id) = { count = 1 } (apstra_rack_type.lab_guide_single.id) = { count = 1 } } }
-
Now review what terraform wants to create with the
terraform plan
command, output follows. Note here that I am no longer using theterraform plan
but theterraform apply
command to review the creation and then executing with the inputyes
bwester@bwester-mbp playground % terraform apply data.apstra_logical_device.lab_guide_switch: Reading... data.apstra_logical_device.lab_guide_servers["single_homed"]: Reading... data.apstra_logical_device.lab_guide_servers["dual_homed"]: Reading... apstra_asn_pool.lab_guide: Refreshing state... [id=a93ff130-8aaf-4759-9dea-b71b62263df1] apstra_ipv4_pool.lab_guide: Refreshing state... [id=29a85b6c-3879-4b8c-8911-85d2116489ae] data.apstra_logical_device.lab_guide_servers["dual_homed"]: Read complete after 1s [id=AOS-2x10-1] data.apstra_logical_device.lab_guide_switch: Read complete after 1s [id=virtual-7x10-1] data.apstra_logical_device.lab_guide_servers["single_homed"]: Read complete after 1s [id=AOS-1x10-1] apstra_rack_type.lab_guide_single: Refreshing state... [id=trhgpkk7tu27mbdvtklh9a] apstra_rack_type.lab_guide_esi: Refreshing state... [id=h2-uvp1ftmuhr4cfsbkqrw] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # apstra_template_rack_based.lab_guide will be created + resource "apstra_template_rack_based" "lab_guide" { + asn_allocation_scheme = "unique" + id = (known after apply) + name = "apstra_junos" + overlay_control_protocol = "evpn" + rack_infos = { + "h2-uvp1ftmuhr4cfsbkqrw" = { + count = 1 + rack_type = (known after apply) }, + "trhgpkk7tu27mbdvtklh9a" = { + count = 1 + rack_type = (known after apply) }, } + spine = { + count = 2 + logical_device = (known after apply) + logical_device_id = "virtual-7x10-1" + tags = (known after apply) } } Plan: 1 to add, 0 to change, 0 to destroy. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes apstra_template_rack_based.lab_guide: Creating... apstra_template_rack_based.lab_guide: Creation complete after 3s [id=a33171d1-021c-47ac-b929-ab6b693c6a69] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. bwester@bwester-mbp playground %
-
Feel free to inspect the creation of the Template through the UI, you can navigate to Design → Templates.