SlideShare a Scribd company logo
Live
Terraform in 45 min
By Brainboard’s team
Chafik, CEO & Founder
@Brainboard
Engineer, +15 years of experience.
Former CTO @Scaleway
Brainboard
Visually build & manage cloud infrastructures.
Objective of the training
✅ Learn how to manage cloud infrastructures with Terraform.
No theory
What you will learn
1. How Terraform works
2. Syntax (HCL)
3. Configuration
4. Resources
5. Data sources
6. Modules
7. Inputs (variables) & outputs
8. Functions
9. Scenarios / use cases
10. How to handle post provisioning actions
IaC - Infrastructure as Code
Applying code principles into the infrastructure.
Life with code
After
Specs Delivered
infrastructure
Code
Deployment
workflow
Before
Design Code Test Review Validate
Document
Few minutes to deploy
Days, weeks or months
How Terraform works ⚙️ mechanics
Installation: binary or docker image
Use: CLI
terraform ${action(s)}
Language: HCL
using Terraform = writing HCL code (you can use json)
How: describing the final cloud architecture state you want to achieve. Not the how-
to.
Wrapper on cloud providers APIs:
1. Terraform the binary
https://github.com/hashicorp/terraform
1. Cloud provider: providing a set of resources (not only cloud providers) AWS,
Azure, Datadog…
https://github.com/hashicorp/terraform-provider-aws → https://registry.terraform.io/providers/hashicorp/aws/latest/docs
How Terraform works ⚙️ mechanics
Some of the most used subcommands:
terraform init
terraform apply
terraform destroy
terraform validate
terraform fmt
terraform state list | show
How Terraform works ⚙️ mechanics
Refresh
Save
.tf files
Saved plan
Configuration files
tfstate file
Cloud providers
(APIs)
Cloud
infrastructure State
to achieve
Compare
changes
Preflight
checks
create
destroy
destroy & recreate
update
Syntax (HCL) 📝
Declarative → describing the final state
Supported files: .ft and .tf.json
Combine all files as a single document (root module, you are always using modules)
Everything is a block
<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" { #comment
# Block body
// comment
<IDENTIFIER> = <EXPRESSION> # Argument
}
Identifiers: letters, digits, underscores (_), and hyphens (-).
The first character must not be a digit.
Styling: terraform fmt
Configuration 📌
Types of configuration:
1. Terraform:
Version
Env variables
Remote backend
1. Cloud provider
Credentials / authentication
Specific params
Versions
1. The environment that will provision the infrastructure using Terraform
How files & folders are organized 🔥
- Files
- Environments
Configuration 📌
Goal: Having a structure that eases maintenance (for all teams) + readability
Obvious ones:
variables.tf
outputs.tf
main.tf
providers.tf
versions.tf
Terraform files: KISS it (Keep It Simple, Stupid)
- Infrastructure logic
database.tf → database / main.tf
compute.tf → compute / main.tf
network.tf → network / main.tf
loadbalancer.tf → loadbalancer / main.tf
- Application logic
backend.tf → backend / main.tf
frontend.tf → frontend / main.tf
microservice1.tf → microservices |- microservice1.tf
microservice2.tf → |- microservice2.tf
Configuration 📌
Environments:
- Git branches (infra repo)
- Terraform workspaces
- Separate folders
- Brainboard environments
App / Infra
Dev Production
Staging
Configuration 📌
Considerations:
- How to promote architectures from one environment to another?
- How to share / scope variables?
- How to manage secrets?
- How to manage cloud provider credentials?
- How tfstate files are managed?
- Who is authorized to do changes?
Questions 🙋♂️🙋♀️
Resources 🧱
Resources = cloud infrastructure object with given settings.
resource <NAME> {
# Configuration
}
2 categories:
1. Belonging to a cloud provider: provided by the cloud provider plugin.
Format: cloud_provider.name_of_resource
aws_vpc, aws_subnet, azurerm_resource_group, google_cloudfunctions_functions
1. Native (Hashicorp providers)
random_password
local_file
dns
https
null_resource
Providers ▶️
- It’s a plugin, downloaded during terraform init
- It provides both resources and data sources
- You can pin the version and provide the source to fetch the provider
👉 Terraform assumes latest as the version if not provided and namespace
hashicorp/provider_name
⚠️ Third-party providers may have confusing namespace
jfrog/artifactory
- Support alias for specific configurations
- required_providers
Resources 🧱
Type (provider)
Cloud information
Meta argument
Post deployment
Anatomy
Actions Attributes
- Create
- Destroy
- Update
- Destroy &
recreate
- Id
- ARN
- Specific
Resources 🧱
Execution: parallel creation of resources, that’s why you may need to specify
dependencies
Exported attributes: resources has attributes, some of them are accessible.
<RESOURCE TYPE>.<NAME>.<ATTRIBUTE>
Meta argument
depends_on
count (index) it’s an array starting at 0
for_each (each) it’s key, value for every attribute
provider
lifecycle
Data sources
Usage: provide information defined outside of Terraform.
data.<DATA TYPE>.<SOURCE>.<ATTRIBUTE>
It can be local actions. For e.g. local_file
Support dependencies
Has meta argument
Questions 🙋♂️🙋♀️
Modules
What: containers of resources
Root: always there
Childs: local or remote from public or private registry
It’s also a resource, so a block, it supports meta argument 😀
module <NAME> {
# Block
}
Source: mandatory argument.
Version: can be provided for pinning.
Output: make the encapsulated resources' information accessible.
Questions 🙋♂️🙋♀️
Live
Learn Terraform in 45 min
By Brainboard’s team
(Focus: Variables)
Objective of the training today
✅ Learn everything about Terraform variables and how to use them.
What you will learn
1. How variables works and their types
2. CLI & environment variables
3. Locals
4. How to use variables
5. Variables in CI/CD
6. Secrets
7. Best practices
Variables & locals
Input: means variables
It’s… a block 😀
variable <NAME> {
# Block
}
Arguments
type can be:
1/ string, number, bool.
2/ list, tuple, map, object, set.
3/ any 😀
👉 you can combine types
default if present, the variable is optional
description
validation conditions to accept the variable
sensitive hidden from logs & outputs
nullable can be null or not?
💡Tips
- Start with the simplest form possible and add
constraints organically.
- Use Terraform function
- sensitive is also a Terraform function
Questions 🙋♂️🙋♀️
Variables’ values
Where do we put the values then?
1. In a file:
- terraform.tfvars (terraform.tfvars.json)
- *.auto.tfvars (*.auto.tfvars.json)
2. Command line “-var=’value_1’”
3. Environment variables TF_VAR_*
💡Tips
- Avoid vars in command line if possible
- Pick one method and use it, don’t mix
- Usually *.tfvars is the best way
4. Internal variables:
module.<NAME>.<OUTPUT>
path.module
count.index
each in for_each
Precedence
Env vars
terraform.tfvars
*.auto.tfvars
Command line
💪💪💪💪
💪💪💪
💪💪
💪
Variables in CI/CD
Best practices:
- Never put the values of variables in the *.tf
- Never commit the *.tfvars to git
- Using terraform.tfvars or *.auto.tfvars in your workflow is more useful for
complex structures
- Naming variables is extremely important
variables.tf = containers of the variables vs *.tfvars that are real values
Locals
local: is more like an alias to an expression (that may include variables)
It’s… a block 😀 but a whole block
locals {
cidr = var.cidr
}
💡Tips
- Are extremely flexible compared to vars
- Use it as an alias to access repeatedly the same expression
- Central place for repeated expressions
- Don’t confuse them with variables
Secrets
Secrets should be treated as secrets:
- Lifecycle
- Fetched from an external source
- Should be revoked easily
- Blast radius of a secret
- Secrets ≠ variables
- It’s better to use a vault (Vault, KMS, Azure Key Vault…)
- Use Terraform vault provider to use them
Join our Slack Community 🙋♂️🙋♀️
https://join.slack.com/t/brainboard-community/shared_invite/zt-19hmgmc92-MixDFmaADwxexAPSa5N~pg
Brainboard
Visually build & manage cloud infrastructures.

More Related Content

PPTX
PPTX
Terraform Basics
PPTX
Introduction git
PDF
Azure Application insights - An Introduction
PDF
Enterprise Architecture - TOGAF Overview
PPTX
AWS Lambda
PPTX
Comprehensive Terraform Training
PPTX
CI/CD Overview
Terraform Basics
Introduction git
Azure Application insights - An Introduction
Enterprise Architecture - TOGAF Overview
AWS Lambda
Comprehensive Terraform Training
CI/CD Overview

What's hot (20)

PPTX
Infrastructure-as-Code (IaC) using Terraform
PDF
Terraform -- Infrastructure as Code
PDF
Terraform
PPTX
Effective terraform
PDF
Terraform
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
PPTX
Building Repeatable Infrastructure using Terraform
PDF
Building infrastructure as code using Terraform - DevOps Krakow
PDF
Best Practices of Infrastructure as Code with Terraform
PDF
Terraform modules and best-practices - September 2018
PDF
PPTX
02 terraform core concepts
PPTX
Terraform modules restructured
PPTX
Introduction To Terraform
PDF
Terraform Best Practices - DevOps Unicorns 2019
PPTX
Final terraform
PDF
Introduce to Terraform
PPTX
MeetUp Monitoring with Prometheus and Grafana (September 2018)
PDF
Terraform: An Overview & Introduction
PPTX
Terraform
Infrastructure-as-Code (IaC) using Terraform
Terraform -- Infrastructure as Code
Terraform
Effective terraform
Terraform
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
Building Repeatable Infrastructure using Terraform
Building infrastructure as code using Terraform - DevOps Krakow
Best Practices of Infrastructure as Code with Terraform
Terraform modules and best-practices - September 2018
02 terraform core concepts
Terraform modules restructured
Introduction To Terraform
Terraform Best Practices - DevOps Unicorns 2019
Final terraform
Introduce to Terraform
MeetUp Monitoring with Prometheus and Grafana (September 2018)
Terraform: An Overview & Introduction
Terraform
Ad

Similar to Terraform training 🎒 - Basic (20)

PPTX
Terraform Abstractions for Safety and Power
PPTX
Terraform Best Practices for Infrastructure Scaling
PDF
The hitchhiker's guide to terraform your infrastructure
PPTX
Terraform Modules Restructured
PDF
Terraform + ansible talk
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
PPTX
Terraform day1
PPTX
Terraform day 1
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PDF
Configuration management II - Terraform
PDF
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
PDF
Terraform modules and some of best-practices - March 2019
PPTX
Terraform Modules and Continuous Deployment
PPTX
TensorFlowOnSpark: Scalable TensorFlow Learning on Spark Clusters
PPTX
Introduction to basics of Terraform.pptx
PDF
My Hashitalk Indonesia April 2024 Presentation
PDF
Collaborative Terraform with Atlantis
PDF
Infrastructure as Code with Terraform
Terraform Abstractions for Safety and Power
Terraform Best Practices for Infrastructure Scaling
The hitchhiker's guide to terraform your infrastructure
Terraform Modules Restructured
Terraform + ansible talk
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Terraform day1
Terraform day 1
"Continuously delivering infrastructure using Terraform and Packer" training ...
Configuration management II - Terraform
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Terraform modules and some of best-practices - March 2019
Terraform Modules and Continuous Deployment
TensorFlowOnSpark: Scalable TensorFlow Learning on Spark Clusters
Introduction to basics of Terraform.pptx
My Hashitalk Indonesia April 2024 Presentation
Collaborative Terraform with Atlantis
Infrastructure as Code with Terraform
Ad

Recently uploaded (20)

PPTX
Geodesy 1.pptx...............................................
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Digital Logic Computer Design lecture notes
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
PPT on Performance Review to get promotions
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
OOP with Java - Java Introduction (Basics)
PPT
Project quality management in manufacturing
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Geodesy 1.pptx...............................................
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
CYBER-CRIMES AND SECURITY A guide to understanding
Lesson 3_Tessellation.pptx finite Mathematics
Digital Logic Computer Design lecture notes
CH1 Production IntroductoryConcepts.pptx
PPT on Performance Review to get promotions
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
OOP with Java - Java Introduction (Basics)
Project quality management in manufacturing
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx

Terraform training 🎒 - Basic

  • 1. Live Terraform in 45 min By Brainboard’s team
  • 2. Chafik, CEO & Founder @Brainboard Engineer, +15 years of experience. Former CTO @Scaleway
  • 3. Brainboard Visually build & manage cloud infrastructures.
  • 4. Objective of the training ✅ Learn how to manage cloud infrastructures with Terraform. No theory
  • 5. What you will learn 1. How Terraform works 2. Syntax (HCL) 3. Configuration 4. Resources 5. Data sources 6. Modules 7. Inputs (variables) & outputs 8. Functions 9. Scenarios / use cases 10. How to handle post provisioning actions
  • 6. IaC - Infrastructure as Code Applying code principles into the infrastructure.
  • 7. Life with code After Specs Delivered infrastructure Code Deployment workflow Before Design Code Test Review Validate Document Few minutes to deploy Days, weeks or months
  • 8. How Terraform works ⚙️ mechanics Installation: binary or docker image Use: CLI terraform ${action(s)} Language: HCL using Terraform = writing HCL code (you can use json) How: describing the final cloud architecture state you want to achieve. Not the how- to. Wrapper on cloud providers APIs: 1. Terraform the binary https://github.com/hashicorp/terraform 1. Cloud provider: providing a set of resources (not only cloud providers) AWS, Azure, Datadog… https://github.com/hashicorp/terraform-provider-aws → https://registry.terraform.io/providers/hashicorp/aws/latest/docs
  • 9. How Terraform works ⚙️ mechanics Some of the most used subcommands: terraform init terraform apply terraform destroy terraform validate terraform fmt terraform state list | show
  • 10. How Terraform works ⚙️ mechanics Refresh Save .tf files Saved plan Configuration files tfstate file Cloud providers (APIs) Cloud infrastructure State to achieve Compare changes Preflight checks create destroy destroy & recreate update
  • 11. Syntax (HCL) 📝 Declarative → describing the final state Supported files: .ft and .tf.json Combine all files as a single document (root module, you are always using modules) Everything is a block <BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" { #comment # Block body // comment <IDENTIFIER> = <EXPRESSION> # Argument } Identifiers: letters, digits, underscores (_), and hyphens (-). The first character must not be a digit. Styling: terraform fmt
  • 12. Configuration 📌 Types of configuration: 1. Terraform: Version Env variables Remote backend 1. Cloud provider Credentials / authentication Specific params Versions 1. The environment that will provision the infrastructure using Terraform How files & folders are organized 🔥 - Files - Environments
  • 13. Configuration 📌 Goal: Having a structure that eases maintenance (for all teams) + readability Obvious ones: variables.tf outputs.tf main.tf providers.tf versions.tf Terraform files: KISS it (Keep It Simple, Stupid) - Infrastructure logic database.tf → database / main.tf compute.tf → compute / main.tf network.tf → network / main.tf loadbalancer.tf → loadbalancer / main.tf - Application logic backend.tf → backend / main.tf frontend.tf → frontend / main.tf microservice1.tf → microservices |- microservice1.tf microservice2.tf → |- microservice2.tf
  • 14. Configuration 📌 Environments: - Git branches (infra repo) - Terraform workspaces - Separate folders - Brainboard environments App / Infra Dev Production Staging
  • 15. Configuration 📌 Considerations: - How to promote architectures from one environment to another? - How to share / scope variables? - How to manage secrets? - How to manage cloud provider credentials? - How tfstate files are managed? - Who is authorized to do changes?
  • 17. Resources 🧱 Resources = cloud infrastructure object with given settings. resource <NAME> { # Configuration } 2 categories: 1. Belonging to a cloud provider: provided by the cloud provider plugin. Format: cloud_provider.name_of_resource aws_vpc, aws_subnet, azurerm_resource_group, google_cloudfunctions_functions 1. Native (Hashicorp providers) random_password local_file dns https null_resource
  • 18. Providers ▶️ - It’s a plugin, downloaded during terraform init - It provides both resources and data sources - You can pin the version and provide the source to fetch the provider 👉 Terraform assumes latest as the version if not provided and namespace hashicorp/provider_name ⚠️ Third-party providers may have confusing namespace jfrog/artifactory - Support alias for specific configurations - required_providers
  • 19. Resources 🧱 Type (provider) Cloud information Meta argument Post deployment Anatomy Actions Attributes - Create - Destroy - Update - Destroy & recreate - Id - ARN - Specific
  • 20. Resources 🧱 Execution: parallel creation of resources, that’s why you may need to specify dependencies Exported attributes: resources has attributes, some of them are accessible. <RESOURCE TYPE>.<NAME>.<ATTRIBUTE> Meta argument depends_on count (index) it’s an array starting at 0 for_each (each) it’s key, value for every attribute provider lifecycle
  • 21. Data sources Usage: provide information defined outside of Terraform. data.<DATA TYPE>.<SOURCE>.<ATTRIBUTE> It can be local actions. For e.g. local_file Support dependencies Has meta argument
  • 23. Modules What: containers of resources Root: always there Childs: local or remote from public or private registry It’s also a resource, so a block, it supports meta argument 😀 module <NAME> { # Block } Source: mandatory argument. Version: can be provided for pinning. Output: make the encapsulated resources' information accessible.
  • 25. Live Learn Terraform in 45 min By Brainboard’s team (Focus: Variables)
  • 26. Objective of the training today ✅ Learn everything about Terraform variables and how to use them.
  • 27. What you will learn 1. How variables works and their types 2. CLI & environment variables 3. Locals 4. How to use variables 5. Variables in CI/CD 6. Secrets 7. Best practices
  • 28. Variables & locals Input: means variables It’s… a block 😀 variable <NAME> { # Block } Arguments type can be: 1/ string, number, bool. 2/ list, tuple, map, object, set. 3/ any 😀 👉 you can combine types default if present, the variable is optional description validation conditions to accept the variable sensitive hidden from logs & outputs nullable can be null or not? 💡Tips - Start with the simplest form possible and add constraints organically. - Use Terraform function - sensitive is also a Terraform function
  • 30. Variables’ values Where do we put the values then? 1. In a file: - terraform.tfvars (terraform.tfvars.json) - *.auto.tfvars (*.auto.tfvars.json) 2. Command line “-var=’value_1’” 3. Environment variables TF_VAR_* 💡Tips - Avoid vars in command line if possible - Pick one method and use it, don’t mix - Usually *.tfvars is the best way 4. Internal variables: module.<NAME>.<OUTPUT> path.module count.index each in for_each
  • 32. Variables in CI/CD Best practices: - Never put the values of variables in the *.tf - Never commit the *.tfvars to git - Using terraform.tfvars or *.auto.tfvars in your workflow is more useful for complex structures - Naming variables is extremely important variables.tf = containers of the variables vs *.tfvars that are real values
  • 33. Locals local: is more like an alias to an expression (that may include variables) It’s… a block 😀 but a whole block locals { cidr = var.cidr } 💡Tips - Are extremely flexible compared to vars - Use it as an alias to access repeatedly the same expression - Central place for repeated expressions - Don’t confuse them with variables
  • 34. Secrets Secrets should be treated as secrets: - Lifecycle - Fetched from an external source - Should be revoked easily - Blast radius of a secret - Secrets ≠ variables - It’s better to use a vault (Vault, KMS, Azure Key Vault…) - Use Terraform vault provider to use them
  • 35. Join our Slack Community 🙋♂️🙋♀️ https://join.slack.com/t/brainboard-community/shared_invite/zt-19hmgmc92-MixDFmaADwxexAPSa5N~pg
  • 36. Brainboard Visually build & manage cloud infrastructures.

Editor's Notes

  • #2: Thanks everyone for joining us today. As usual we’ll be waiting for 5 min. Put music https://open.spotify.com/playlist/4idpO55zNoCMNTtuqP0rlB?si=56914a0f6fd94054&nd=1#login For future training, webinars and use cases, follow our LinkedIn page. CTA like the Linkedin page -> share the LinkedIn page: https://www.linkedin.com/company/brainboard-co
  • #4: Quick introduction about what we are working on at Brainboard. Bidirectional way from code to design and vice versa.
  • #5: We will not be talking about the history of infrastructure as code, neither its benefits and why it is useful. There are hundreds of articles and information that you can find online. Our goal today is to: Understand clearly how terraform works How you can use it in real life to manage cloud infrastructures, not just in theory We’ll be using Brainboard today to save time as it generates the Terraform code and also helps on the explanation or how IaC works. I suggest if you want to do it in a hands on way that you either login or create an account in Brainboard. You can also use your vscode editor and terminal if you want. I highly recommend that you follow us this way and not just listen to it as literature. Tarak shares https://app.brainboard.co/register Stephane & Tarak are with us today, they’ll be your host and managing your questions
  • #6: Explain the different topics quickly We’ll be taking questions regularly, so if you have any questions ask in the chat and the team will handle it
  • #7: Versioning Testing Code review Automatic deployment Change management
  • #8: 2 lives: before and after the code All the tools we see now are mainly focused on deployments: … -> once you are the code The big part is now emerging - push button deploy We will see every part of that Life - Before the code
  • #9: Talk about the installation of Terraform, download the binary. At the end they can import code and learn from public repos. HCL is like YAML with JSON capabilities. Like comments… In the how talk about architecture: so you design your architecture which is the state you want to achieve and Terraform handles the interactions with the cloud providers and their APIs. Terraform the project that compiles to the binary hosted at https://github.com/hashicorp/terraform Cloud providers that contains the resources for eg: https://github.com/hashicorp/terraform-provider-aws you usually interact with that through the documentation only https://registry.terraform.io/providers/hashicorp/aws/latest/docs unless you hit an issue or you look for a new missing feature Tarak sends all the link of this page + link from the slides
  • #10: Talk about the installation of Terraform, download the binary. At the end they can import code and learn from public repos. HCL is like YAML with JSON capabilities. Like comments… In the how talk about architecture: so you design your architecture which is the state you want to achieve and Terraform handles the interactions with the cloud providers and their APIs. Terraform the project that compiles to the binary hosted at https://github.com/hashicorp/terraform Cloud providers that contains the resources for eg: https://github.com/hashicorp/terraform-provider-aws you usually interact with that through the documentation only https://registry.terraform.io/providers/hashicorp/aws/latest/docs unless you hit an issue or you look for a new missing feature Tarak sends all the link of this page + link from the slides
  • #11: Preflight checks: Checks the binary if it matches the configuration Check if you want a specific version of the provider or use latest version Download modules Compare configuration files (can .tf files or a saved plan) against the state to know what to do, that’s why it’s extremely important to save this file in a safe place This is a global picture, we’ll zoom a bit on the supported actions on resources later on This is a the first training and we’ll be doing deep dives in every section, modules, remote backend configuration, secure connection, create workflows.... State files Matching the state with the conf files to create, destroy/destroy & recreate and update Cloud providers, are distributed separately API Versions
  • #12: Give examples of var, terraform conf block Blocks are optional in some situations here are some examples: in BB Terraform conf Variable Resource Give example of expressions Identifiers can contain letters, digits, underscores (_), and hyphens (-). The first character of an identifier must not be a digit, to avoid ambiguity with literal numbers. It’s a good practice to use fmt or tflint project https://github.com/terraform-linters/tflint as part of your CI
  • #16: Infrastructure should be considered in its entirety not just provisioning part. You need to care about all the points around the infrastructure for costs, security and maintenaibility
  • #18: https://registry.terraform.io/browse/providers
  • #19: For the version and source give an example of cloudflare
  • #20: Create resources that exist in the configuration but are not associated with a real infrastructure object in the state. Destroy resources that exist in the state but no longer exist in the configuration. Update in-place resources whose arguments have changed. Destroy and re-create resources whose arguments have changed but which cannot be updated in-place due to remote API limitations. The ID card with the generated code
  • #21: Give example of attribute accessible Give examples of dependency When to use count = identical resources and for_each for specific information For_each values should be known for_each = { a_group = "eastus" another_group = "westus2" } name = each.key location = each.value Chain for_each variable "vpcs" { type = map(object({ cidr_block = string })) } resource "aws_vpc" "example" { # One VPC for each element of var.vpcs for_each = var.vpcs # each.value here is a value from var.vpcs cidr_block = each.value.cidr_block } resource "aws_internet_gateway" "example" { # One Internet Gateway per VPC for_each = aws_vpc.example # each.value here is a full aws_vpc object vpc_id = each.value.id }
  • #22: data "aws_ami" "example" { most_recent = true owners = ["self"] tags = { Name = "app-server" Tested = "true" } } data "local_file" "foo" { filename = "${path.module}/foo.bar" } resource "aws_s3_bucket_object" "shared_zip" { bucket = "my-bucket" key = "my-key" content = data.local_file.foo.content }
  • #24: Source accept registry, git, s3…. For_each added in v0.13
  • #26: Thanks everyone for joining us today. As usual we’ll be waiting for 5 min. Put music https://open.spotify.com/playlist/4idpO55zNoCMNTtuqP0rlB?si=56914a0f6fd94054&nd=1#login For future training, webinars and use cases, follow our LinkedIn page. CTA like the Linkedin page -> share the LinkedIn page: https://www.linkedin.com/company/brainboard-co
  • #27: Especially in the CI/CD and automation in general but also cross environments It means we may have errors that we debug together, we may simulate errors to better understand how it works….
  • #28: Explain the different topics quickly We’ll be taking questions regularly, so if you have any questions ask in the chat and the team will handle it
  • #29: How variables are defined and used in the CI/CD pipeline: variables.tf vs *.tfvars To show case the different argument create a vpc + subnet + instance -> this is a real use case The purpose here is also to see the thinking process, start with the simplest form you can and add organically constraints Input = variables & locals Let’s start with variables as they slightly differ from locals Arguments, type: list(string) Map List of map or object list(object({ internal = number external = number protocol = string })) Map or map(string) If default and type are present, the default should be in the specified type. Show an example In validation you can use Terraform functions like. Show an example: length(var.toto) > 4 Sensitive: show an example of a resource containing a sensitive information sensitive in TF is week, it’s better to treat sensitive as secrets and hide them with your vault because if it’s part of the id it will be printed even if it’s sensitive Use random_pet Error messages
  • #31: I know the value of my variable, so where do I put it’s value? tfvars: this is how tf passes vars in their cloud offering and this how bb also do it Show bb separation between variables.tf and variables.tfvars Space around = are not tolerated…. In command line vars TF_VAR_varname=”toto” difference between env vars and files is with env var there are no warnings or error messages
  • #34: How variables are defined and used in the CI/CD pipeline: variables.tf vs *.tfvars To show case the different argument create a vpc + subnet + instance -> this is a real use case The purpose here is also to see the thinking process, start with the simplest form you can and add organically constraints Input = variables & locals Let’s start with variables as they slightly differ from locals Arguments, type: list(string) Map List of map or object list(object({ internal = number external = number protocol = string })) Map or map(string) If default and type are present, the default should be in the specified type. Show an example In validation you can use Terraform functions like. Show an example: length(var.toto) > 4 Sensitive: show an example of a resource containing a sensitive information sensitive in TF is week, it’s better to treat sensitive as secrets and hide them with your vault because if it’s part of the id it will be printed even if it’s sensitive Use random_pet Error messages
  • #37: Quick introduction about what we are working on at Brainboard. Bidirectional way from code to design and vice versa.