Course outlines for learning terraform.
expected time | requirements |
---|---|
120 minutes | A computer with Terraform installed, terraform knowledge. |
Goal: Write Terraform code for the cloud provider of your choice.
We’ll try some experiments. Some of these experiments take some time to finish, maybe you’ll run into issues. Don’t worry, share your screen to troubleshoot together.
Pick the easiest use case first.
Use cloud-init in the Terraform code (hint to do these things on a newly generated system:
mkpasswd --method=SHA-512 --rounds=4096
)sudo: ALL=(ALL) NOPASSWD:ALL
).Update the software on the instance. (hint.)
Add a resource manually, import and try to expand the memory.
How do you organize variables so that you have the least amount of locations to define variables, but keep flexibility.
For example:
location
where resources are provisioned is fixed for the company.size
of a VM has a suggested value, but can be overwritten.name
of a VM should be given by the user of the module.A list of subscriptions (and their id), where different environments use specific subscriptions.
Write Terraform code to:
+--- loadbalancer1 ---+
| Listening on ports: |
| - port 80 |
| - port 443 |
+---------------------+
| |
V V
+--- instance1 ---+ +--- instance2 ---+
| Linux: | | Linux: |
| - apache | | - apache |
+-----------------+ +-----------------+
The image above leaves some room for interpretation. If you’re done, you should be able to:
instance1
or instance2
.You’ve written Terraform code, see what items can be moved to a module and rewrite your code to use these modules.