Professional Documents
Culture Documents
Introduction To Terraform
Introduction To Terraform
19.12.22
Alari Varmann
Knowit Solutions Finland
Agenda
- What is Terraform
- Why Terraform : strengths and drawbacks
- Language specific details:
- State, lock file and backend configuration
- Block types: Data, resource, module
- Input and Output variables; variable precedence
- Deployment paradigms
- Workspace VS Environment (folder-based) approach
- Execution provisioners
- Comparison to alternatives
- Tool examples: Terraformer, Pluralith
- Demo: With ChatGPT; Basics; Homie-related; CI-CD
- Code analyses
About me
On next slide
Originally from Estonia (Tallinn),
living in Finland
Terraform Associate
Install Terraform now
Then you can check out the following:
https://github.com/alarivarmann/terraform_demo_presentation
https://github.com/ExamProCo/Terraform-Associate-Labs
Why Use?
- Number 1 IaC tool in the world
- Cloud provider agnostic
- Has cloud and enterprise tiers
- Open-source (free) with a strong community
- Collaborations with Top cloud providers (on
provider-level)
- Reproducibility, testability, automation
- Reduced development cost
- Supports multi-cloud deployments
- Reduced development and provisioning time
Evaluation Priority
Local variables (locals)
Output == output variable
Both the main program and modules (“sub-program”) can have output variables
module.<MODULE_NAME>.<OUTPUT_VARIABLE_NAME>
Why Use Modules?
Think about this for a second….
- Dev
- Uat / stage
- Prod
Option 1 is a special case of option 3 where the environments are very similar to
each other – no need to create separate folders.
Even if your specific use-case is not described in the following sections, we still recommend attempting to
solve it using other techniques first, and
use provisioners only if there is no other option – in a last resort.
Provisioner Example - what does this code do?
Demos
Find the associated codes here:
https://github.com/alarivarmann/terraform_demo_presentation
https://github.com/ExamProCo/Terraform-Associate-Labs
How to Migrate to Terraform? Import and Terraformer
Quiz. Q1: Passing variables between modules
1) Add an output that references the subnet module and retrieve the value using
module.subnet.subnet_id in the load balancer module
2) References to resources in a module cannot be used within other modules
3) Move the subnet and load balancer resource into the main configuration file so they
can be easily referenced
4) Publish the module to a Terraform registry first
Q1 Answer
Q2 :
What does ´terraform init' command do?
Q2 Answer
Q3 : What does it mean if a resource has ~ in front of it during
running `terraform plan`?
Q3 Answer
Reference & Learning Resources
- Website: https://www.terraform.io/
- Terraform registry: https://registry.terraform.io/?product_intent=terraform
- Online courses