2. Outline
• Configuration management vs. Server templating vs. Server provisioning
• Overview of Terraform
• Examples of using Terraform
• Server provisioning and configuration
• Kubernetes cluster provisioning
• Demo: create a Kubernetes cluster
• Conclusion
8. 8
Resource orchestration and provisioning
• Provides resource provisioning and
configuration, as well as ...
• Immutable infrastructure
• Terraform is an example of resource
orchestrator and provisioner
9. 9
Overview of Terraform
• Terraform supports resource provisioning and
configuration in multiple cloud providers
• Azure
• AWS
• Google Cloud Plaform
• Terraform provides a single language, the
Terraform laguage, to interact in an uniform way
with multiple cloud APIs
11. 11
Terraform Language
• The Terraform language is a JSON-like Domain Specific
Language (DSL), using the HCL syntax, to specify
resources and their attributes
• The resources supported are representations of the
services offfered by the cloud provider
• Examples of resources
• Virtual Machines
• Disks
• Networks
• Container clusters
12. 12
Example #1: server provisioning & configuration
• Provision and configure a virtual machine (VM) instance
in the AWS cloud
• The resource type in AWS for a virtual machine is
aws_instance
• The user_data attribute of the VM instance can be used
to configure the instance
13. 13
• Terraform provisions a server off a VM image, and allows
to configure server-specific software using cloud provider-
specific mechanisms such as user_data for AWS
Example #1 continued 1
14. 14
• Terraform supports variables, both statically and dynamically defined,
e.g., the public_ip attribute of the example instance of the
aws_instance resouce type, i.e., ${aws_instance.example.public_ip}
Example #1 continued 2
15. 15
Example #2: Kubernetes cluster provisioning
• Provision and configure a Kubernetes cluster in the
Google Cloud Platform (GCP)
• The resource type in GCP for a kubernetes cluster is
google_container_cluster
• The resource type has as prefix the cloud provider
name, in this case google
• Cluster attributes can be required or optional:
• zone – required
• initial_node_count - optional
16. 16
Example #2: continued 1
• For modularity, the code can be divided in multiple files
• Main configuration: main.tf
• Provider configurations: provider.tf
• Variable definition: variables.tf
17. 17
Example #2: continued 2
• Define the cloud provider
• The credentials are obtained by creating a service account,
e.g. in the Google Cloud UI
22. Conclusion
• Resources offered by different cloud providers are different
• Databases, caches, load balancers
• Since resources are cloud-provider specific, Terraform code is cloud-
provider specific
• Terraform provides a language and toolset for creating resources in
multiple clouds