Terraform Cloud

Terraform GCP – 2. Cài đặt Terraform

terraform 26042021 1

Như chúng ta đã biết, Terrform là một chương trình cho phép quản lý với các hạ tầng Cloud khác nhau. Trong bài viết này, chúng sẽ cùng tìm hiểu cách các cách để cài đặt nó.

Cách 1: Cài đặt từ repository

Cách này phù hợp với những server có kết nối internet.

Đầu tiên, chúng ta sẽ cập nhật lại các repository và cài các chương trình cần thiết.

$ sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl

Tiếp theo, ta sẽ thêm GPG Key của HashiCorp.
$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add –

Thêm official repository của HashiCorp.

$ sudo apt-add-repository “deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main”

Cập nhật lại repository và tiến hành cài đặt Terraform với câu lệnh sau:
$ sudo apt-get update && sudo apt-get install terraform

Xác minh cài đặt

Để xác minh lại quá trình cài đặt, chúng ta sẽ dùng option terraform –help , nó sẽ hiển thị các thông tin như sau.

$ terraform -help

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.

Cách 2: Cài từ file nhị phân

Cách này khá là dễ và nó rất được mọi người ưu chuộng. Chỉ cần tải về file nhị phân là có thể dùng được terraform.
Đầu tiên, chúng ta truy cập https://www.terraform.io/downloads.html chọn và tải về file nhị phân phù hợp với môi trường của bạn.

terraform 20210427

download terraform

 

Sau đó copy file nhị phân vừa download về vào đường dẫn /usr/local/bin/:
mv terraform /usr/local/bin/

Như vậy là xong, rất đơn giản. Chúng ta có thể dễ dàng xác minh lại cài đặt bằng câu lệnh sau:
$ terraform -help

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.

 

congdonglinux.com

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !