A Terraform Example
The following pages will introduce you to the process of creating a Terraform configuration for deploying components on the Jetstream2 cloud computing platform. Each page builds upon the material covered in previous pages, so you are strongly encouraged to work through them in order. Most pages contain a mixture of content describing aspects of Terraform, the HashiCorp Configuration Language (HCL), Terraform's OpenStack provider, and deployment to Jetstream2.
Each page of the section will ask you to download one or more Terraform configuration (.tf) files. The content of the example configuration was broken down into these individual files for instructional clarity only. The entire content could just as easily be placed into a single .tf file, as Terraform reads all of the .tf files in a configuration folder before it begins processing. But it is a common practice to put related configuration elements together in a suitably named file (such as main.tf or variables.tf).
The complete set of deployment files (not including those for provisioning) is available as a zip file for simpler downloading. However, it is strongly recommended that when working through the examples you only download the individual files as directed.
If you complete the steps on all pages of this example, the result will be a deployment of three instances (one leader and two followers) on Jetstream2, along with all supporting resources that are needed for their use. This example does not perform any specific function, its purpose is purely educational. But once this foundational information is understood, you will be in a good position to explore other Terraform functionality and perhaps adapt examples from other sources to meet your specific needs. The subjects covered in each of this section's pages are:
- Creating Security Groups, HCL Syntax. We introduce basic aspects of the HCL syntax while defining a security group that will be deployed to Jetstream2.
- Creating Key Pairs, Using HCL Variables. The use of HCL variables is described while we add a key pair (your key pair!) to the configuration.
- Creating Networks, Using Internal References. References to attributes of other Terraform objects are used when creating a private network in the configuration.
- Creating Instances. We tie together the previous components when creating an instance, then tear it all down.
- Creating Multiples. HCL syntax variations are introduced to show how easy it is to deploy multiple similar objects.
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)