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

Nhập Cloudflare tài nguyên Import Cloudflare resources ការនាំចូល Cloudflare សមត្ថភាព

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 «Import Cloudflare resources» 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. Đọc phần tóm tắt và lưu ý trước — sau đó mở docs gốc để copy lệnh và cấu hình chi tiết.

The Cloudflare Terraform tool is available in the Terraform ME repository. To use it, you must first install the Terraform app on your Mac or Linux system. You must then import Cloudflare resources individually by providing their IDs and names.

ឧបករណ៍ Cloudflare Terraform គឺអាចរកបាននៅក្នុង repository Terraform ME ។ ដើម្បីប្រើវាអ្នកត្រូវការដំឡើងកម្មវិធី Terraform នៅលើប្រព័ន្ធ Mac ឬ Linux របស់អ្នក។ បន្ទាប់មកអ្នកត្រូវនាំចូល Cloudflare សមត្ថភាពដោយផ្ទាល់ដោយផ្តល់ ID និងឈ្មោះរបស់ពួកគេ។

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

Phần «Tổng quan» — đọ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 "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 ផ្លូវការ ↗
Một điểm quan trọng để hiểu về Terraform là nó chỉ có thể quản lý cấu hình mà nó đã tạo ra hoặc đã được nói rõ về sau khi thực tế. Lý do cho sự hạn chế này là Terraform hy vọng sẽ có thẩm quyền đối với các tài nguyên mà nó quản lý. Nó dựa vào hai loại tệp để hiểu tài nguyên nào nó kiểm soát và trạng thái nào họ đang ở. Terraform xác định khi nào và làm thế nào để thực hiện thay đổi từ sau:
An important point to understand about Terraform is that it can only manage configuration it created or was explicitly told about after the fact. The reason for this limitation is that Terraform expects to be authoritative for the resources it manages. It relies on two types of files to understand what resources it controls and what state they are in. Terraform determines when and how to make changes from the following:
សំនួរសំខាន់មួយដើម្បីដឹងអំពី Terraform គឺថាវាអាចគ្រប់គ្រងការកំណត់ដែលវាបានបង្កើតឬត្រូវបាននិយាយដោយពិសេសអំពីបន្ទាប់ពីការពិត។ ទោះជាយ៉ាងណាក៏ដោយ Terraform មានអត្ថប្រយោជន៍ក្នុងការគ្រប់គ្រងប្រយោជន៍របស់អ្នក។ វាត្រូវបានផ្លាស់ប្តូរដោយប្រភេទឯកសារទាំងពីរដើម្បីដឹងថាមពលដែលវាគ្រប់គ្រងនិងស្ថានភាពដែលពួកគេមាននៅក្នុង។ Terraform បានកំណត់ពេលដែលនិងរបៀបដើម្បីធ្វើឱ្យការផ្លាស់ប្តូរពីដូចខាងក្រោម:
  • Một configuration file ↗ (kết thúc bằng .tf) xác định cấu hình tài nguyên cho Terraform để quản lý. Đây là những gì bạn đã làm việc với trong các bước hướng dẫn.
  • Một địa phương state file ↗ mà bản đồ tên tài nguyên được xác định trong tệp cấu hình của bạn – ví dụ, cloudflare<em>load</em>balancer.www-lb – đến các tài nguyên tồn tại trong Cloudflare.
  • A configuration file ↗ (ending in .tf) that defines the configuration of resources for Terraform to manage. This is what you worked with in the tutorial steps.
  • A local state file ↗ that maps the resource names defined in your configuration file — for example, cloudflare<em>load</em>balancer.www-lb — to the resources that exist in Cloudflare.
  • configuration file ↗ (បញ្ចប់នៅក្នុង .tf) ដែលបញ្ជាក់ការកំណត់រចនាសម្ព័ន្ធរក្សាសម្ព័ន្ធសម្រាប់ Terraform ដើម្បីគ្រប់គ្រង។ នេះគឺជាអ្វីដែលអ្នកបានធ្វើការនៅក្នុងដំណោះស្រាយ Tutorial ។
  • ទូទៅ state file ↗ ដែលបង្វិលឈ្មោះឧបករណ៍ដែលបានកំណត់នៅក្នុងឯកសារកំណត់របស់អ្នក - ដូចជា cloudflare<em>load</em>balancer.www-lb - ទៅឧបករណ៍ដែលមាននៅក្នុង Cloudflare ។
Khi Terraform thực hiện cuộc gọi đến Cloudflare API để tạo tài nguyên mới như được giải thích trong tutorial, nó giữ những ID đó vào một tệp trạng thái. Theo mặc định, Terraform sử dụng tệp terraform.tfstate trong thư mục của bạn, nhưng đây cũng có thể là một remote location ↗. Những ID này sau đó được nhìn lên và làm mới khi bạn gọi terraform plan và terraform apply.
When Terraform makes calls to Cloudflare's API to create new resources as explained in the tutorial, it persists those IDs to a state file. By default, Terraform uses the terraform.tfstate file in your directory, but this can also be a remote location ↗. These IDs are later looked up and refreshed when you call terraform plan and terraform apply.
នៅពេលដែល Terraform បានធ្វើការទូរស័ព្ទទៅ Cloudflare របស់ API ដើម្បីបង្កើតសារធាតុថ្មីដូចដែលបានបង្ហាញនៅក្នុង tutorial, វាត្រូវបានរក្សាទុក IDs នេះទៅជាឯកសារស្ថានភាព។ ដោយគោលបំណង, Terraform ប្រើឯកសារ terraform.tfstate នៅក្នុងប្រព័ន្ធប្រតិបត្តិការរបស់អ្នកប៉ុន្តែវាអាចជា remote location ↗ ។ ទោះជាយ៉ាងណាក៏ដោយអ៊ីនធឺណិតទាំងនេះត្រូវបានមើលឡើងនិងធ្វើឱ្យប្រសើរឡើងនៅពេលដែលអ្នកចុច terraform plan និង terraform apply ។
Nếu bạn đã cấu hình Cloudflare bằng các phương tiện khác, ví dụ, bằng cách đăng nhập vào bảng điều khiển Cloudflare hoặc thực hiện cuộc gọi curl đến api.cloudflare.com, Terraform chưa có ID tài nguyên này trong tệp trạng thái. Để quản lý cấu hình sẵn có này, bạn sẽ cần phải tái tạo cấu hình trong tệp cấu hình của bạn và sau đó nhập tài nguyên riêng lẻ bằng cách cung cấp ID và tên tài nguyên của họ.
If you configured Cloudflare through other means, for example, by logging in to the Cloudflare dashboard or making curl calls to api.cloudflare.com, Terraform does not yet have these resource IDs in the state file. To manage this preexisting configuration, you will need to first reproduce the configuration in your config file and then import resources individually by providing their IDs and resource names.
ប្រសិនបើអ្នកបានកំណត់ Cloudflare ដោយប្រើវិធីផ្សេងទៀតដូចជាដោយការចូលទៅក្នុងប្រព័ន្ធប្រតិបត្តិការ Cloudflare ឬធ្វើការ curl ទូរស័ព្ទទៅ api.cloudflare.com, Terraform មិនមាន ID សមត្ថភាពទាំងនេះនៅក្នុងឯកសារសកម្មភាព។ ដើម្បីគ្រប់គ្រងការកំណត់រចនាសម្ព័ន្ធដែលមានមុនពេលនេះអ្នកនឹងត្រូវការកំណត់រចនាសម្ព័ន្ធដំបូងនៅក្នុងឯកសារកំណត់រចនាសម្ព័ន្ធរបស់អ្នកហើយបន្ទាប់មកនាំចូលរចនាសម្ព័ន្ធដោយផ្ទាល់ដោយផ្តល់ ID និងឈ្មោះរចនាសម្ព័ន្ធរបស់ពួកគេ។

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

Cf-terraform hóa cf-terraforming Cf-ការផ្លាស់ប្តូរ

Phần «cf-terraforming» — đọ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 "cf-terraforming" section below — open the official docs link for full screenshots and configuration tabs.

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

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
cf-terraforming ↗ giúp khách hàng hiện tại Cloudflare get started với Terraform. Hiện tại, cf-terraforming giúp tạo trạng thái cấu hình Terraform bằng cách lấy tất cả các tài nguyên của một loại được chỉ định từ tài khoản và/hoặc khu vực bạn chọn.
cf-terraforming ↗ helps existing Cloudflare customers get started with Terraform. Currently, cf-terraforming helps to generate the Terraform config state by fetching all the resources of a specified type from the account and/or zone of your choosing.
cf-terraforming ↗ អនុញ្ញាតឱ្យអតិថិជន Cloudflare មាន get started ជាមួយ Terraform ។ ឥឡូវនេះ cf-terraforming អនុញ្ញាតឱ្យបង្កើតសកម្មភាព Terraform ដោយស្វែងរកប្រសិទ្ធិភាពទាំងអស់នៃប្រភេទដែលបានបញ្ជាក់ពីគណនីនិង / ឬតំបន់ដែលអ្នកជ្រើសរើស។

Cài đặt Installation ការដំឡើង

Phần «Installation» — đọ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 "Installation" section below — open the official docs link for full screenshots and configuration tabs.

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

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Trước khi bạn bắt đầu, bạn phải cài đặt cf-terraforming.
Before you start, you must install cf-terraforming.
មុនពេលចាប់ផ្តើមអ្នកត្រូវដំឡើង cf-terraforming ។
Nếu bạn đang sử dụng Homebrew trên macOS, hãy mở một thiết bị đầu cuối và chạy các lệnh sau:
If you use Homebrew on macOS, open a terminal and run the following commands:
ប្រសិនបើអ្នកកំពុងប្រើ Homebrew នៅលើ macOS, ចុចបញ្ចប់បញ្ចប់និងដំណើរការបញ្ចប់ដូចខាងក្រោម:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
brew tap cloudflare/cloudflare

brew install cloudflare/cloudflare/cf-terraforming
Nếu bạn đang sử dụng một hệ điều hành khác, download the latest release ↗ từ kho lưu trữ cf-terraforming GitHub.
If you are using a different OS, download the latest release ↗ from the cf-terraforming GitHub repository.
ប្រសិនបើអ្នកប្រើប្រព័ន្ធប្រតិបត្តិការផ្សេងទៀត, download the latest release ↗ ពី repo cf-terraforming GitHub ។
Để xem tệp trợ giúp, hãy chạy cf-terraforming hoặc cf-terraforming -h.
To view the help file, run cf-terraforming or cf-terraforming -h.
ប្រសិនបើអ្នកចង់មើលឯកសារជំនួយរបស់អ្នក, សូមធ្វើការ cf-terraforming ឬ cf-terraforming -h ។

Sử dụng cơ bản Basic usage ការប្រើប្រាស់មូលដ្ឋាន

Phần «Basic usage» — đọ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 "Basic usage" section below — open the official docs link for full screenshots and configuration tabs.

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

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Để sử dụng cf-terraforming, hãy chỉ định các mục dưới đây:
To use cf-terraforming, specify the items below:
ដើម្បីប្រើ cf-terraforming សូមបញ្ជាក់អត្ថបទខាងក្រោម:
  1. Lệnh để thực hiện (ví dụ: generate hoặc import).
  2. Email của người dùng Cloudflare - --email hoặc -e.
  3. Token của bạn Cloudflare API - --token hoặc -t.
  4. Tài khoản và/hoặc khu vực để rút tài nguyên từ - --account/--zone hoặc -a/-z.
  5. Các tài nguyên Cloudflare để tạo config.
  1. The command to execute (for example, generate or import).
  2. Your Cloudflare user email - --email or -e.
  3. Your Cloudflare API token - --token or -t.
  4. The account and/or zone to pull resources from - --account/--zone or -a/-z.
  5. The Cloudflare resources to generate config.
  1. គោលដៅដើម្បីដំណើរការ (ដូចជា generate ឬ import) ។
  2. អាសយដ្ឋានអ៊ីម៉ែលរបស់អ្នក Cloudflare - --email ឬ -e.
  3. ស្លាករបស់អ្នក Cloudflare API - --token ឬ -t ។
  4. ទិន្នន័យនិង / ឬតំបន់ដើម្បីបាត់បន្ថយសារធាតុពី - --account / --zone ឬ -a / -z.
  5. ការ Cloudflare ឧបករណ៍ដើម្បីបង្កើត config ។
Danh sách các tài nguyên được hỗ trợ có sẵn trong Terraform README ↗.
The list of supported resources is available in the Terraform README ↗.
អាសយដ្ឋានដែលគាំទ្រអាចរកបាននៅក្នុង Terraform README ↗ ។

Nhập tài nguyên hiện có Cloudflare Import existing Cloudflare resources ទិន្នន័យ Cloudflare

Phần «Import existing Cloudflare resources» — đọ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 "Import existing Cloudflare resources" section below — open the official docs link for full screenshots and configuration tabs.

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

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Để bắt đầu quản lý tài nguyên Cloudflare hiện có trong Terraform, ví dụ, DNS bản ghi, bạn cần:
To start managing existing Cloudflare resources in Terraform, for example, DNS records, you need:
ដើម្បីចាប់ផ្តើមគ្រប់គ្រងប្រសិទ្ធិភាព Cloudflare ដែលមាននៅលើ Terraform, ដូចជាប្រសិទ្ធិភាព DNS, អ្នកត្រូវ:
  • Cấu hình Terraform của tài nguyên đó (được định nghĩa trong tệp .tf)
  • Một tệp trạng thái kèm theo Terraform của trạng thái tài nguyên đó (được định nghĩa trong tệp .tfstate)
  • The Terraform configuration of that resource (defined in a .tf file)
  • An accompanying Terraform state file of that resources state (defined in a .tfstate file)
  • ការកំណត់ Terraform នៃ សមត្ថភាពនេះ (កំណត់នៅក្នុងឯកសារ .tf)
  • An accompanying Terraform state file of that resources state (defined in a .tfstate file)

Tạo cấu hình Terraform với cf-terraforming Generate Terraform configuration with cf-terraforming Generate Terraform configuration ជាមួយនឹង cf-terraforming

Phần «Tạo Terraform configuration với cf-terraforming» — đọ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 "Generate Terraform configuration with cf-terraforming" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «Generate Terraform configuration ជាមួយនឹង cf-terraforming» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Nếu bạn không có tệp cấu hình Terraform được xác định, bạn cần khối provider được xác định như sau:
If you do not have a Terraform configuration file defined, you need the provider block defined as follows:
ប្រសិនបើអ្នកមិនមានឯកសារកំណត់កំណត់ Terraform ដែលអ្នកត្រូវការប្លុក provider ដែលត្រូវបានកំណត់ដូចខាងក្រោម:
Các đoạn mã Terraform dưới đây chỉ đề cập đến v4 SDK.
Terraform code snippets below refer to the v4 SDK only.
Terraform សៀវភៅកូដខាងក្រោមបង្ហាញតែសម្រាប់ v4 SDK ។
text
provider 'cloudflare' {

 # Cloudflare email saved in $CLOUDFLARE_EMAIL

 # Cloudflare API token saved in $CLOUDFLARE_API_TOKEN

}
Hãy nhớ giữ thông tin xác thực của bạn được lưu trong các biến môi trường hoặc terraform autovars mà không được kiểm tra vào các tệp nguồn của bạn.
Remember to keep your credentials saved in environment variables or terraform autovars that are not checked into your source files.
សូមចង់រក្សាទុកគោលបំណងរបស់អ្នកនៅក្នុងការផ្លាស់ប្តូរបរិស្ថានឬ terraform autovars ដែលមិនត្រូវបានត្រួតពិនិត្យនៅក្នុងឯកសារប្រភពរបស់អ្នក។
Bắt đầu bằng cách gọi cf-terraforming generate để tạo cấu hình Terraform cho các bản ghi DNS trong khu vực bạn muốn quản lý với Terraform.
Start by making a call to cf-terraforming generate to generate the Terraform configuration for the DNS records in the zone you want to manage with Terraform.
ចាប់ផ្តើមដោយធ្វើការទូរស័ព្ទទៅ cf-terraforming generate ដើម្បីបង្កើតការកំណត់ Terraform សម្រាប់ឯកសារ DNS នៅក្នុងតំបន់ដែលអ្នកចង់គ្រប់គ្រងជាមួយ Terraform ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
cf-terraforming generate --email $CLOUDFLARE_EMAIL --token $CLOUDFLARE_API_TOKEN -z 1109d899a5ff5fd74bc01e581693685b --resource-type cloudflare_record > importing-example.tf
Nếu bạn không chuyển hướng đầu ra sang tệp importing-example.tf, kết quả hiển thị trong đầu ra tiêu chuẩn (cửa sổ đầu cuối của bạn) sẽ trông như sau:
If you had not redirected the output to the importing-example.tf file, the result displayed in the standard output (your terminal window) would look like the following:
ប្រសិនបើអ្នកមិនបានផ្លាស់ប្តូរផលិតផលទៅឯកសារ importing-example.tf, លទ្ធផលដែលបានបង្ហាញនៅក្នុងផលិតផលធម្មតា (ឧបករណ៍បញ្ចប់របស់អ្នក) នឹងមើលដូចខាងក្រោម:
Các đoạn mã Terraform dưới đây chỉ đề cập đến v4 SDK.
Terraform code snippets below refer to the v4 SDK only.
Terraform សៀវភៅកូដខាងក្រោមបង្ហាញតែសម្រាប់ v4 SDK ។
text
resource "cloudflare_record" "terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31" {

    name    = "@"

    type    = "A"

    ttl     = 1

    proxied = true

    value   = "192.0.2.1"

    zone_id = "1109d899a5ff5fd74bc01e581693685b"

}


resource "cloudflare_record" "terraform_managed_resource_5e10399a590a45279f09aa8fb1163354" {

    name    = "www"

    type    = "CNAME"

    ttl     = 1

    proxied = true

    value   = "mitigateddos.net"

    zone_id = "1109d899a5ff5fd74bc01e581693685b"

}


resource "cloudflare_record" "terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248" {

    name    = "a123"

    type    = "NS"

    ttl     = 300

    proxied = false

    value   = "rafe.ns.cloudflare.com"

    zone_id = "1109d899a5ff5fd74bc01e581693685b"

}


resource "cloudflare_record" "terraform_managed_resource_5799bb01054843eea726758f935d2aa2" {

    name    = "a123"

    type    = "NS"

    ttl     = 300

    proxied = false

    value   = "terin.ns.cloudflare.com"

    zone_id = "1109d899a5ff5fd74bc01e581693685b"

}
Gọi terraform plan tại thời điểm này sẽ cố gắng tạo các tài nguyên này như thể chúng không tồn tại, vì chúng không hiện diện trong tệp trạng thái địa phương:
Calling terraform plan at this point will try to create these resources as if they did not exist, since they are not present in the local state file:
ការចែកចាយ terraform plan នៅពេលនេះនឹងធ្វើការដើម្បីបង្កើតសម្ភារៈទាំងនេះដូចជាពួកគេមិនមាននៅពេលដែលពួកគេមិនមាននៅក្នុងឯកសារស្ថានតំបន់:
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_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31 will be created

  + resource "cloudflare_record" "terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31" {

      + id          = (known after apply)>

      + created_on  = (known after apply)

      + domain      = "mitigateddos.net"

      + hostname    = (known after apply)

      + metadata    = (known after apply)

      + modified_on = (known after apply)

      + name        = "mitigateddos.net"

      + proxiable   = (known after apply)

      + proxied     = true

      + ttl         = 1

      + type        = "A"

      + value       = "192.0.2.1"

      + zone_id     = "1109d899a5ff5fd74bc01e581693685b"

    }


  # cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354 will be created

  + resource "cloudflare_record" "terraform_managed_resource_5e10399a590a45279f09aa8fb1163354" {

      + id          = (known after apply)

      + created_on  = (known after apply)

      + domain      = "mitigateddos.net"

      + hostname    = (known after apply)

      + metadata    = (known after apply)

      + modified_on = (known after apply)

      + name        = "www.mitigateddos.net"

      + proxiable   = (known after apply)

      + proxied     = true

      + ttl         = 1

      + type        = "CNAME"

      + value       = "mitigateddos.net"

      + zone_id     = "1109d899a5ff5fd74bc01e581693685b"

    }


  # cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248 will be created

  + resource "cloudflare_record" "terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248" {

      + id          = (known after apply)

      + created_on  = (known after apply)

      + domain      = "mitigateddos.net"

      + hostname    = (known after apply)

      + metadata    = (known after apply)

      + modified_on = (known after apply)

      + name        = "a123.mitigateddos.net"

      + proxiable   = (known after apply)

      + proxied     = false

      + ttl         = 300

      + type        = "NS"

      + value       = "rafe.ns.cloudflare.com"

      + zone_id     = "1109d899a5ff5fd74bc01e581693685b"

    }


  # cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2 will be created

  + resource "cloudflare_record" "terraform_managed_resource_5799bb01054843eea726758f935d2aa2" {

      + id          = (known after apply)

      + created_on  = (known after apply)

      + domain      = "mitigateddos.net"

      + hostname    = (known after apply)

      + metadata    = (known after apply)

      + modified_on = (known after apply)

      + name        = "a123.mitigateddos.net"

      + proxiable   = (known after apply)

      + proxied     = false

      + ttl         = 300

      + type        = "NS"

      + value       = "terin.ns.cloudflare.com"

      + zone_id     = "1109d899a5ff5fd74bc01e581693685b"

    }


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


------------------------------------------------------------------------


Note: You didn't use the -out option to save this plan, so Terraform can't

guarantee to take exactly these actions if you run "terraform apply" now.
Để khắc phục điều này, bạn phải nhập trạng thái thực tế của các tài nguyên đó từ Cloudflare vào tệp trạng thái Terraform (.tfstate).
To fix this, you must import the real state of those resources from Cloudflare into the Terraform state file (.tfstate).
ដើម្បីដោះស្រាយបញ្ហានេះអ្នកគួរតែនាំចូលស្ថានភាពពិតប្រាកដនៃឧបករណ៍ទាំងនេះពី Cloudflare ទៅក្នុងឯកសារស្ថានភាព Terraform (.tfstate) ។

Nhập tài nguyên vào trạng thái Terraform Import resources into Terraform state ទាញយកឧបករណ៍ទៅ Terraform

Phần «Import resources into Terraform state» — đọ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 "Import resources into Terraform state" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «ទាញយកឧបករណ៍ទៅ Terraform» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
cf-terraforming cho phép bạn nhập trạng thái cục bộ (tệp .tfstate) cho cùng một tài nguyên mà bạn đã nhập trong quá trình cấu hình.
cf-terraforming allows you to import local state (.tfstate file) for the same resources you imported during configuration.
cf-terraforming អនុញ្ញាតឱ្យអ្នកនាំចូលគ្នានៅដ្ឋាន (ឯកសារ .tfstate) សម្រាប់សមត្ថភាពដូចគ្នាដែលអ្នកបាននាំចូលនៅពេលការកំណត់។
Khi bạn chạy cf-terraforming import ..., bạn sẽ nhận được một danh sách các lệnh terraform import ... mà bạn phải chạy thủ công sau đó để nhập các tài nguyên đó vào trạng thái Terraform. Đây là một quá trình thủ công hiện nay, nhưng nó có thể được tự động hóa trong tương lai.
When you run cf-terraforming import ..., you will obtain a list of terraform import ... commands that you must run manually afterward to import those resources into Terraform state. This is currently a manual process, but it may be automated in the future.
នៅពេលដែលអ្នកដំណើរការ cf-terraforming import ... អ្នកនឹងទទួលបានបញ្ជីនៃការបញ្ជា terraform import ... ដែលអ្នកត្រូវដំណើរការដោយផ្ទាល់បន្ទាប់មកដើម្បីនាំចូលចំណាយទាំងនេះទៅ Terraform ។ ឥឡូវនេះវាជាដំណើរការម៉ាស៊ីនប៉ុន្តែវាអាចត្រូវបានដោយស្វ័យប្រវត្តិនៅក្នុងអនាគត។
  1. Chạy lệnh sau:
  1. Run the following command:
  1. ធ្វើការបញ្ជាបញ្ជាដូចខាងក្រោម:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
cf-terraforming import --resource-type "cloudflare_record" --email $CLOUDFLARE_EMAIL --key $CLOUDFLARE_API_KEY --zone $CLOUDFLARE_ZONE_ID
  1. Sao chép từng lệnh terraform import ... bao gồm trong đầu ra và chạy nó. Terraform sẽ nhập từng tài nguyên riêng lẻ vào trạng thái Terraform.
  1. Copy each terraform import ... command included in the output and run it. Terraform will import each resource individually into Terraform state.
  1. ចម្លង terraform import ... ទាំងអស់ដែលមាននៅក្នុងការនាំចេញនិងដំណើរការវា។ Terraform នឹងនាំចូលប្រសិនបើមានប្រសិនបើមានប្រសិនបើមានប្រសិនបើមានប្រសិនបើមានប្រសិនបើមានប្រសិនបើមាន Terraform ។
Ví dụ, nếu đầu ra của lệnh đầu tiên (cf-terraforming import ...) chứa các lệnh terraform sau:
For example, if the output of the first command (cf-terraforming import ...) contained the following terraform commands:
ឧទាហរណ៍, ប្រសិនបើដំណោះស្រាយនៃជម្រើសដំបូង (cf-terraforming import ...) មានជម្រើស terraform ដូចខាងក្រោម:
text
terraform import cloudflare_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31 1109d899a5ff5fd74bc01e581693685b/3c0b456bc2aa443089c5f40f45f51b31

terraform import cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354 1109d899a5ff5fd74bc01e581693685b/d09d916d059aa9fc8cb54bdd49deea5f

terraform import cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248 1109d899a5ff5fd74bc01e581693685b/8d6ec0d02c5b22212ff673782c816ef8

terraform import cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2 1109d899a5ff5fd74bc01e581693685b/3766b952a2dda4c47e71952aeef33c77
Bạn sẽ chạy từng lệnh riêng lẻ trong Terminal:
You would run each command individually in the terminal:
អ្នកនឹងដំណើរការបញ្ជាទូទៅក្នុងបញ្ជាទូទៅក្នុងបញ្ជាទូទៅ:
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform import cloudflare_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31 1109d899a5ff5fd74bc01e581693685b/3c0b456bc2aa443089c5f40f45f51b31
text
cloudflare_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Importing from ID "1109d899a5ff5fd74bc01e581693685b/3c0b456bc2aa443089c5f40f45f51b31"...

cloudflare_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Import complete!

  Imported cloudflare_record [id=3c0b456bc2aa443089c5f40f45f51b31]

cloudflare_record.terraform_managed_resource_3c0b456bc2aa443089c5f40f45f51b31: Refreshing state... [id=3c0b456bc2aa443089c5f40f45f51b31]


Import successful!


The resources that were imported are shown above. These resources are now in

your Terraform state and will henceforth be managed by Terraform.
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform import cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354 1109d899a5ff5fd74bc01e581693685b/d09d916d059aa9fc8cb54bdd49deea5f
text
cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354: Importing from ID "1109d899a5ff5fd74bc01e581693685b/d09d916d059aa9fc8cb54bdd49deea5f"...

cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354: Import complete!

  Imported cloudflare_record [id=d09d916d059aa9fc8cb54bdd49deea5f]

cloudflare_record.terraform_managed_resource_5e10399a590a45279f09aa8fb1163354: Refreshing state... [id=d09d916d059aa9fc8cb54bdd49deea5f]


Import successful!


The resources that were imported are shown above. These resources are now in

your Terraform state and will henceforth be managed by Terraform.
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform import cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248 1109d899a5ff5fd74bc01e581693685b/8d6ec0d02c5b22212ff673782c816ef8
text
cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248: Importing from ID "1109d899a5ff5fd74bc01e581693685b/8d6ec0d02c5b22212ff673782c816ef8"...

cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248: Import complete!

  Imported cloudflare_record [id=8d6ec0d02c5b22212ff673782c816ef8]

cloudflare_record.terraform_managed_resource_de1cb74bae184b569bb7f83fefe72248: Refreshing state... [id=8d6ec0d02c5b22212ff673782c816ef8]


Import successful!


The resources that were imported are shown above. These resources are now in

your Terraform state and will henceforth be managed by Terraform.
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform import cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2 1109d899a5ff5fd74bc01e581693685b/3766b952a2dda4c47e71952aeef33c77
text
cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2: Importing from ID "1109d899a5ff5fd74bc01e581693685b/3766b952a2dda4c47e71952aeef33c77"...

cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2: Import complete!

  Imported cloudflare_record [id=3766b952a2dda4c47e71952aeef33c77]

cloudflare_record.terraform_managed_resource_5799bb01054843eea726758f935d2aa2: Refreshing state... [id=3766b952a2dda4c47e71952aeef33c77]


Import successful!


The resources that were imported are shown above. These resources are now in

your Terraform state and will henceforth be managed by Terraform.
Nếu bây giờ bạn chạy terraform plan, bạn sẽ nhận thấy rằng Terraform sẽ không còn cố gắng tạo lại các tài nguyên cloudflare_record:
If you now run terraform plan, you will notice that Terraform will no longer try to re-create the cloudflare_record resources:
ប្រសិនបើអ្នកដំណើរការ terraform plan ឥឡូវនេះ, អ្នកនឹងរកឃើញថា Terraform នឹងមិនដំណើរការដើម្បីបង្កើត Resources cloudflare_record ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
terraform plan | grep changes
text
No changes. Infrastructure is up-to-date.
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/advanced-topics/","name":"Advanced topics"}},{"@type":"ListItem","position":4,"item":{"@id":"/terraform/advanced-topics/import-cloudflare-resources/","name":"Import Cloudflare resources"}}]}

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 ↗ ឯកសារផ្លូវការ ↗