Tạo các tài nguyên khác nhau bằng cách sử dụng Pulumi và Wrangler Create different resources using Pulumi and Wrangler ការបង្កើតសារធាតុផ្សេងគ្នាដោយប្រើ Pulumi និង Wrangler
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 Developer Platform — thực hành triển khai code, API và dữ liệu trên edge/serverless. Tutorial «Tạo different resources using Pulumi và Wrangler» 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.
Pulumi and Wrangler can be used to create different types of resources.
Pulumi និង Wrangler អាចត្រូវបានប្រើដើម្បីបង្កើតប្រភេទផ្សេងគ្នានេះ។
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 đủ.
- Cần tài khoản Cloudflare, Wrangler CLI và (thường) hoàn thành hướng dẫn Get started của Workers/Pages.
- 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.
- Requires a Cloudflare account, Wrangler CLI, and (typically) completing the Workers/Pages Get started guide.
- 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, សៀវភៅកូដនិងរូបថតពេញលេញ។
- តម្រូវឱ្យមានគណនី Cloudflare, Wrangler CLI និង (ប្រហែលជា) ការបញ្ចប់គណនី Workers/Pages Get started ។
- សូមពិនិត្យមើល API tokens និងការបង្វិលប្រព័ន្ធប្រតិបត្តិការមុនពេលធ្វើការប្រឆាំងនឹងការផលិត។
- Cloudflare បានផ្លាស់ប្តូរជាធម្មតានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅ។
Tài liệu gốc — rà soát lần cuối: over 1 year ago Official docs — last reviewed: over 1 year ago ឯកសារផ្លូវការ — ពិនិត្យចុងក្រោយ: over 1 year ago
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 កំណត់។
- Sử dụng Pulumi cho một số tài nguyên được hỗ trợ bởi nhà cung cấp Cloudflare Pulumi.
- Sử dụng Wrangler để tạo các loại tài nguyên khác.
- Use Pulumi for some resources supported by the Cloudflare Pulumi provider.
- Use Wrangler to create other types of resources.
- ប្រើ Pulumi សម្រាប់ចំណុចមួយចំនួនដែលគាំទ្រដោយក្រុមហ៊ុនផ្គត់ផ្គង់ Pulumi Cloudflare ។
- ប្រើ Wrangler ដើម្បីបង្កើតប្រភេទសម្បត្តិផ្សេងទៀត។
Wrangler sử dụng Wrangler usage Wrangler ការប្រើប្រាស់
Phần «Wrangler 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 "Wrangler usage" section below — open the official docs link for full screenshots and configuration tabs.
អានផ្នែក «Wrangler ការប្រើប្រាស់» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។
migrations thay đổi, trong trường hợp đó lệnh Pulumi sẽ được thực hiện.migrations directory changes, in which case the Pulumi command will be executed.migrations ។ ក្នុងករណីនេះការបញ្ជា Pulumi នឹងត្រូវបានអនុវត្ត។Nhà cung cấp tài nguyên động cho Vectorize Dynamic resource provider for Vectorize អ្នកផ្គត់ផ្គង់ឧបករណ៍ឌីមីសម្រាប់ Vectorize
Phần «Dynamic resource provider for Vectorize» — đọ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 "Dynamic resource provider for Vectorize" section below — open the official docs link for full screenshots and configuration tabs.
អានផ្នែក «អ្នកផ្គត់ផ្គង់ឧបករណ៍ឌីមីសម្រាប់ Vectorize» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។
Ví dụ code Example code លេខកូដ
Phần «Example code» — đọ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 "Example code" section below — open the official docs link for full screenshots and configuration tabs.
អានផ្នែក «លេខកូដ» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។
"use strict";
const pulumi = require("@pulumi/pulumi");
const cloudflare = require("@pulumi/cloudflare");
const command = require("@pulumi/command");
const path = require("path");
const axios = require("axios");
const https = require("https");
const crypto = require("crypto");
const fs = require("fs");
// Load configuration
const config = new pulumi.Config();
const domainName = config.require("domainName");
const accountId = config.require("accountId");
const apiToken = config.requireSecret("apiToken");
// Function to compute hash of a file
function computeFileHashSync(filePath) {
const fileBuffer = fs.readFileSync(filePath);
const hash = crypto.createHash("sha256");
hash.update(fileBuffer);
return hash.digest("hex");
}
// Function to compute the hash of a directory
async function hashDirectory(dirPath) {
const files = await fs.promises.readdir(dirPath);
const fileHashes = [];
for (const file of files) {
const filePath = path.join(dirPath, file);
const fileStat = await fs.promises.stat(filePath);
if (fileStat.isFile()) {
const fileData = await fs.promises.readFile(filePath);
const hash = crypto.createHash("sha256").update(fileData).digest("hex");
fileHashes.push(hash);
}
}
// Combine all file hashes and hash the result to get a unique hash for the directory
const combinedHash = crypto
.createHash("sha256")
.update(fileHashes.join(""))
.digest("hex");
return combinedHash;
}
// Instantiate Cloudflare provider
// https://www.pulumi.com/registry/packages/cloudflare/
//-----------------------------------------------------------------------------
const cloudflareProvider = new cloudflare.Provider("cloudflare", {
apiToken: apiToken,
});
// Create a Cloudflare Zone
// https://www.pulumi.com/registry/packages/cloudflare/api-docs/zone/
//-----------------------------------------------------------------------------
const myZone = new cloudflare.Zone(
"myZone",
{
zone: domainName,
plan: "enterprise",
accountId: accountId,
},
{ provider: cloudflareProvider },
);
// Create a Cloudflare Queue (used as a binding in Worker)
// https://www.pulumi.com/registry/packages/cloudflare/api-docs/queue/
//-----------------------------------------------------------------------------
const myqueue = new cloudflare.Queue(
"myqueue",
{
zoneId: myZone.id,
name: "myqueue",
description: "Queue for my messages",
accountId: accountId,
},
{ provider: cloudflareProvider },
);
// Create a Cloudflare Queue (used as a binding in Worker)
// https://www.pulumi.com/registry/packages/cloudflare/api-docs/queue/
//-----------------------------------------------------------------------------
const myqueuedeadletter = new cloudflare.Queue(
"myqueuedeadletter",
{
zoneId: myZone.id,
name: "myqueuedeadletter",
description: "Queue for messages that were not processed correctly",
accountId: accountId,
},
{ provider: cloudflareProvider },
);
// Create a D1 Database
// https://www.pulumi.com/registry/packages/cloudflare/api-docs/d1database/
//-----------------------------------------------------------------------------
const myD1Database = new cloudflare.D1Database(
"myD1Database",
{
accountId: accountId,
name: "mydb",
},
{ provider: cloudflareProvider },
);
// Deploy Changes to D1 Schema
// - Cloudflare Wrangler stores a list of migrations in the D1 database.
// - To check which migrations were run, go to the Cloudflare dashboard
// and run "SELECT * FROM d1_migrations" on the console of the D1 database.
//-----------------------------------------------------------------------------
const d1Dir = "../../mydb/";
const d1Migration = new command.local.Command(
"d1Migration",
{
dir: d1Dir,
create: `npx wrangler d1 migrations apply mydb --remote`,
triggers: [hashDirectory(`${d1Dir}migrations`)],
},
Access Xuất khẩu Pulumi Access Pulumi exports Access ការនាំចេញ Pulumi
Phần «Access Pulumi exports» — đọ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 "Access Pulumi exports" section below — open the official docs link for full screenshots and configuration tabs.
អានផ្នែក «Access ការនាំចេញ Pulumi» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។
pulumi up, tài nguyên của bạn sẽ được tạo hoặc cập nhật.pulumi up, your resources will be created or updated.pulumi up អ្នកនឹងត្រូវបានបង្កើតឬបច្ចុប្បន្នភាពប្រសិទ្ធិភាពរបស់អ្នក។pulumi stack output myServiceTokenClientSecret --show-secrets {"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/pulumi/","name":"Pulumi"}},{"@type":"ListItem","position":3,"item":{"@id":"/pulumi/tutorial/","name":"Tutorials"}},{"@type":"ListItem","position":4,"item":{"@id":"/pulumi/tutorial/dynamic-provider-and-wrangler/","name":"Create different resources using Pulumi and Wrangler"}}]} 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 ↗ ឯកសារផ្លូវការ ↗