SlideShare una empresa de Scribd logo
1 de 20
Infraestructura como código
Terraform
Victor Adsuar - Arquitecto Cloud
victor@victorasuar.com
https://victoradsuar.com
twitter: @victoradsuar
Me presento
Bienvenidos a la gestión de
infraestructura como código
¿Qué es Terraform?
Producto Open Source de Hashicorp
- Open Source (Mozilla Public License 2.0)
- Sencillo de usar. (HCL)
- Compatible con plataformas de
virtualización y nube
- Planes de ejecución para su versionado
- Gráfico dependencias
Características de Terraform:
- Linux 32 y 64 bits, and ARM.
- Mac Os X, 32 y 64 bits.
- FreeBSD 32 y 64 bits.
- OpenBSD 32 y 64 bits.
- Illumos Distributions 64 bits
- Windows 32 y 64 bits.
¿Dónde podemos instalar Terraform?
- Linux 32 y 64 bits, and ARM.
- Mac Os X, 32 y 64 bits.
- FreeBSD 32 y 64 bits.
- OpenBSD 32 y 64 bits.
- Illumos Distributions 64 bits
- Windows 32 y 64 bits.
¿Dónde podemos instalar Terraform?
Instalación Linux
$ wget https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_linux_amd64.zip
$ unzip https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_linux_amd64.zip
$ sudo mv terraform /usr/local/bin
$ chown -R root:root /usr/local/bin/terraform
Instalación Windows
C:> MKDIR terraform
C:> CD terraform
https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_windows_amd64.zip
Add Path $env:Path += ";C:terraform"
Instalación Mac
$ brew install terraform
Comprobar instalación
$ terraform version
Terraform v0.10.0
$ terraform help
terraform help
Usage: terraform [--version] [--help] <command> [args]
Common commands:
apply Builds or changes infrastructure
console Interactive console for Terraform interpolations
destroy Destroy Terraform-managed infrastructure
env Workspace management
fmt Rewrites config files to canonical format
get Download and install modules for the configuration
graph Create a visual graph of Terraform resources
import Import existing infrastructure into Terraform
init Initialize a Terraform working directory
output Read an output from a state file
plan Generate and show an execution plan
providers Prints a tree of the providers used in the configuration
push Upload this Terraform module to Atlas to run
refresh Update local state file against real resources
show Inspect Terraform state or plan
taint Manually mark a resource for recreation
untaint Manually unmark a resource as tainted
validate Validates the Terraform files
version Prints the Terraform version
workspace Workspace management
All other commands:
debug Debug output management (experimental)
force-unlock Manually unlock the terraform state
state Advanced state management
Variables
Modules
Resources
Output
state
Terraform State
/* This is a multi-line comment. This is a multi-line comment. This is a multi-line comment.
This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. */
provider "aws" {
region = "eu-west-1"
}
# This is a single-line comment.
resource "aws_instance" "base" {
ami = "ami-ebd02392"
instance_type = "t2.micro"
}
Ejemplo de ec2.tf
Los parámetros no especificados
cogerá los que AWS tenga
definidos por defecto.
Crear infraestructura
Iniciar Terraform
$ terraform init
Plan
$ terraform plan
$ terraform plan -out base-`date +'%s'`.plan
Crear
$ terraform apply
$ terraform apply base-1503252130.plan
Comprobar
$ terraform show
$ terraform state list
/* This is a multi-line comment. This is a multi-line comment. This is a multi-line comment.
This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. */
provider "aws" {
region = "eu-west-1"
}
# This is a single-line comment.
resource "aws_instance" "base" {
ami = "ami-ebd02392"
instance_type = "t2.micro"
}
resource "aws_eip" "base" {
instance = "${aws_instance.base.id}"
}
Las variables, funciones y atributos
de recursos se referencian
por $ { }
Modificar y Destruir Infraestructura
Modificación
$terraform apply
+ Recurso será añadido
- Recurso será eliminado
-/+ Recurso será eliminado y creado de nuevo
~ Recurso será modificado
Destrucción
$ terraform destroy
Tipo de variables
Strings
“variable "region" {
description = "The AWS
region."
default = "us-east-1"
}”
Maps
“variable "ami" {
type = "map"
default = {
us-east-1 = "ami-0d729a60"
us-west-1 = "ami-7c4b331c"
}
description = "The AMIs to use."
}”
Lists
“variable "security_group_ids"
{
type = "list"
description = "List of
security group IDs."
default = ["sg-4f713c35",
"sg-4f713c35", "sg-4f713c35"]
}”
Carga de variables
Linea de Comando
“terraform plan -var 'access_key=12345 -var
'secret_key=12345”
Desde un fichero (terraform.tfvars)
“access_key = "xyz245"
secret_key = "xyz245"
ami = {
us-east-1 = "ami-0d729a60"
us-west-1 = "ami-7c4b331c"
}”
Variables de Entorno
“TF_VAR_comodin”
$TF_VAR_aws_code = zxy245
Por defecto
“variable "region" {
description = "The AWS region."
default = "eu-west-1"
}”
Módulos
Llamada módulo fichero
module "vpc" {
source = "./modules"
name = "WTFVPC"
cidr = "10.0.0.0/16"
}
Llamada módulo internet
module "vpc" {
source = "github.com/wtf/wtf_vpc
. . .
}
Definición módulo
resource "aws_vpc" "vpc_wtf" {
cidr_block = "${var.cidr}"
enable_dns_hostnames =
"${var.enable_dns_hostnames}"
enable_dns_support =
"${var.enable_dns_support}"
tags {
Name = "${var.name}"
}
}
Aprovisionamiento de Stack
Infraestructura
Imágen
User-Data
Ansible, Puppet,
Chef, etc...
Vamos a desplegar!
Muchas gracias

Más contenido relacionado

La actualidad más candente

Configuration management II - Terraform
Configuration management II - TerraformConfiguration management II - Terraform
Configuration management II - TerraformXavier Serrat Bordas
 
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
 
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...Amazon Web Services
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To TerraformSasitha Iresh
 
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)Adin Ermie
 
Microsoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformMicrosoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformAlex Mags
 
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 modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
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)Adin Ermie
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformKnoldus Inc.
 

La actualidad más candente (20)

Final terraform
Final terraformFinal terraform
Final terraform
 
Configuration management II - Terraform
Configuration management II - TerraformConfiguration management II - Terraform
Configuration management II - 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
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
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...
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To 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)
 
Terraform
TerraformTerraform
Terraform
 
Microsoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformMicrosoft Azure IaaS and Terraform
Microsoft Azure IaaS and Terraform
 
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 modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
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)
 
Introduce to Terraform
Introduce to TerraformIntroduce to Terraform
Introduce to Terraform
 
Terraform day1
Terraform day1Terraform day1
Terraform day1
 
Terraform
TerraformTerraform
Terraform
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 

Similar a Terraform infraestructura como código

Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform TrainingYevgeniy Brikman
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipelineAnton Babenko
 
Terraform at Scale - All Day DevOps 2017
Terraform at Scale - All Day DevOps 2017Terraform at Scale - All Day DevOps 2017
Terraform at Scale - All Day DevOps 2017Jonathon Brouse
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your TeamGR8Conf
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformAdin Ermie
 
"Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ..."Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ...Anton Babenko
 
leboncoin DataEngineering / Terraform - beginner to advanced
leboncoin DataEngineering / Terraform - beginner to advancedleboncoin DataEngineering / Terraform - beginner to advanced
leboncoin DataEngineering / Terraform - beginner to advancedleboncoin engineering
 
Introductory Overview to Managing AWS with Terraform
Introductory Overview to Managing AWS with TerraformIntroductory Overview to Managing AWS with Terraform
Introductory Overview to Managing AWS with TerraformMichael Heyns
 
A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices Nebulaworks
 
Terraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentTerraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentZane Williamson
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache MesosJoe Stein
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...NETWAYS
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache MesosJoe Stein
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSYevgeniy Brikman
 
Using Terraform to manage the configuration of a Cisco ACI fabric.
Using Terraform to manage the configuration of a Cisco ACI fabric.Using Terraform to manage the configuration of a Cisco ACI fabric.
Using Terraform to manage the configuration of a Cisco ACI fabric.Joel W. King
 
Workshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - SuestraWorkshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - SuestraMario IC
 
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?Katherine Golovinova
 

Similar a Terraform infraestructura como código (20)

London HUG 12/4
London HUG 12/4London HUG 12/4
London HUG 12/4
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
Terraform at Scale - All Day DevOps 2017
Terraform at Scale - All Day DevOps 2017Terraform at Scale - All Day DevOps 2017
Terraform at Scale - All Day DevOps 2017
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
"Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ..."Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ...
 
leboncoin DataEngineering / Terraform - beginner to advanced
leboncoin DataEngineering / Terraform - beginner to advancedleboncoin DataEngineering / Terraform - beginner to advanced
leboncoin DataEngineering / Terraform - beginner to advanced
 
Terraform in action
Terraform in actionTerraform in action
Terraform in action
 
Introductory Overview to Managing AWS with Terraform
Introductory Overview to Managing AWS with TerraformIntroductory Overview to Managing AWS with Terraform
Introductory Overview to Managing AWS with Terraform
 
A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices
 
Terraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentTerraform Modules and Continuous Deployment
Terraform Modules and Continuous Deployment
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
 
An intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECSAn intro to Docker, Terraform, and Amazon ECS
An intro to Docker, Terraform, and Amazon ECS
 
Using Terraform to manage the configuration of a Cisco ACI fabric.
Using Terraform to manage the configuration of a Cisco ACI fabric.Using Terraform to manage the configuration of a Cisco ACI fabric.
Using Terraform to manage the configuration of a Cisco ACI fabric.
 
Workshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - SuestraWorkshop Infrastructure as Code - Suestra
Workshop Infrastructure as Code - Suestra
 
Terraform day02
Terraform day02Terraform day02
Terraform day02
 
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?
 

Más de Victor Adsuar

AWS Valencia Meetup v2
AWS Valencia Meetup v2AWS Valencia Meetup v2
AWS Valencia Meetup v2Victor Adsuar
 
AWS Valencia Meetup v3
AWS Valencia Meetup v3AWS Valencia Meetup v3
AWS Valencia Meetup v3Victor Adsuar
 
AWS Cloud Levante Meetup 2v
AWS Cloud Levante Meetup 2vAWS Cloud Levante Meetup 2v
AWS Cloud Levante Meetup 2vVictor Adsuar
 
Data Beers ALC 15 mayo 2019
Data Beers ALC 15 mayo 2019Data Beers ALC 15 mayo 2019
Data Beers ALC 15 mayo 2019Victor Adsuar
 
Cloud Levante MeetUp V3
Cloud Levante MeetUp V3Cloud Levante MeetUp V3
Cloud Levante MeetUp V3Victor Adsuar
 
Integración y migración a aws
Integración y migración a awsIntegración y migración a aws
Integración y migración a awsVictor Adsuar
 

Más de Victor Adsuar (6)

AWS Valencia Meetup v2
AWS Valencia Meetup v2AWS Valencia Meetup v2
AWS Valencia Meetup v2
 
AWS Valencia Meetup v3
AWS Valencia Meetup v3AWS Valencia Meetup v3
AWS Valencia Meetup v3
 
AWS Cloud Levante Meetup 2v
AWS Cloud Levante Meetup 2vAWS Cloud Levante Meetup 2v
AWS Cloud Levante Meetup 2v
 
Data Beers ALC 15 mayo 2019
Data Beers ALC 15 mayo 2019Data Beers ALC 15 mayo 2019
Data Beers ALC 15 mayo 2019
 
Cloud Levante MeetUp V3
Cloud Levante MeetUp V3Cloud Levante MeetUp V3
Cloud Levante MeetUp V3
 
Integración y migración a aws
Integración y migración a awsIntegración y migración a aws
Integración y migración a aws
 

Último

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 WorkerThousandEyes
 
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 CVKhem
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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)wesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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 FresherRemote DBA Services
 
🐬 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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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 Takeoffsammart93
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Último (20)

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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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...
 
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...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Terraform infraestructura como código

  • 2. Victor Adsuar - Arquitecto Cloud victor@victorasuar.com https://victoradsuar.com twitter: @victoradsuar Me presento
  • 3. Bienvenidos a la gestión de infraestructura como código ¿Qué es Terraform?
  • 4. Producto Open Source de Hashicorp
  • 5. - Open Source (Mozilla Public License 2.0) - Sencillo de usar. (HCL) - Compatible con plataformas de virtualización y nube - Planes de ejecución para su versionado - Gráfico dependencias Características de Terraform:
  • 6. - Linux 32 y 64 bits, and ARM. - Mac Os X, 32 y 64 bits. - FreeBSD 32 y 64 bits. - OpenBSD 32 y 64 bits. - Illumos Distributions 64 bits - Windows 32 y 64 bits. ¿Dónde podemos instalar Terraform?
  • 7. - Linux 32 y 64 bits, and ARM. - Mac Os X, 32 y 64 bits. - FreeBSD 32 y 64 bits. - OpenBSD 32 y 64 bits. - Illumos Distributions 64 bits - Windows 32 y 64 bits. ¿Dónde podemos instalar Terraform?
  • 8. Instalación Linux $ wget https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_linux_amd64.zip $ unzip https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_linux_amd64.zip $ sudo mv terraform /usr/local/bin $ chown -R root:root /usr/local/bin/terraform Instalación Windows C:> MKDIR terraform C:> CD terraform https://releases.hashicorp.com/terraform/0.10.0/terraform_0.10.0_windows_amd64.zip Add Path $env:Path += ";C:terraform" Instalación Mac $ brew install terraform
  • 9. Comprobar instalación $ terraform version Terraform v0.10.0 $ terraform help terraform help Usage: terraform [--version] [--help] <command> [args] Common commands: apply Builds or changes infrastructure console Interactive console for Terraform interpolations destroy Destroy Terraform-managed infrastructure env Workspace management fmt Rewrites config files to canonical format get Download and install modules for the configuration graph Create a visual graph of Terraform resources import Import existing infrastructure into Terraform init Initialize a Terraform working directory output Read an output from a state file plan Generate and show an execution plan providers Prints a tree of the providers used in the configuration push Upload this Terraform module to Atlas to run refresh Update local state file against real resources show Inspect Terraform state or plan taint Manually mark a resource for recreation untaint Manually unmark a resource as tainted validate Validates the Terraform files version Prints the Terraform version workspace Workspace management All other commands: debug Debug output management (experimental) force-unlock Manually unlock the terraform state state Advanced state management
  • 11. /* This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. */ provider "aws" { region = "eu-west-1" } # This is a single-line comment. resource "aws_instance" "base" { ami = "ami-ebd02392" instance_type = "t2.micro" } Ejemplo de ec2.tf Los parámetros no especificados cogerá los que AWS tenga definidos por defecto.
  • 12. Crear infraestructura Iniciar Terraform $ terraform init Plan $ terraform plan $ terraform plan -out base-`date +'%s'`.plan Crear $ terraform apply $ terraform apply base-1503252130.plan Comprobar $ terraform show $ terraform state list
  • 13. /* This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. This is a multi-line comment. */ provider "aws" { region = "eu-west-1" } # This is a single-line comment. resource "aws_instance" "base" { ami = "ami-ebd02392" instance_type = "t2.micro" } resource "aws_eip" "base" { instance = "${aws_instance.base.id}" } Las variables, funciones y atributos de recursos se referencian por $ { }
  • 14. Modificar y Destruir Infraestructura Modificación $terraform apply + Recurso será añadido - Recurso será eliminado -/+ Recurso será eliminado y creado de nuevo ~ Recurso será modificado Destrucción $ terraform destroy
  • 15. Tipo de variables Strings “variable "region" { description = "The AWS region." default = "us-east-1" }” Maps “variable "ami" { type = "map" default = { us-east-1 = "ami-0d729a60" us-west-1 = "ami-7c4b331c" } description = "The AMIs to use." }” Lists “variable "security_group_ids" { type = "list" description = "List of security group IDs." default = ["sg-4f713c35", "sg-4f713c35", "sg-4f713c35"] }”
  • 16. Carga de variables Linea de Comando “terraform plan -var 'access_key=12345 -var 'secret_key=12345” Desde un fichero (terraform.tfvars) “access_key = "xyz245" secret_key = "xyz245" ami = { us-east-1 = "ami-0d729a60" us-west-1 = "ami-7c4b331c" }” Variables de Entorno “TF_VAR_comodin” $TF_VAR_aws_code = zxy245 Por defecto “variable "region" { description = "The AWS region." default = "eu-west-1" }”
  • 17. Módulos Llamada módulo fichero module "vpc" { source = "./modules" name = "WTFVPC" cidr = "10.0.0.0/16" } Llamada módulo internet module "vpc" { source = "github.com/wtf/wtf_vpc . . . } Definición módulo resource "aws_vpc" "vpc_wtf" { cidr_block = "${var.cidr}" enable_dns_hostnames = "${var.enable_dns_hostnames}" enable_dns_support = "${var.enable_dns_support}" tags { Name = "${var.name}" } }

Notas del editor

  1. Agradecimientos: Amazon Web Service. Grupo de usuarios de Valencia. CloudLevante: Lynxview y Devopensource.
  2. Ingeniero con algunos años de experiencia en proyectos tecnológicos y 6 años inmerso en proyectos cloud. Después de trabajar en diferentes empresas di un gran salto a trabajar con las personas con las que me identifico con mis valores. Sabes que estás en el camino correcto cuando interiormente tu dejas de ser un obstáculo para avanzar día a día. Cuando los lunes te despiertas con una sonrisa sabes que estás haciendo las cosas bien.
  3. Introducción a la infraestructura como código. La virtualización inició este movimiento, pero el cloud lo está acelerando.
  4. Terraform es un producto creado por Hashicorp para la creación y administración de infraestructura como código. Además incluye otros productos como Vagrant, Packer, Vault, Consul y Nomad. En el caso de infraestructura tenemos Vagrant, Terraform y Packer. Hoy nos centraremos en el uso de Terraform para la administración
  5. Terraform es casi compatible con todo y muy fácil de instalar
  6. Terraform es casi compatible con todo y muy fácil de instalar
  7. Terraform es casi compatible con todo y muy fácil de instalar
  8. La instalación de Terraform es muy simple en todos los sistemas operativos disponibles
  9. La instalación de Terraform es muy simple en todos los sistemas operativos disponibles
  10. Cómo funciona Terraform?
  11. Ejemplo de un fichero terraform básico.
  12. Ejemplo de un fichero terraform básico.
  13. L