SlideShare une entreprise Scribd logo
1  sur  23
Getting started with Terraform
• Terraform is an infrastructure as code software by HashiCorp.
• Terraform is used to create, manage, and update infrastructure resources
such as physical machines, VMs, network ,storage, containers, and more.
Almost any infrastructure type can be represented as a resource in Terraform
• It is developed in Go Language
• The syntax of Terraform configurations is called HashiCorp Configuration
Language (HCL) . It is meant to strike a balance between human readable
and editable as well as being machine-friendly
• Managing anything with an API
Terraform is a
• Open source
• Declarative language : where you write code that specifies your desired end state
• Immutable infrastructure : is all about immutable components which are recreated and
replaced instead of updating after infrastructure creation.
Terraform vs Other Software
• Chef, Puppet, Ansible etc. : Configuration management tools install and manage software on
a machine that already exists.
• Cloud Formation : is developed and maintained by AWS, it is very tightly integrated and only
supports AWS.
• cloud-agnostic : it goes further by being both cloud-agnostic and enabling multiple providers
and services to be combined and composed.
• Terraform is a client-only architecture.
Supported providers
• It supports many providers (cloud agnostic)
And many resources for each provider
Steps to install Terraform
For Mac/Linux :
• Navigate to https://www.terraform.io/downloads.html select appropriate installer based
on your operating system.
• Once you install you can verify the version of terraform
• Make sure that the terraform binary is available on the PATH.
• For Mac/Linux. On the shell/terminal, go to the folder where terraform binary is extracted
• echo $"export PATH=$PATH:$(pwd)" >> ~/.bash_profile
• source ~/.bash_profile
For windows :
• In Search, search for and then select: System (Control Panel)
• Click the System and Security link.
• Click the System link.
• Click the Advanced system settings link.
• Click Environment Variables. In the section System Variables, find the PATH environment
variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
• In the Edit System Variable (or New System Variable) window, append at the end of
the PATH environment variable the value of terraform path ex.”c:terraform;”. Click OK. Close
all remaining windows by clicking OK.
• Reopen Command prompt window, and run terraform.
You define resources as code in
Terraform templates
This template creates a single EC2 instance in AWS
Use Terraform Init
• The terraform init command is used to initialize a working directory containing
Terraform configuration files
Use the Terraform plan command to see
what you’re about to deploy
 terraform plan
Use the apply command to apply
the changes
 terraform apply
 Ec2 up & running
 You can clean up all resources you created with Terraform
Just use the terraform destroy command
But how did Terraform know what to destroy???
• Terraform records state of everything it has done
once you execute Terraform Apply ,it creates below files
• terraform.tfstate
• terraform.tfstate.backup
• By default, state is stored locally in .tfstate files
Getting Advanced
• Variables, Outputs(parameterization)
• Interpolation Functions
• Modules
• Remote state
You can parameterize your
templates using variables
• Example :-
 outputs
• Is a way to organize data to be easily queried and shown back to the Terraform user.
• Outputs are a way to tell Terraform what data is important. This data is outputted when apply is
called, and can be queried using the terraform output command.
• an output to show us the public IP address of the elastic IP address that we create. Add this
to any of your *.tf files :
 Backends
• Backends are responsible for storing state
• A "backend" in Terraform determines how state is loaded and how an operation such as apply
is executed
• By default, Terraform uses the "local" backend, which is the normal behavior of Terraform
you're used to
• Here are some of the benefits of backends:
• Working in a team:
• Backends can store their state remotely and protect that state with locks to prevent
corruption. Some backends such as Terraform Enterprise even automatically store a
history of all state revisions.
• Keeping sensitive information off disk:
• State is retrieved from backends on demand and only stored in memory. If you're using
a backend such as Amazon S3, the only location the state ever is persisted is in S3.
 Terraform Modules
• That you can reuse, configure, and version control
• A module is just a folder with Terraform templates
• Example using module
 Module Sources
• The module installer supports installation from a number of different source types, as listed below
• Local paths
• GitHub
• Bit bucket
• S3 buckets
• Terraform Registry
 Best practices
• Plan before apply
• Stage before prod
• Isolated environments
THANK YOU
- Harish Kumar
- Sreenivasulu Durgam
- Ashish Singh

Contenu connexe

Tendances

Tendances (20)

Terraform
TerraformTerraform
Terraform
 
Terraform
TerraformTerraform
Terraform
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Terraform
TerraformTerraform
Terraform
 
Terraform
TerraformTerraform
Terraform
 
A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...
A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...
A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
 
An introduction to terraform
An introduction to terraformAn introduction to terraform
An introduction to terraform
 
Terraform Basics
Terraform BasicsTerraform Basics
Terraform Basics
 
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
 
Best Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with TerraformBest Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with Terraform
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
Terraform Introduction
Terraform IntroductionTerraform Introduction
Terraform Introduction
 
Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018
 
Terraform
TerraformTerraform
Terraform
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform
TerraformTerraform
Terraform
 
Terraform day1
Terraform day1Terraform day1
Terraform day1
 

Similaire à Terraform

Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptxLinode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
AkwasiBoateng6
 

Similaire à Terraform (20)

Deploy resources on Azure using IaC (Azure Terraform)
Deploy  resources on Azure using IaC (Azure Terraform)Deploy  resources on Azure using IaC (Azure Terraform)
Deploy resources on Azure using IaC (Azure Terraform)
 
Infrastructure as code with terraform and packer
Infrastructure as code with terraform and packerInfrastructure as code with terraform and packer
Infrastructure as code with terraform and packer
 
Configuration management II - Terraform
Configuration management II - TerraformConfiguration management II - Terraform
Configuration management II - Terraform
 
Terraform day 1
Terraform day 1Terraform day 1
Terraform day 1
 
Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?Infrastructure as Code for Azure: ARM or Terraform?
Infrastructure as Code for Azure: ARM or Terraform?
 
Terraform + ansible talk
Terraform + ansible talkTerraform + ansible talk
Terraform + ansible talk
 
Infrastructure as Code with Terraform
Infrastructure as Code with TerraformInfrastructure as Code with Terraform
Infrastructure as Code with Terraform
 
DevOps Online Training | DevOps Training
DevOps Online Training | DevOps TrainingDevOps Online Training | DevOps Training
DevOps Online Training | DevOps Training
 
Terraform training 🎒 - Basic
Terraform training 🎒 - BasicTerraform training 🎒 - Basic
Terraform training 🎒 - Basic
 
Oracle database 12c client quick installation guide 7
Oracle database 12c client quick installation guide 7Oracle database 12c client quick installation guide 7
Oracle database 12c client quick installation guide 7
 
DevOps Training - Introduction to Terraform
DevOps Training - Introduction to TerraformDevOps Training - Introduction to Terraform
DevOps Training - Introduction to Terraform
 
OracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdfOracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdf
 
Terraform Definition, Working and Challenges it Overcomes
Terraform Definition, Working and Challenges it OvercomesTerraform Definition, Working and Challenges it Overcomes
Terraform Definition, Working and Challenges it Overcomes
 
Oracle database 12c client quick installation guide 8
Oracle database 12c client quick installation guide 8Oracle database 12c client quick installation guide 8
Oracle database 12c client quick installation guide 8
 
Oracle database 12c client quick installation guide 3
Oracle database 12c client quick installation guide 3Oracle database 12c client quick installation guide 3
Oracle database 12c client quick installation guide 3
 
Oracle database 12c client quick installation guide 4
Oracle database 12c client quick installation guide 4Oracle database 12c client quick installation guide 4
Oracle database 12c client quick installation guide 4
 
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptxLinode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
Linode_eBook_Declarative_Cloud_Infrastructure_Management_with_Terraform.pptx
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs Pulumi
 
The hitchhiker's guide to terraform your infrastructure
The hitchhiker's guide to terraform your infrastructureThe hitchhiker's guide to terraform your infrastructure
The hitchhiker's guide to terraform your infrastructure
 
Oracle database 12c client quick installation guide 2
Oracle database 12c client quick installation guide 2Oracle database 12c client quick installation guide 2
Oracle database 12c client quick installation guide 2
 

Dernier

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

Terraform

  • 1. Getting started with Terraform • Terraform is an infrastructure as code software by HashiCorp. • Terraform is used to create, manage, and update infrastructure resources such as physical machines, VMs, network ,storage, containers, and more. Almost any infrastructure type can be represented as a resource in Terraform • It is developed in Go Language • The syntax of Terraform configurations is called HashiCorp Configuration Language (HCL) . It is meant to strike a balance between human readable and editable as well as being machine-friendly • Managing anything with an API
  • 2. Terraform is a • Open source • Declarative language : where you write code that specifies your desired end state • Immutable infrastructure : is all about immutable components which are recreated and replaced instead of updating after infrastructure creation.
  • 3. Terraform vs Other Software • Chef, Puppet, Ansible etc. : Configuration management tools install and manage software on a machine that already exists. • Cloud Formation : is developed and maintained by AWS, it is very tightly integrated and only supports AWS. • cloud-agnostic : it goes further by being both cloud-agnostic and enabling multiple providers and services to be combined and composed. • Terraform is a client-only architecture.
  • 4. Supported providers • It supports many providers (cloud agnostic)
  • 5. And many resources for each provider
  • 6. Steps to install Terraform For Mac/Linux : • Navigate to https://www.terraform.io/downloads.html select appropriate installer based on your operating system. • Once you install you can verify the version of terraform • Make sure that the terraform binary is available on the PATH. • For Mac/Linux. On the shell/terminal, go to the folder where terraform binary is extracted • echo $"export PATH=$PATH:$(pwd)" >> ~/.bash_profile • source ~/.bash_profile
  • 7. For windows : • In Search, search for and then select: System (Control Panel) • Click the System and Security link. • Click the System link. • Click the Advanced system settings link. • Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New. • In the Edit System Variable (or New System Variable) window, append at the end of the PATH environment variable the value of terraform path ex.”c:terraform;”. Click OK. Close all remaining windows by clicking OK. • Reopen Command prompt window, and run terraform.
  • 8. You define resources as code in Terraform templates
  • 9. This template creates a single EC2 instance in AWS
  • 10. Use Terraform Init • The terraform init command is used to initialize a working directory containing Terraform configuration files
  • 11. Use the Terraform plan command to see what you’re about to deploy  terraform plan
  • 12. Use the apply command to apply the changes  terraform apply
  • 13.  Ec2 up & running
  • 14.  You can clean up all resources you created with Terraform Just use the terraform destroy command
  • 15. But how did Terraform know what to destroy??? • Terraform records state of everything it has done once you execute Terraform Apply ,it creates below files • terraform.tfstate • terraform.tfstate.backup • By default, state is stored locally in .tfstate files
  • 16. Getting Advanced • Variables, Outputs(parameterization) • Interpolation Functions • Modules • Remote state
  • 17. You can parameterize your templates using variables • Example :-
  • 18.  outputs • Is a way to organize data to be easily queried and shown back to the Terraform user. • Outputs are a way to tell Terraform what data is important. This data is outputted when apply is called, and can be queried using the terraform output command. • an output to show us the public IP address of the elastic IP address that we create. Add this to any of your *.tf files :
  • 19.  Backends • Backends are responsible for storing state • A "backend" in Terraform determines how state is loaded and how an operation such as apply is executed • By default, Terraform uses the "local" backend, which is the normal behavior of Terraform you're used to • Here are some of the benefits of backends: • Working in a team: • Backends can store their state remotely and protect that state with locks to prevent corruption. Some backends such as Terraform Enterprise even automatically store a history of all state revisions. • Keeping sensitive information off disk: • State is retrieved from backends on demand and only stored in memory. If you're using a backend such as Amazon S3, the only location the state ever is persisted is in S3.
  • 20.  Terraform Modules • That you can reuse, configure, and version control • A module is just a folder with Terraform templates • Example using module
  • 21.  Module Sources • The module installer supports installation from a number of different source types, as listed below • Local paths • GitHub • Bit bucket • S3 buckets • Terraform Registry
  • 22.  Best practices • Plan before apply • Stage before prod • Isolated environments
  • 23. THANK YOU - Harish Kumar - Sreenivasulu Durgam - Ashish Singh