SlideShare a Scribd company logo
1 of 25
Terraform
Make infrastructure great again
A gopher
@advincze
https://github.com/advincze
WeltN24 & AWS
Using AWS for 1++ year
Started with an ops guy, ruby sdk, AWS cli, cloudformation,
Terraform helped adoption among non ops
What is terraform?
Declarative infrastructure Management
Better cloudformation? (code writability, open source, speed of dev, planning)
Network Setup to application deployment
Cloud / vendor agnostic
AWS first class citizen (uses directly AWS Go sdk, not CF)
Application Code vs. Infrastructure code
Imperative
Hopefully stateless
>50y
Declarative
Global state (dns, ips, s3 buckets, ssl
certs)
<10y
Quick look at code
How Terraform works
State-Before
Get state
Configuration:
*.tf files
Get config Validate config
Config errors
Calculate Diff
(graph)
Execute plan Write new State
State After
Exec errorsOutput plan
Three states
configuration Terraform state Real world
UI
Commands: plan, apply, destroy
Dev workflow : click, click-delete, read docs (similar to CF), write code, plan,
apply, destroy, fmt !
- Input/Output: Variables
- Interpolation
- Strings, functions
demo
Default VPC
EC2 instance
Security group CNAME: demo1.mob.welt.de
code
- File names don’t matter: *.tf
- Interpolation + var maps to switch regions easily (genesis example)
- Tag the resources
state
- What terraform knows about the real world
- Validated before application
- Used for planning (to create and ! to destroy)
Remote
- Store remote in artifactory, Atlas, Consul, S3, HTTP, etcd, swift (openstack)
- Easy to forget to configure (gist: terraformw)
- From relative filepath or e.g. github
- enable shared, reusable components
- Abstraction (!) for service developers
- Examples: ECS cluster, private_nets, public_nets
Modules - teams share code
Real Life demo
VPC
Public subnet
Internet gateway
Public subnet
Internet gateway
routingrouting
VPC
Public subnet
Internet gateway
Public subnet
Internet gateway
routingrouting
ECS instance
ECS cluster
SG
ECS instance
IAM
SG
VPC
Public subnet
Internet gateway
Public subnet
Internet gateway
routingrouting
ECS instance
ECS cluster
SG
ECS instance
IAM
SG ECR repository
APP image
VPC
Public subnet
Internet gateway
Public subnet
Internet gateway
routingrouting
ECS instance
ECS cluster
SG
ECS instance
IAM
SG ECR repository
APP image
ECS task ECS task
ECS service
ELB
CNAME: demo2.mob.welt.de
SSL
State dependencies
State
VPC
State
ECS
State
ECR
State
App
vpc.tf ecs.tf ecr.tf app.tf
- Input/Output in separate files
- Resource names: the resource type is part of the name
Best practices - code
- For production, use remote state only
- Separate repos/states for big logical parts (how often do you change this?
Who contributes?)
- Central components
- Shared components, services
- Service individual infrastructure
- Service deployment
- This is not Free !
Best practices - state
- Start with (repo) local modules and
- move them into separate repo if used elsewhere + mature
- Use ID prefix for module resources to avoid problems
- Practice: create + destroy all every day
- Don’t apply locally (only plan) - Centralize plan+apply
- Pin module versions
Best practices - modules
- Terraform is Production ready
- It can be used with your existing setup
- Extendable with custom plugins - standard lifecycle CRUD
- Main benefits: easy installation,ease of use, readable code, fast dev cycle,
open source - often quicker than CF
- Drawback: no rollbacks
- helps devOps culture
- Written in go, you should learn go.
summary
Thanks, questions?
@advincze

More Related Content

What's hot

What's hot (20)

Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Terraform
TerraformTerraform
Terraform
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform
TerraformTerraform
Terraform
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
An introduction to terraform
An introduction to terraformAn introduction to terraform
An introduction to terraform
 
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
 
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)
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Introduction to IAC and Terraform
Introduction to IAC and Terraform Introduction to IAC and Terraform
Introduction to IAC and Terraform
 
Terraform Introduction
Terraform IntroductionTerraform Introduction
Terraform Introduction
 
Terraform
TerraformTerraform
Terraform
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
Infrastructure-as-Code (IaC) Using Terraform (Intermediate Edition)
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
 

Viewers also liked

Infrastructure as code with Terraform
Infrastructure as code with TerraformInfrastructure as code with Terraform
Infrastructure as code with Terraform
Sam Bashton
 

Viewers also liked (20)

Terraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentTerraform Modules and Continuous Deployment
Terraform Modules and Continuous Deployment
 
Rapid Infrastructure Provisioning
Rapid Infrastructure ProvisioningRapid Infrastructure Provisioning
Rapid Infrastructure Provisioning
 
Terraform and cloud.ca
Terraform and cloud.caTerraform and cloud.ca
Terraform and cloud.ca
 
Infrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to TerraformInfrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to Terraform
 
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-TannerDevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
 
Terraform at Scale
Terraform at ScaleTerraform at Scale
Terraform at Scale
 
Etcd terraform by Alex Somesan
Etcd terraform by Alex SomesanEtcd terraform by Alex Somesan
Etcd terraform by Alex Somesan
 
Terraform: Cloud Configuration Management (WTC/IPC'16)
Terraform: Cloud Configuration Management (WTC/IPC'16)Terraform: Cloud Configuration Management (WTC/IPC'16)
Terraform: Cloud Configuration Management (WTC/IPC'16)
 
2016 - IGNITE - Terraform to go from Zero to Prod in less than 1 month and TH...
2016 - IGNITE - Terraform to go from Zero to Prod in less than 1 month and TH...2016 - IGNITE - Terraform to go from Zero to Prod in less than 1 month and TH...
2016 - IGNITE - Terraform to go from Zero to Prod in less than 1 month and TH...
 
Refactoring terraform
Refactoring terraformRefactoring terraform
Refactoring terraform
 
TerraformでECS+ECRする話
TerraformでECS+ECRする話TerraformでECS+ECRする話
TerraformでECS+ECRする話
 
Rediscovering Developer Opportunities in the Philippines by Fred Tshidimba
Rediscovering Developer Opportunities in the Philippines by Fred TshidimbaRediscovering Developer Opportunities in the Philippines by Fred Tshidimba
Rediscovering Developer Opportunities in the Philippines by Fred Tshidimba
 
Jsonnet, terraform & packer
Jsonnet, terraform & packerJsonnet, terraform & packer
Jsonnet, terraform & packer
 
Infrastructure as code with Terraform
Infrastructure as code with TerraformInfrastructure as code with Terraform
Infrastructure as code with Terraform
 
London Hug 19/5 - Terraform in Production
London Hug 19/5 - Terraform in ProductionLondon Hug 19/5 - Terraform in Production
London Hug 19/5 - Terraform in Production
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and Docker
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
 
AWS re:Invent 2016| GAM401 | Riot Games: Standardizing Application Deployment...
AWS re:Invent 2016| GAM401 | Riot Games: Standardizing Application Deployment...AWS re:Invent 2016| GAM401 | Riot Games: Standardizing Application Deployment...
AWS re:Invent 2016| GAM401 | Riot Games: Standardizing Application Deployment...
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 

Similar to Terraform

Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
QAware GmbH
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
QAware GmbH
 

Similar to Terraform (20)

Building services on AWS in China region
Building services on AWS in China regionBuilding services on AWS in China region
Building services on AWS in China region
 
Cloud infrastructure as code
Cloud infrastructure as codeCloud infrastructure as code
Cloud infrastructure as code
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...Test cloud application deployments locally and in CI without staging environm...
Test cloud application deployments locally and in CI without staging environm...
 
Building Your Docker Tech Stack
Building Your Docker Tech StackBuilding Your Docker Tech Stack
Building Your Docker Tech Stack
 
Building your production tech stack for docker container platform
Building your production tech stack for docker container platformBuilding your production tech stack for docker container platform
Building your production tech stack for docker container platform
 
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
AWS re:Invent 2016: Service Integration Delivery and Automation Using Amazon ...
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
 
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
DevOps in Droplr
DevOps in DroplrDevOps in Droplr
DevOps in Droplr
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaSAutoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
Autoscaling OpenStack Natively with Heat, Ceilometer and LBaaS
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
 
Infrastructure as code, using Terraform
Infrastructure as code, using TerraformInfrastructure as code, using Terraform
Infrastructure as code, using Terraform
 
OpenCms Days 2012 - OpenCms on open clouds
OpenCms Days 2012 - OpenCms on open cloudsOpenCms Days 2012 - OpenCms on open clouds
OpenCms Days 2012 - OpenCms on open clouds
 
Cloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java Developers
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
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
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Terraform

  • 3. WeltN24 & AWS Using AWS for 1++ year Started with an ops guy, ruby sdk, AWS cli, cloudformation, Terraform helped adoption among non ops
  • 4. What is terraform? Declarative infrastructure Management Better cloudformation? (code writability, open source, speed of dev, planning) Network Setup to application deployment Cloud / vendor agnostic AWS first class citizen (uses directly AWS Go sdk, not CF)
  • 5. Application Code vs. Infrastructure code Imperative Hopefully stateless >50y Declarative Global state (dns, ips, s3 buckets, ssl certs) <10y
  • 7. How Terraform works State-Before Get state Configuration: *.tf files Get config Validate config Config errors Calculate Diff (graph) Execute plan Write new State State After Exec errorsOutput plan
  • 9. UI Commands: plan, apply, destroy Dev workflow : click, click-delete, read docs (similar to CF), write code, plan, apply, destroy, fmt ! - Input/Output: Variables - Interpolation - Strings, functions
  • 10. demo
  • 11. Default VPC EC2 instance Security group CNAME: demo1.mob.welt.de
  • 12. code - File names don’t matter: *.tf - Interpolation + var maps to switch regions easily (genesis example) - Tag the resources
  • 13. state - What terraform knows about the real world - Validated before application - Used for planning (to create and ! to destroy) Remote - Store remote in artifactory, Atlas, Consul, S3, HTTP, etcd, swift (openstack) - Easy to forget to configure (gist: terraformw)
  • 14. - From relative filepath or e.g. github - enable shared, reusable components - Abstraction (!) for service developers - Examples: ECS cluster, private_nets, public_nets Modules - teams share code
  • 16. VPC Public subnet Internet gateway Public subnet Internet gateway routingrouting
  • 17. VPC Public subnet Internet gateway Public subnet Internet gateway routingrouting ECS instance ECS cluster SG ECS instance IAM SG
  • 18. VPC Public subnet Internet gateway Public subnet Internet gateway routingrouting ECS instance ECS cluster SG ECS instance IAM SG ECR repository APP image
  • 19. VPC Public subnet Internet gateway Public subnet Internet gateway routingrouting ECS instance ECS cluster SG ECS instance IAM SG ECR repository APP image ECS task ECS task ECS service ELB CNAME: demo2.mob.welt.de SSL
  • 21. - Input/Output in separate files - Resource names: the resource type is part of the name Best practices - code
  • 22. - For production, use remote state only - Separate repos/states for big logical parts (how often do you change this? Who contributes?) - Central components - Shared components, services - Service individual infrastructure - Service deployment - This is not Free ! Best practices - state
  • 23. - Start with (repo) local modules and - move them into separate repo if used elsewhere + mature - Use ID prefix for module resources to avoid problems - Practice: create + destroy all every day - Don’t apply locally (only plan) - Centralize plan+apply - Pin module versions Best practices - modules
  • 24. - Terraform is Production ready - It can be used with your existing setup - Extendable with custom plugins - standard lifecycle CRUD - Main benefits: easy installation,ease of use, readable code, fast dev cycle, open source - often quicker than CF - Drawback: no rollbacks - helps devOps culture - Written in go, you should learn go. summary

Editor's Notes

  1. local state No exports
  2. Modules, remote state in s3, interpolation