Hướng dẫn cài đặt Terraform trên Linux

Hướng dẫn cài đặt Terraform trên LinuxCuongquach.com | Terraform là một trong những công cụ chương trình phục vụ cho mục tiêu ‘Infrastructure as Code‘. ‘Infrastructure as Code‘ là một phương pháp trong đó bạn sẽ viết các đoạn mã để xây dựng hạ tầng cho sản phẩm của mình. Bài viết này nằm trong nội dung thực hành sử dụng Terraform với bước đầu là cài đặt Terraform trên máy chủ Linux để từ đó tương tác với các API dịch vụ Cloud như AWS/Azure bất kì.

cai-dat-terraform-tren-linux
cai-dat-terraform-tren-linux

Cài đặt Terraform trên Linux

Hashicorp cung cấp công cụ terraform dưới dạng binary package hỗ trợ cho rất nhiều kiến trúc và nền tảng khác nhau. Bạn chỉ cần kiểm tra OS của mình là gì ? và tải gói chương trình binary của Terraform phù hợp về là xong.

Trang download: https://www.terraform.io/downloads.html

# cd /opt/
# wget https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip

Cài đặt tool để giải nén.

+ CentOS

# yum install unzip -y

+ Ubuntu

# apt-get install unzip -y

Giải nén file terraform và di chuyển vào thư mục chứa các chương trình khác ($PATH).

# unzip terraform_0.12.2_linux_amd64.zip
Archive: terraform_0.12.2_linux_amd64.zip
inflating: terraform

# mv terraform /usr/bin/

Giờ ta kiểm tra chương trình binary 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             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
    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:
    0.12upgrade        Rewrites pre-0.12 module source code for v0.12
    debug              Debug output management (experimental)
    force-unlock       Manually unlock the terraform state
    push               Obsolete command for Terraform Enterprise legacy (v1)
    state              Advanced state management

Ở nội dung kế tiếp chúng ta sẽ tìm hiểu việc cấu hình Terraform với AWS Credentials để chứng thực quyền truy cập hạ tầng API dịch vụ AWS qua SecretKey/AccessKey tài khoản người dùng.

Nguồn: https://cuongquach.com/

Previous articleEbook Cassandra The Definitive Guide 2nd Edition (PDF)
Next articleEbook Prometheus Up & Running (PDF)
Bạn đang theo dõi website "https://cuongquach.com/" nơi lưu trữ những kiến thức tổng hợp và chia sẻ cá nhân về Quản Trị Hệ Thống Dịch Vụ & Mạng, được xây dựng lại dưới nền tảng kinh nghiệm của bản thân mình, Quách Chí Cường. Hy vọng bạn sẽ thích nơi này !