SlideShare a Scribd company logo
1 of 23
+
What is Terraform?
1. Terraform is an open-source tool for Infrastructure as Code (IaC)
2. Terraform is a declarative language based on HCL (Hashicorp Configuration Language)
3. Terraform is used to provision resources that are defined as code
4. Terraform is written in Go
The key advantage of this is that it enables you to manage your infrastructure with the same processes
that you use to manage the source code of an application with tools like git.
How do Ansible and Terraform work together?
Overlap between the tools
- Ansible can create physical resources
- But managing relationships between them can be awkward
- E.g. Assigning an EIP to an EC2 instance
- And you can configure machines through Terraform
- User Data
- Takes time for the machine to configure itself on startup.
- Separating gives you more options - Packer, etc.
- Ansible > Shell
- But different tools have different strengths
- Use the best tool for each part of the job
Other Tools
● Terraform vs. Cloudformation
○ Cross platform
○ CLI differences - terraform plan, watch progress in console
● Ansible vs. Shell, Chef, Puppet, Salt, etc.
○ Ansible is: agentless, stateless
Terraform Basic
Composition
● Providers
● Root modules
● Reusable modules
● Inputs
● Outputs
● Resources
What are providers
A provider is responsible for understanding API interactions and exposing resources.
Providers generally are an IaaS for example AWS, GCP, Azure etc.
Providers serve 4 main purposes
● Create: resourceServerCreate,
● Read: resourceServerRead,
● Update: resourceServerUpdate,
● Delete: resourceServerDelete,
Defining a resource
provider "aws" {
region = "us-east-1"
profile = "henry_gallo"
}
What are tf Modules? A module is a collection of multiple resources
that are used together, it can be considered
the base unit of terraform. All terraform
configuration should be written in the form of
a module.
All terraform modules consist of three
distinct parts:
What are tf Modules? A module is a collection of multiple resources
that are used together, it can be considered
the base unit of terraform. All terraform
configuration should be written in the form of
a module.
All terraform modules consist of three
distinct parts:
● Input variables to accept values from
the caller.
What are tf Modules? A module is a collection of multiple resources
that are used together, it can be considered
the base unit of terraform. All terraform
configuration should be written in the form of
a module.
All terraform modules consist of three
distinct parts:
● Input variables to accept values from
the caller.
● Output values to return results to the
caller.
What are tf Modules? A module is a collection of multiple resources
that are used together, it can be considered
the base unit of terraform. All terraform
configuration should be written in the form of
a module.
All terraform modules consist of three
distinct parts:
● Input variables to accept values from
the caller.
● Output values to return results to the
caller.
● Resources to define one or more
infrastructure objects that the module
will manage.
Types of Modules
Root Modules
This is the only required element for the standard module structure. Terraform files must exist in the root directory of
the repository. This should be the primary entrypoint for the module and is expected to be opinionated.
module "firewall_ec2" {
security_group_name = "terraform_demo_ec2"
sg_description = "Allow ssh inbound traffic"
source = "git::https://github.com/hgallo0/ec2_sec_group.git?ref=v0.0.2"
…
}
Types of Modules
Reusable Modules
Reusable modules are used to create lightweight abstractions of the resources defined by your provider, they enable
the use of terraform files across multiple projects avoiding duplication, this concept is similar to Libraries in
programing languages.
resource "aws_security_group" "allow_http" {
name = var.security_group_name
description = var.sg_description
vpc_id = var.vpc_id
...
Terraform State
Terraform must store state about your managed infrastructure and configuration. This state is stored by default in a local file
named "terraform.tfstate", but it can also be stored remotely, which works better in a team environment.
Terraform uses this local state to create plans and make changes to your infrastructure. Prior to any operation, Terraform does a
refresh to update the state with the real infrastructure.
terraform {
backend "s3" {
bucket = "terraform-meetup"
key = "ec2"
encrypt = "true"
region = "us-east-1"
dynamodb_table = "terraform-meetup"
profile = "henry_gallo"
...
Modification is highly
discouraged
Inspection and Modification
While the format of the state files are just JSON, direct file editing of the state is discouraged. Terraform provides the terraform
state command to perform basic modifications of the state using the CLI
But if you ever needed to
error : Error: orphan resource module.firewall_ec2.aws_security_group.allow_http still has a non-empty state after apply; this is a bug in
Terraform
henrygallo@henrys-MacBook-Pro ec2 % terraform state rm module.firewall_ec2.aws_security_group.allow_http
Removed module.firewall_ec2.aws_security_group.allow_http
Successfully removed 1 resource instance(s).
Demo from Steve
Base code
https://github.com/contino/terraform_talk.git
Initial files
Initializing terraform
.terraform dir content
The modules file
The remote state

More Related Content

What's hot

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 2018Anton Babenko
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Terraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCPTerraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCPSamuel Chow
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practicesAnton Babenko
 
Terraform Best Practices - DevOps Unicorns 2019
Terraform Best Practices - DevOps Unicorns 2019Terraform Best Practices - DevOps Unicorns 2019
Terraform Best Practices - DevOps Unicorns 2019Anton Babenko
 
Best practices for Terraform with Vault
Best practices for Terraform with VaultBest practices for Terraform with Vault
Best practices for Terraform with VaultMitchell Pronschinske
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipelineAnton Babenko
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introductionJason Vance
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformKnoldus Inc.
 
Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Janakiram MSV
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Krishna-Kumar
 
Working with Terraform on Azure
Working with Terraform on AzureWorking with Terraform on Azure
Working with Terraform on Azuretombuildsstuff
 

What's hot (20)

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
 
Introduce to Terraform
Introduce to TerraformIntroduce to Terraform
Introduce to Terraform
 
Terraform
TerraformTerraform
Terraform
 
Terraform
TerraformTerraform
Terraform
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Terraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCPTerraforming your Infrastructure on GCP
Terraforming your Infrastructure on GCP
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practices
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Terraform Best Practices - DevOps Unicorns 2019
Terraform Best Practices - DevOps Unicorns 2019Terraform Best Practices - DevOps Unicorns 2019
Terraform Best Practices - DevOps Unicorns 2019
 
Best practices for Terraform with Vault
Best practices for Terraform with VaultBest practices for Terraform with Vault
Best practices for Terraform with Vault
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 
Helm.pptx
Helm.pptxHelm.pptx
Helm.pptx
 
Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets Kubernetes Webinar - Using ConfigMaps & Secrets
Kubernetes Webinar - Using ConfigMaps & Secrets
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
 
Working with Terraform on Azure
Working with Terraform on AzureWorking with Terraform on Azure
Working with Terraform on Azure
 
Terraform
TerraformTerraform
Terraform
 

Similar to Terraform + ansible talk

Collaborative Terraform with Atlantis
Collaborative Terraform with AtlantisCollaborative Terraform with Atlantis
Collaborative Terraform with AtlantisFerenc Kovács
 
Terraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerTerraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerCalvin French-Owen
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfssuser705051
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs PulumiHoaiNam307
 
Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019Anton Babenko
 
Configuration management II - Terraform
Configuration management II - TerraformConfiguration management II - Terraform
Configuration management II - TerraformXavier Serrat Bordas
 
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 infrastructureFernanda Martins
 
Introduction to Terra space Presentation
Introduction to Terra space PresentationIntroduction to Terra space Presentation
Introduction to Terra space PresentationKnoldus Inc.
 
Introduction to Terraspace Presentation.
Introduction to Terraspace Presentation.Introduction to Terraspace Presentation.
Introduction to Terraspace Presentation.Knoldus Inc.
 
Terraform training - Modules 🎒
Terraform training - Modules 🎒Terraform training - Modules 🎒
Terraform training - Modules 🎒StephaneBoghossian1
 
OracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdfOracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdfStefan Oehrli
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based TerraformAndrew Kirkpatrick
 
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...Alex Cachia
 
DevOps Training - Introduction to Terraform
DevOps Training - Introduction to TerraformDevOps Training - Introduction to Terraform
DevOps Training - Introduction to TerraformRauno De Pasquale
 
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.pptxAkwasiBoateng6
 

Similar to Terraform + ansible talk (20)

Collaborative Terraform with Atlantis
Collaborative Terraform with AtlantisCollaborative Terraform with Atlantis
Collaborative Terraform with Atlantis
 
Terraform Abstractions for Safety and Power
Terraform Abstractions for Safety and PowerTerraform Abstractions for Safety and Power
Terraform Abstractions for Safety and Power
 
Terraform training 🎒 - Basic
Terraform training 🎒 - BasicTerraform training 🎒 - Basic
Terraform training 🎒 - Basic
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Why Learn Terraform?
Why Learn Terraform?Why Learn Terraform?
Why Learn Terraform?
 
Terraform vs Pulumi
Terraform vs PulumiTerraform vs Pulumi
Terraform vs Pulumi
 
Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019Terraform modules and some of best-practices - March 2019
Terraform modules and some of best-practices - March 2019
 
Configuration management II - Terraform
Configuration management II - TerraformConfiguration management II - Terraform
Configuration management II - Terraform
 
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
 
Introduction to Terra space Presentation
Introduction to Terra space PresentationIntroduction to Terra space Presentation
Introduction to Terra space Presentation
 
Introduction to Terraspace Presentation.
Introduction to Terraspace Presentation.Introduction to Terraspace Presentation.
Introduction to Terraspace Presentation.
 
Terraform training - Modules 🎒
Terraform training - Modules 🎒Terraform training - Modules 🎒
Terraform training - Modules 🎒
 
OracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdfOracleBeer_Terraform_soe.pdf
OracleBeer_Terraform_soe.pdf
 
Introduction to IAC and Terraform
Introduction to IAC and Terraform Introduction to IAC and Terraform
Introduction to IAC and Terraform
 
Terraform
TerraformTerraform
Terraform
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based 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...
 
DevOps Training - Introduction to Terraform
DevOps Training - Introduction to TerraformDevOps Training - Introduction to Terraform
DevOps Training - Introduction to 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
 

Recently uploaded

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Recently uploaded (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Terraform + ansible talk

  • 1. +
  • 2. What is Terraform? 1. Terraform is an open-source tool for Infrastructure as Code (IaC) 2. Terraform is a declarative language based on HCL (Hashicorp Configuration Language) 3. Terraform is used to provision resources that are defined as code 4. Terraform is written in Go The key advantage of this is that it enables you to manage your infrastructure with the same processes that you use to manage the source code of an application with tools like git.
  • 3. How do Ansible and Terraform work together?
  • 4. Overlap between the tools - Ansible can create physical resources - But managing relationships between them can be awkward - E.g. Assigning an EIP to an EC2 instance - And you can configure machines through Terraform - User Data - Takes time for the machine to configure itself on startup. - Separating gives you more options - Packer, etc. - Ansible > Shell - But different tools have different strengths - Use the best tool for each part of the job
  • 5. Other Tools ● Terraform vs. Cloudformation ○ Cross platform ○ CLI differences - terraform plan, watch progress in console ● Ansible vs. Shell, Chef, Puppet, Salt, etc. ○ Ansible is: agentless, stateless
  • 6. Terraform Basic Composition ● Providers ● Root modules ● Reusable modules ● Inputs ● Outputs ● Resources
  • 7. What are providers A provider is responsible for understanding API interactions and exposing resources. Providers generally are an IaaS for example AWS, GCP, Azure etc. Providers serve 4 main purposes ● Create: resourceServerCreate, ● Read: resourceServerRead, ● Update: resourceServerUpdate, ● Delete: resourceServerDelete, Defining a resource provider "aws" { region = "us-east-1" profile = "henry_gallo" }
  • 8. What are tf Modules? A module is a collection of multiple resources that are used together, it can be considered the base unit of terraform. All terraform configuration should be written in the form of a module. All terraform modules consist of three distinct parts:
  • 9. What are tf Modules? A module is a collection of multiple resources that are used together, it can be considered the base unit of terraform. All terraform configuration should be written in the form of a module. All terraform modules consist of three distinct parts: ● Input variables to accept values from the caller.
  • 10. What are tf Modules? A module is a collection of multiple resources that are used together, it can be considered the base unit of terraform. All terraform configuration should be written in the form of a module. All terraform modules consist of three distinct parts: ● Input variables to accept values from the caller. ● Output values to return results to the caller.
  • 11. What are tf Modules? A module is a collection of multiple resources that are used together, it can be considered the base unit of terraform. All terraform configuration should be written in the form of a module. All terraform modules consist of three distinct parts: ● Input variables to accept values from the caller. ● Output values to return results to the caller. ● Resources to define one or more infrastructure objects that the module will manage.
  • 12. Types of Modules Root Modules This is the only required element for the standard module structure. Terraform files must exist in the root directory of the repository. This should be the primary entrypoint for the module and is expected to be opinionated. module "firewall_ec2" { security_group_name = "terraform_demo_ec2" sg_description = "Allow ssh inbound traffic" source = "git::https://github.com/hgallo0/ec2_sec_group.git?ref=v0.0.2" … }
  • 13. Types of Modules Reusable Modules Reusable modules are used to create lightweight abstractions of the resources defined by your provider, they enable the use of terraform files across multiple projects avoiding duplication, this concept is similar to Libraries in programing languages. resource "aws_security_group" "allow_http" { name = var.security_group_name description = var.sg_description vpc_id = var.vpc_id ...
  • 14. Terraform State Terraform must store state about your managed infrastructure and configuration. This state is stored by default in a local file named "terraform.tfstate", but it can also be stored remotely, which works better in a team environment. Terraform uses this local state to create plans and make changes to your infrastructure. Prior to any operation, Terraform does a refresh to update the state with the real infrastructure. terraform { backend "s3" { bucket = "terraform-meetup" key = "ec2" encrypt = "true" region = "us-east-1" dynamodb_table = "terraform-meetup" profile = "henry_gallo" ...
  • 15. Modification is highly discouraged Inspection and Modification While the format of the state files are just JSON, direct file editing of the state is discouraged. Terraform provides the terraform state command to perform basic modifications of the state using the CLI
  • 16. But if you ever needed to error : Error: orphan resource module.firewall_ec2.aws_security_group.allow_http still has a non-empty state after apply; this is a bug in Terraform henrygallo@henrys-MacBook-Pro ec2 % terraform state rm module.firewall_ec2.aws_security_group.allow_http Removed module.firewall_ec2.aws_security_group.allow_http Successfully removed 1 resource instance(s).