Chuyển đến nội dung chính

Terraform: Terraform là gì? - Part 1

Terraform là gì?

Terraform là một công cụ nguồn mở, được phát triển bởi HashiCorp, dùng để quản lý cơ sở hạ tầng dưới dạng mã (IaC - Infrastructure as Code). Công cụ này cho phép người dùng định nghĩa, xây dựng, thay đổi và quản lý các tài nguyên như máy chủ, mạng và cơ sở dữ liệu một cách tự động bằng cách viết các tệp cấu hình. Terraform giúp tự động hóa việc cung cấp và cập nhật cơ sở hạ tầng, kể cả trên nhiều nhà cung cấp đám mây khác nhau. 

Hiểu đơn giản

Thay vì bạn phải:

Vào Azure Portal → click tạo VM, network, resource group…

➡️ Với Terraform, bạn viết file .tf (Terraform file) để mô tả mọi thứ.

Cài đặt

Terraform hỗ trợ nhiều hệ điều hành khác nhau như Windows, Linux, MacOS, Solaris, FreeBSD và OpenBSD... Bài viết này sẽ hướng dẫn các bạn cài trên hệ điều hành Windows

Download: https://developer.hashicorp.com/terraform/install

Phần tải Terraform cho Windows, với hai tùy chọn:

  • 386 → dành cho máy 32-bit
  • AMD64 → dành cho máy 64-bit (các CPU hiện đại: Intel, AMD, Ryzen, v.v.) 

Sau khi tải xong:

  • Giải nén file .zip
  • Copy file terraform.exe vào thư mục (ví dụ: D:\apps\terraform\)
  • Thêm đường dẫn đó vào Environment Variables → PATH

Thêm đường dẫn (PATH) vào hệ thống

Để bạn có thể chạy terraform ở bất kỳ đâu (cmd, PowerShell, VS Code...), bạn cần thêm đường dẫn D:\apps\terraform vào Environment Variables.

Bấm Start → gõ “environment” → chọn “Edit the system environment variables”

Trong cửa sổ System Properties, bấm Environment Variables... 

Trong phần System variables, tìm biến tên Path, chọn Edit

D:\apps\terraform

Mở cmd hoặc PowerShell, gõ lệnh kiểm tra

>terraform -version
Terraform v1.13.4
on windows_amd64
Để xem danh sách các commands có trong terraform có thể sử dụng lệnh terraform -help
>terraform -help
Usage: terraform [global options] <subcommand> [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main commands:
  init          Prepare your working directory for other commands
  validate      Check whether the configuration is valid
  plan          Show changes required by the current configuration
  apply         Create or update infrastructure
  destroy       Destroy previously-created infrastructure

All other commands:
  console       Try Terraform expressions at an interactive command prompt
  fmt           Reformat your configuration in the standard style
  force-unlock  Release a stuck lock on the current workspace
  get           Install or upgrade remote Terraform modules
  graph         Generate a Graphviz graph of the steps in an operation
  import        Associate existing infrastructure with a Terraform resource
  login         Obtain and save credentials for a remote host
  logout        Remove locally-stored credentials for a remote host
  metadata      Metadata related commands
  modules       Show all declared modules in a working directory
  output        Show output values from your root module
  providers     Show the providers required for this configuration
  refresh       Update the state to match remote systems
  show          Show the current state or a saved plan
  stacks        Manage HCP Terraform stack operations
  state         Advanced state management
  taint         Mark a resource instance as not fully functional
  test          Execute integration tests for Terraform modules
  untaint       Remove the 'tainted' state from a resource instance
  version       Show the current Terraform version
  workspace     Workspace management

Global options (use these before the subcommand, if any):
  -chdir=DIR    Switch to a different working directory before executing the
                given subcommand.
  -help         Show this help output or the help for a specified subcommand.
  -version      An alias for the "version" subcommand.

 

Nhận xét

Bài đăng phổ biến từ blog này

[ASP.NET MVC] Authentication và Authorize

Một trong những vấn đề bảo mật cơ bản nhất là đảm bảo những người dùng hợp lệ truy cập vào hệ thống. ASP.NET đưa ra 2 khái niệm: Authentication và Authorize Authentication xác nhận bạn là ai. Ví dụ: Bạn có thể đăng nhập vào hệ thống bằng username và password hoặc bằng ssh. Authorization xác nhận những gì bạn có thể làm. Ví dụ: Bạn được phép truy cập vào website, đăng thông tin lên diễn đàn nhưng bạn không được phép truy cập vào trang mod và admin.

ASP.NET MVC: Cơ bản về Validation

Validation (chứng thực) là một tính năng quan trọng trong ASP.NET MVC và được phát triển trong một thời gian dài. Validation vắng mặt trong phiên bản đầu tiên của asp.net mvc và thật khó để tích hợp 1 framework validation của một bên thứ 3 vì không có khả năng mở rộng. ASP.NET MVC2 đã hỗ trợ framework validation do Microsoft phát triển, tên là Data Annotations. Và trong phiên bản 3, framework validation đã hỗ trợ tốt hơn việc xác thực phía máy khách, và đây là một xu hướng của việc phát triển ứng dụng web ngày nay.

Tổng hợp một số kiến thức lập trình về Amibroker

Giới thiệu về Amibroker Amibroker theo developer Tomasz Janeczko được xây dựng dựa trên ngôn ngữ C. Vì vậy bộ code Amibroker Formula Language sử dụng có syntax khá tương đồng với C, ví dụ như câu lệnh #include để import hay cách gói các object, hàm trong các block {} và kết thúc câu lệnh bằng dấu “;”. AFL trong Amibroker là ngôn ngữ xử lý mảng (an array processing language). Nó hoạt động dựa trên các mảng (các dòng/vector) số liệu, khá giống với cách hoạt động của spreadsheet trên excel.