Terraform es una de las mejores infraestructuras como herramienta de código que existen. Le permite crear, modificar y expandir estructuras de forma segura en los proveedores de servicios más populares.

Puede usarlo para administrar de manera eficiente la computación en la nube, las redes, los balanceadores de carga y el DNS con el lenguaje de programación declarativo simple. Está disponible en Github. Este artículo proporciona una guía paso a paso sobre cómo instalar Terraform en Ubuntu 18.04 y CentOS 7.

Instale Terraform en Ubuntu 18.04 / CentOS 7

  1. Primero, asegúrese de que wget esté instalado en su PC usando el siguiente comando en la terminal:
$ sudo apt-get install wget # Ubuntu
$ sudo yum install wget # CentOS

  1. Obtenga el archivo de Terraform ahora.
export VER="0.11.8"
wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip

  1. Una vez descargado, extraiga el archivo escribiendo el siguiente comando:
$ sudo apt-get install unzip # Ubuntu
$ sudo yum install unzip     # CentOS 7
$ unzip terraform_${VER}_linux_amd64.zip
Archive:  terraform_0.11.8_linux_amd64.zip
  inflating: terraform

  1. Se ha creado un archivo binario Terraform en el directorio de trabajo. Ahora debe mover el archivo al directorio / usr / local / bin. Ingrese la siguiente línea:
sudo mv terraform /usr/local/bin/

  1. Todos los usuarios de su PC ahora pueden acceder a Terraform. Ingrese estas líneas para verificar la accesibilidad:
$which terraform
/usr/local/bin/terraform

  1. Verifique el número de versión de Terraform.
$ terraform -v
Terraform v0.11.8

  1. Ahora compruebe la funcionalidad de Terraform.
# terraform
Usage: terraform [-version] [-help] <command> [args]

The available commands for execution are listed below.
The most common, useful commands are shown first, followed by
less common or more advanced commands. If you're just getting
started with Terraform, stick with the common commands. For the
other commands, please read the help and docs before usage.

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             Readan 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            Updatelocal 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

Conclusión

Si todo funciona correctamente, Terraform se ha instalado correctamente en su PC. Ahora tiene la oportunidad de configurar, cambiar y combinar la infraestructura de manera eficiente y segura.