Tutorial Tutorial Tutorial Application Services Application Services Application Services ~24 phút ~24 min ~24 នាទី Đồng bộ 2026-06-10 Synced 2026-06-10 ធ្វើសមកាល 2026-06-10

Giới thiệu về Terraform init Introduction to Terraform init ការចូលទៅក្នុង Terraform init

Hướng dẫn chi tiết đồng bộ từ docs Cloudflare — mỗi section có backlink tới đúng vị trí trên trang gốc. Detailed guide synced from Cloudflare docs — each section links to the matching anchor on the official page. មគ្គុទ្ទេសក៍លម្អិតធ្វើសមកាលពី docs Cloudflare — ផ្នែកនីមួយៗមានតំណទៅទីតាំងត្រូវគ្នានៅទំព័រផ្លូវការ។

← Danh mục ← Catalog ← បញ្ជី

Giải thích nhanh Quick context បរិបទរហ័ស

Thuộc nhóm Application Services — tập trung bảo vệ, tăng tốc và vận hành ứng dụng/web phía trước origin. Tutorial «1 – Initialize Terraform» giúp bạn làm quen luồng triển khai thật — phù hợp đọc trước khi mở tài liệu gốc tiếng Anh. Docs gốc chia khoảng 3 bước chính; bản tóm tắt dưới đây giúp bạn nắm khung trước khi làm theo từng lệnh.

This tutorial shows you how to get started with Terraform. You will create a DNS record pointing www.example.com to a web server at 203.0.113.10.

វគ្គបណ្តុះបណ្តាលនេះបង្ហាញអ្នកពីរបៀបដើម្បី get started ជាមួយ Terraform ។ អ្នកនឹងបង្កើតឯកសារ DNS ដែលបង្ហាញ www.example.com ទៅលើបណ្តាញនៅ 203.0.113.10 ។

Lưu ý Note ចំណាំ

Lưu ý trước khi làm Notes before you start ចំណាំមុនពេលចាប់ផ្តើម

  • Đây là bản tóm tắt trên Orange Cloud Learning Hub — không thay thế tài liệu chính thức.
  • Luôn mở liên kết «Tài liệu gốc» bên dưới khi cần lệnh CLI, snippet code và ảnh minh họa đầy đủ.
  • Kiểm tra token/API và state backend trước khi chạy trên môi trường production.
  • Docs Cloudflare cập nhật thường xuyên — đối chiếu ngày «Rà soát lần cuối» trên trang gốc khi triển khai production.
  • This is a summary on Orange Cloud Learning Hub — it does not replace the official documentation.
  • Open the Official docs link below for CLI commands, code snippets, and full screenshots.
  • Verify API tokens and the state backend before running against production.
  • Cloudflare docs change frequently — verify the Last reviewed date on the official page before production use.
  • នេះគឺជាការបញ្ជាក់អំពី Orange Cloud Learning Hub — វាគឺជាការផ្លាស់ប្តូរនៃឯកសារផ្លូវការ។
  • ចុចតំណភ្ជាប់ Docs Official នៅខាងក្រោមសម្រាប់ការបញ្ជា CLI, សៀវភៅកូដនិងរូបថតពេញលេញ។
  • សូមពិនិត្យមើល API tokens និងការបង្វិលប្រព័ន្ធប្រតិបត្តិការមុនពេលធ្វើការប្រឆាំងនឹងការផលិត។
  • Cloudflare បានផ្លាស់ប្តូរជាធម្មតានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅ។

Overview Overview Overview

Tutorial này hướng dẫn bạn get started with Terraform. You just signed up your domain ( example.com ) on Cloudflare to manage everything in Terraform and now you will create a DNS record pointing www.example.com to a web server at 203.0.113.10 .

Read the "Overview" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «Overview» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Hướng dẫn này cho bạn thấy làm thế nào để get started với Terraform. Bạn vừa đăng ký tên miền của mình (example.com) trên Cloudflare để quản lý mọi thứ trong Terraform và bây giờ bạn sẽ tạo một bản ghi DNS chỉ www.example.com đến một máy chủ web tại 203.0.113.10.
This tutorial shows you how to get started with Terraform. You just signed up your domain (example.com) on Cloudflare to manage everything in Terraform and now you will create a DNS record pointing www.example.com to a web server at 203.0.113.10.
វគ្គបណ្តុះបណ្តាលនេះបង្ហាញអ្នកពីរបៀបដើម្បី get started ជាមួយ Terraform ។ ប្រសិនបើអ្នកបានចុះឈ្មោះអាសយដ្ឋានរបស់អ្នក (example.com) នៅ Cloudflare ដើម្បីគ្រប់គ្រងទាំងអស់នៅក្នុង Terraform ហើយឥឡូវនេះអ្នកនឹងបង្កើតអាសយដ្ឋាន DNS ដែលបង្ហាញ www.example.com ទៅលើបណ្តាញនៅ 203.0.113.10 ។
Trước khi bạn bắt đầu, hãy chắc chắn rằng bạn có:
Before you begin, ensure you have:
មុនពេលដែលអ្នកចាប់ផ្តើម, សូមធានាថាអ្នកមាន:
  • Installed Terraform
  • Created an API Token ជាមួយនឹងការអនុញ្ញាតឱ្យធ្វើតេស្តឧបករណ៍សម្រាប់ការធ្វើតេស្តនេះ
Các đoạn mã Terraform dưới đây chỉ đề cập đến v5 SDK.
Terraform code snippets below refer to the v5 SDK only.
Terraform សៀវភៅកូដខាងក្រោមបង្ហាញតែសម្រាប់ SDK v5 ។

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs) តំណពាក់ព័ន្ធ (docs Cloudflare)

1.Điều Tạo cấu hình của bạn 1. Create your configuration 1 ។ បានបង្កើត Configuration របស់អ្នក

Tạo file named main.tf , filling in your own values for the API token , zone ID , account ID , and domain :

Read the "1. Create your configuration" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «1 ។ បានបង្កើត Configuration របស់អ្នក» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Tạo tệp có tên main.tf, điền các giá trị của riêng bạn cho API token, zone ID, account ID và domain:
Create a file named main.tf, filling in your own values for the API token, zone ID, account ID, and domain:
បានបង្កើតឯកសារដែលមានឈ្មោះ main.tf និងបំពេញតម្លៃរបស់អ្នកសម្រាប់ API token, zone ID, account ID និង domain:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform {

  required_providers {

    cloudflare = {

      source  = "cloudflare/cloudflare"

      version = "~> 5"

    }

  }

}


provider "cloudflare" {

  api_token = "<YOUR_API_TOKEN>"

}


variable "zone_id" {

  default = "<YOUR_ZONE_ID>"

}


variable "account_id" {

  default = "<YOUR_ACCOUNT_ID>"

}


variable "domain" {

  default = "<YOUR_DOMAIN>"

}


resource "cloudflare_dns_record" "www" {

  zone_id = "<YOUR_ZONE_ID>"

  name    = "www"

  content = "203.0.113.10"

  type    = "A"

  ttl     = 1

  proxied = true

  comment = "Domain verification record"

}
Warning
Warning
Warning
Để ngăn chặn việc vô tình tiết lộ thông tin nhận dạng Cloudflare của bạn, đừng lưu tệp này vào hệ thống kiểm soát phiên bản của bạn. next tutorial sẽ bao gồm các thực tiễn tốt nhất để vượt qua trong mã thông báo API của bạn.
To prevent accidentally exposing your Cloudflare credentials, do not save this file in your version control system. The next tutorial will cover best practices for passing in your API token.
ដើម្បីជួសជុលការបង្ហាញ Cloudflare របស់អ្នកដោយប្រសិនបើគួរឱ្យចាប់អារម្មណ៍ទេ, សូមមិនសរសេរឯកសារនេះនៅក្នុងប្រព័ន្ធគ្រប់គ្រងកំណែរបស់អ្នក។ next tutorial នឹងគ្របដណ្តប់ការអនុវត្តល្អបំផុតសម្រាប់ការផ្លាស់ប្តូរនៅក្នុង API token របស់អ្នក។

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs) តំណពាក់ព័ន្ធ (docs Cloudflare)

2.Đối với Bắt đầu và lập kế hoạch 2. Initialize and plan 2 ។ ការចាប់ផ្តើមនិងការរចនា

Phần «Khởi tạo và plan» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "2. Initialize and plan" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «2 ។ ការចាប់ផ្តើមនិងការរចនា» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Bắt đầu Terraform để tải về nhà cung cấp Cloudflare:
Initialize Terraform to download the Cloudflare provider:
ការចាប់ផ្តើម Terraform ដើម្បីទាញយកក្រុមហ៊ុនផ្គត់ផ្គង់ Cloudflare:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform init
Xem xét những gì sẽ được tạo ra:
Review what will be created:
សូមពិនិត្យមើលអ្វីដែលនឹងត្រូវបានបង្កើត:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform plan
text
Terraform used the selected providers to generate the following execution plan. Resource actions are

indicated with the following symbols:

  + create


Terraform will perform the following actions:


  # cloudflare_dns_record.www will be created

  + resource "cloudflare_dns_record" "www" {

      + comment             = "Domain verification record"

      + comment_modified_on = (known after apply)

      + content             = "203.0.113.10"

      + created_on          = (known after apply)

      + id                  = (known after apply)

      + meta                = (known after apply)

      + modified_on         = (known after apply)

      + name                = "www"

      + proxiable           = (known after apply)

      + proxied             = true

      + settings            = (known after apply)

      + tags                = (known after apply)

      + tags_modified_on    = (known after apply)

      + ttl                 = 1

      + type                = "A"

      + zone_id             = "<YOUR_ZONE_ID>"

    }


Plan: 1 to add, 0 to change, 0 to destroy.

3 Cái Ứng dụng và Verify 3. Apply and verify 3 ។ ការអនុវត្តនិងការត្រួតពិនិត្យ

Phần «Apply và verify» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "3. Apply and verify" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «3 ។ ការអនុវត្តនិងការត្រួតពិនិត្យ» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Sử dụng cấu hình của bạn:
Apply your configuration:
សូមអនុវត្តទម្រង់របស់អ្នក:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform apply
Nhấn yes khi được nhắc.
Type yes when prompted.
ទាញយក yes នៅពេលដែលអ្នកកំពុងទាញយក
text
Terraform used the selected providers to generate the following execution plan. Resource actions are

indicated with the following symbols:

  + create


Terraform will perform the following actions:


  # cloudflare_dns_record.www will be created

  + resource "cloudflare_dns_record" "www" {

      + comment             = "Domain verification record"

      + comment_modified_on = (known after apply)

      + content             = "203.0.113.10"

      + created_on          = (known after apply)

      + id                  = (known after apply)

      + meta                = (known after apply)

      + modified_on         = (known after apply)

      + name                = "www"

      + proxiable           = (known after apply)

      + proxied             = true

      + settings            = (known after apply)

      + tags                = (known after apply)

      + tags_modified_on    = (known after apply)

      + ttl                 = 1

      + type                = "A"

      + zone_id             = "<YOUR_ZONE_ID>"

    }


Plan: 1 to add, 0 to change, 0 to destroy.


Do you want to perform these actions?

  Terraform will perform the actions described above.

  Only 'yes' will be accepted to approve.


  Enter a value: yes


cloudflare_dns_record.www: Creating...

cloudflare_dns_record.www: Creation complete after 0s


Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Sau khi tạo, hãy xác minh bản ghi DNS:
After creation, verify the DNS record:
បន្ទាប់ពីការបង្កើត, សូមបញ្ជាក់ DNS ដំណឹង:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
dig www.example.com
Kiểm tra phản ứng của máy chủ web:
Test the web server response:
ការធ្វើតេស្តអត្ថប្រយោជន៍របស់អតិថិជន Web Server:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
curl https://www.example.com
text
Hello, this is 203.0.113.10!
Để xem kết quả đầy đủ được trả về từ cuộc gọi API:
To see the full results returned from the API call:
ដើម្បីមើលលទ្ធផលពេញលេញដែលបានបង្ហាញពីការហៅ API:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform show
Bạn cũng có thể kiểm tra bảng điều khiển Cloudflare và đi đến trang DNS \> Records.
You can also check the Cloudflare dashboard and go to the DNS \> Records page.
អ្នកអាចពិនិត្យមើលប្រព័ន្ធប្រតិបត្តិការ Cloudflare ហើយចូលទៅក្នុងទំព័រ DNS \> Records ។
json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/terraform/","name":"Terraform"}},{"@type":"ListItem","position":3,"item":{"@id":"/terraform/tutorial/","name":"Tutorials"}},{"@type":"ListItem","position":4,"item":{"@id":"/terraform/tutorial/initialize-terraform/","name":"1 –  Initialize Terraform"}}]}

Xem bản đầy đủ trên developers.cloudflare.com (ảnh, tab cấu hình). View the full guide on developers.cloudflare.com (images, config tabs). មើលមគ្គុទ្ទេសក៍ពេញលើ developers.cloudflare.com (រូបភាព, tab កំណត់)។

Tài liệu gốc ↗ Official docs ↗ ឯកសារផ្លូវការ ↗