Slide 1

Slide 1 text

Ondrej Sika [email protected] @ondrejsika LinuxDays 2019 Terraform Infrastructure as a code

Slide 2

Slide 2 text

About me - Ondrej Sika I'm DevOps consultant and lecturer. I'm helping companies to setup DevOps. That means for them to focus on their product, faster & more reliable delivery new features to production and stop wasting time for example on deployments and infrastructure.

Slide 3

Slide 3 text

We want Git versioned - Source Code - Environments (Dockerfiles) - Configuration (Nginx, …) - Deployments (Kubernetes) - Infrastructure?

Slide 4

Slide 4 text

How we handle infrastructure? - Physical servers - manually - Virtual servers - manually - Cloud - manually - Cloud - as a code - Terraform

Slide 5

Slide 5 text

Terraform

Slide 6

Slide 6 text

What is Terraform? Terraform is a tool for managing infrastructure as code You can version your infrastructure in Git, create resources from pull requests or fork infrastructure you like.

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Terraform - Designed for infrastructure management - Provide declarative way how to define your infrastructure - Support removing resources (has state) - Help you to evolve infrastructure save & predictable way - Work with all major clouds (AWS, Azure, …) - Open Source (18 000 stars on Github) - Can predict costs (Terraform Enterprise)

Slide 9

Slide 9 text

Why Terraform? and not Ansible, Puppet, ... Terraform is better with Ansible, Puppet, ... - Terraform is not a configuration management tool, Ansible or Puppet do it and do it pretty good - Terraform work with configuration management tool - Terraform creates infrastructure and run CM tool for setting up the resources

Slide 10

Slide 10 text

How Terraform works Terraform compare actual infrastructure (stored in local or remote state) and infrastructure you want (in .tf files). Then apply (create, update or remove) the differences.

Slide 11

Slide 11 text

Configuration Language

Slide 12

Slide 12 text

Providers A provider is responsible for understanding API interactions and exposing resources. Providers generally are an IaaS (e.g. AWS, GCP, Azure, OpenStack) or SaaS services (e.g. CloudFlare, Gitlab).

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Resources Terraform is used to create, manage, and update infrastructure resources such as physical machines, VMs, network switches, containers, and more. Almost any infrastructure type can be represented as a resource in Terraform.

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Data Sources Data sources allow data to be fetched or computed for use elsewhere in Terraform configuration. Use of data sources allows a Terraform configuration to make use of information defined outside of Terraform, or defined by another separate Terraform configuration.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Modules A module is a container for multiple resources that are used together.

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Backends A "backend" in Terraform determines how state is loaded and how an operation such as apply is executed. This abstraction enables non-local file state storage, remote execution, etc. Why remote state / backend? - Working in a team - Remote operations (CI/CD)

Slide 22

Slide 22 text

Terraform CLI

Slide 23

Slide 23 text

Terraform CLI - terraform init - download plugins & setup modules - terraform plan - show & prepare changes of infrastructure - terraform apply - apply new version of infrastructure - terraform destroy - destroy your infrastructure

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Demo Time

Slide 30

Slide 30 text

ondrej-sika.cz/repozitare/#terraform

Slide 31

Slide 31 text

Thank you & Questions Ondrej Sika email: [email protected] www: https://ondrej-sika.cz twitter: @ondrejsika linkedin: /in/ondrejsika/ Slides: https://sika.link/linuxdays2019