Cloud foundations

Lab: Account, first VM, firewall and spend alert. PLO: PLO1 / PLO3. Points: 7.

Overview

The campus media unit is four people in Chiang Mai: two editors, a designer and a coordinator. They publish about 40 short videos a month and maintain a 6,000-asset image and 3D catalogue. A one-terabyte video archive grows every year, and the unit serves about 300 clip views on an average day.

The one big idea for this session: cloud replaces fixed capacity with elastic, metered capacity — but only when demand is variable and the unit can operate it. A closet server is cheap until it is full; a cloud account is cheap until nobody turns it off.

Lesson

What the unit actually rents

Service type What the unit rents Example in the course
IaaS A virtual machine and a disk A DigitalOcean Droplet
PaaS A managed runtime for the catalogue API A Cloudflare Worker (Session 4)
SaaS A managed AI API OpenRouter (Session 8)

The boundaries are blurry in practice. The useful question is not "which layer?" but who owns the operating system, the patching and the failure mode. On a Droplet the unit patches Rocky Linux itself. On a Worker the provider runs the runtime and the unit only ships code. On an inference API the provider also owns the model and the hardware.

The account is a set of separate objects

DigitalOcean is not one big console page; it is an account containing objects with different jobs. The lab creates each one deliberately, because each one is a different kind of guardrail.

Object What it is What it is not
Project A folder that groups resources for billing and browsing Not an access boundary — every team member sees every project
Tag A label such as week:1 that can attach a firewall to a Droplet Not a security rule by itself
SSH key A public key stored on the account; the private half stays on the laptop Not a password; it cannot be typed in
*API token* A scoped credential for doctl and the API, with an expiry date Not editable after creation — a scope you forgot means a new token
Cloud firewall A ruleset applied to Droplets by Droplet ID or by tag Not on the Droplet itself; it lives in the network
Droplet A virtual machine with a disk and a public IPv4 address Not backed up unless you snapshot it

Two rules follow from that table. First, prefer tag attachment: a firewall attached to the tag week:1 protects every Droplet that carries the tag, including one created later. Second, scope the token: a token that can delete Droplets is a token that can delete the wrong Droplet. The lab asks for a custom-scope token limited to the S1 resource types and a 90-day expiry, and it keeps the secret out of the repository.

One region, no zones

The unit's nearest region is SGP1 (Singapore). A region is a geographic area with its own network and power. Unlike some providers, DigitalOcean does not expose customer-selectable availability zones: a region is the failure domain the unit can choose.

So the resilience story is short. A region is not a backup. A snapshot is a copy of a Droplet's disk at a point in time, and restoring it builds a new Droplet. The unit's minimum rule is one snapshot plus a restore test you have actually run — and, for the archive, a copy outside the region.

The latency numbers are deliberately absent here. SGP1 is the nearest region, and Session 2 measures what the distance costs from Chiang Mai through the Cloudflare edge.

Metered cost, and the guardrail that is not a cap

A Droplet bills by the hour it exists, not by the hour it works. The lab size s-1vcpu-1gb costs $0.00893 per hour, so a four-hour lab costs about four cents. A Droplet that is powered off still bills, because the provider is holding the capacity; only destroying it stops the meter.

What the unit does What it costs
One s-1vcpu-1gb Droplet for 2 hours about $0.018
The same for 11 hours about $0.098 — the S1 ceiling
The same for 30 days, idle about $6.43

A spend alert emails at percentage thresholds of a monthly budget. It is not a cap: the account keeps spending after the email arrives. That distinction is the session's financial lesson. The student sets a $10 monthly alert, the course envelope is $25, and the student is reimbursed $10 of actual spend. The lab's own ceiling is $0.10, and the evidence must show the run stayed under it.

Egress — data leaving the provider's network — is metered separately. DigitalOcean pools 1,000 GiB of transfer per Droplet per month, and overage is charged per GiB. For this lab the unit transfers a few kilobytes, so the Droplet hour dominates.

What the unit does first

The order matters, and the lab follows it exactly:

  1. Turn on two-factor authentication and a backup method. The account is the root of everything else.
  2. Create a project and a tag. Grouping and labelling are free and make the next steps safer.
  3. Create an ed25519 SSH key. Key-only login is the default on a key-created Droplet; there is no password to leak.
  4. Create a scoped API token. Every later command is a bounded action, not an account-wide password.
  5. Create a default-deny firewall that allows SSH from one address. Guardrails before resources.
  6. Create one Droplet and prove the first login. This is the smallest useful piece of rented capacity.
  7. Set the spend alert and read the billing view. The bill is the feedback loop.
  8. Tear the Droplet and firewall down, and prove the account is clean. An empty list is the only teardown proof.

When cloud is the wrong answer

Predictable, high-volume rendering can be cheaper on owned hardware. Data gravity — moving a terabyte out of a provider — can cost more than the storage. And a team that cannot operate the account will pay for idle resources. The research question asks you to find the tipping point for this unit.

Check yourself

  1. Why does the unit need a spend alert before it needs a second Droplet?
  2. What is the difference between a region and a backup?
  3. Name one workload that should stay on-premises, and why.
สรุปภาษาไทย หน่วยสื่อของมหาวิทยาลัยมีสี่คน ผลิตวิดีโอสั้นประมาณ 40 ชิ้นต่อเดือน และดูแลแคตตาล็อกภาพและโมเดล 3 มิติ 6,000 รายการ แนวคิดหลักคือคลาวด์แทนความจุคงที่ด้วยความจุแบบยืดหยุ่นที่จ่ายตามใช้ แต่จะคุ้มก็ต่อเมื่อความต้องการไม่สม่ำเสมอและทีมดูแลระบบได้ บัญชี DigitalOcean ไม่ใช่หน้าเดียว แต่ประกอบด้วยวัตถุที่ทำหน้าที่ต่างกัน ได้แก่ โปรเจกต์ (เพียงโฟลเดอร์จัดกลุ่ม ไม่ใช่ขอบเขตสิทธิ์) แท็ก (ป้ายที่ใช้ผูกไฟร์วอลล์กับ Droplet) คีย์ SSH โทเคน API ที่จำกัดขอบเขตและมีวันหมดอายุ ไฟร์วอลล์ และ Droplet หลักการคือผูกไฟร์วอลล์ด้วยแท็กและจำกัดสิทธิ์ของโทเคน ภูมิภาคที่ใกล้ที่สุดคือ SGP1 (สิงคโปร์) DigitalOcean ไม่มีโซนให้เลือก ภูมิภาคจึงเป็นขอบเขตความล้มเหลว ภูมิภาคไม่ใช่แบ็กอัป แต่สแนปช็อตคือสำเนาของดิสก์ ณ เวลาหนึ่ง และต้องทดสอบกู้คืนจริง Droplet คิดค่าบริการตามชั่วโมงที่มีอยู่ แม้ปิดเครื่องก็ยังคิดเงิน การแจ้งเตือนการใช้จ่ายเป็นเพียงอีเมล ไม่ใช่เพดาน แล็บนี้จึงจำกัดค่าใช้จ่ายไว้ที่ 0.10 ดอลลาร์
中文总结 大学的媒体单元有四个人,每月制作约 40 条短视频,并维护包含 6,000 项图像和 3D 模型的目录。核心概念是:云用按使用付费的弹性容量取代固定容量,但只有当需求不规律且团队能够运维时,它才划算。 DigitalOcean 账号不是一个单一页面,而是由承担不同职责的对象组成:项目(只是分组用的文件夹,不是权限边界)、标签(把防火墙绑定到 Droplet 的标记)、SSH 密钥、受限权限且带有效期的 API token、防火墙和 Droplet。原则是用标签绑定防火墙,并限制 token 的权限。 最近的区域是 SGP1(新加坡)。DigitalOcean 不提供可选择的可用区,因此区域就是故障边界。区域不是备份,但快照是磁盘在某一时刻的副本,而且必须实际测试恢复。Droplet 按存在的小时数计费,即使关机也仍然收费。支出提醒只是一封邮件,不是上限,因此本次实验把成本限制在 0.10 美元。

Interactive: region, Droplet and snapshot

The scene shows the account hierarchy and the smallest useful deployment: a Droplet inside SGP1, a firewall in front of it, the SSH key that opens it, and a snapshot copy behind it. Hover an object to read its role; drag to orbit and scroll to zoom.

Drag to orbit, scroll to zoom. Hover an object for its role.

Reading the scene. The account contains a project, which contains the Droplet. The firewall sits in front of the Droplet and admits SSH from one address; the key is what the firewall's rule lets through. The snapshot sits beside the Droplet, outside its failure domain, and is the only copy that survives destroying the Droplet. The tag week:1 is the link between the firewall and the Droplet: the firewall follows the label, not the machine.

A box labelled account containing a project box, a Droplet, a firewall with an SSH rule, an SSH key and a tag, with a snapshot arrow leaving the Droplet.
Figure 1.1 — Account, project, Droplet, firewall, key, tag and snapshot: the objects the S1 lab creates, and the two links that matter.

Hierarchy at a glance.

Level Object Created by Deleted at teardown?
Account DigitalOcean account + 2FA Student, pre-course No
Organisation Project course-<id> Panel or doctl projects create No — kept for the course
Access SSH key course-s1-<id> and token course-s1-<id> Panel; key also by doctl No — token expires
Network Firewall course-<id>-s1, attached by tag week:1 Panel or doctl compute firewall create Yes
Compute Droplet course-<id>-s1 Panel or doctl compute droplet create Yes
Durability Snapshot of the Droplet Panel or doctl compute droplet-action snapshot Extension only

A static version of the same diagram is available if WebGL is unavailable.

Prerequisite: A DigitalOcean account with two-factor authentication and a backup method, the instructor added as a Resource Viewer and a $10 spend alert; an SSH key pair and a scoped API token. Set it up in Session 0: Accounts, SSH keys.

Lab — Account, first VM, firewall and spend alert

Time: 120 minutes — 10 setup, 10 project and tags, 10 SSH key, 10 token, 15 firewall including the lockout drill, 15 Droplet and first login, 5 spend alert, 5 buffer, 20 evidence, 10 teardown.

Prerequisite: the pre-course checklist — a DigitalOcean account with two-factor authentication and a backup method, the instructor added as a Resource Viewer, doctl installed, and a payment method on the account. The card is required at signup; spend alerts are email thresholds, not caps.

You need to know: DigitalOcean separates the object that groups resources (a project) from the object that admits traffic (a cloud firewall) and the credential that authorises commands (an API token). A project is organisational only; it is not an access boundary. A firewall attached by tag protects every Droplet that later carries that tag. A token's custom scopes are fixed at creation, so choosing too few means creating a new token, not editing the old one. A Droplet bills while it exists, including while it is powered off; only destroying it stops the meter.

Safe-data acknowledgement: I have read the lab safe-data policy. I will use only the synthetic media supplied with the course, and I will not upload real personal media — or real account identifiers, emails or tokens in a screenshot — to any cloud service.

Task

Create a safe DigitalOcean identity, a project, an SSH key, a scoped API token, a default-deny firewall and one small Rocky Linux 10 Droplet in SGP1. Prove the first key-only login, break your own SSH access and recover it through the Control Panel, set a $10 spend alert, capture the evidence, and tear the Droplet and firewall down. The lab must stay under $0.10.

Steps

1. Pre-flight: account, two-factor and the scoped token

Panel path: Account → Settings, check that 2FA shows Enabled and a backup method is listed. Panel path for membership: Teams → Members, confirm the instructor appears as Resource Viewer.

Panel path: API → Tokens → Generate New Token. Choose Custom scopes, name it course-s1-<id>, set the expiry to 90 days (or the longest offered), and select exactly:

Resource Scopes
droplet read, create, delete
ssh_key read, create
firewall read, create, update, delete
project read, create, assign_resource
tag read, create
account read
region read
size read
image read
billing read

The secret is shown once; copy it into doctl auth init immediately. Custom scopes are per resource type and action — a token cannot be limited to one Droplet — and they cannot be edited after creation. If the Droplet commands later fail with a 403, a scope is missing: create a new token, do not hunt for an edit button. There is no CLI path for this step.

doctl auth init

Asks for the token and saves it in the default context. Paste the secret you just copied; it is not echoed as you type.

chmod 600 "$HOME/Library/Application Support/doctl/config.yaml"

Restricts the saved token to your user account. On Linux the path is ~/.config/doctl/config.yaml. This file is a credential: never commit it, copy it into the repository, or paste its contents into a report.

สรุปภาษาไทย สร้างโทเคนแบบกำหนดขอบเขตเอง ชื่อ course-s1- อายุ 90 วัน และเลือกสิทธิ์ตามตาราง โทเคนจะแสดงเพียงครั้งเดียว ให้คัดลอกไปใช้กับ `doctl auth init` ทันที ขอบเขตแก้ไขภายหลังไม่ได้ หากคำสั่งได้ 403 แสดงว่าขาดสิทธิ์ ต้องสร้างโทเคนใหม่ ขั้นนี้ไม่มีเส้นทาง CLI
中文总结 创建一个自定义作用域的 token,命名为 course-s1-<id>,有效期 90 天,并按表格选择权限。token 只显示一次,要立即复制并用于 `doctl auth init`。作用域之后无法修改;如果命令返回 403,说明缺少权限,必须重新创建 token。这一步没有 CLI 路径。
doctl version

Prints the doctl version and the API endpoint. The course was verified with doctl 2.4.0; an older release may not know doctl projects or doctl balance get.

doctl compute image list --public --format Slug --no-header | grep -x rockylinux-10-x64

Checks that the Rocky Linux 10 image slug exists in the public catalogue and prints it back. No output means the slug is unavailable in this account or region; stop and use the image ID the panel shows instead of guessing.

doctl account get

Calls the account endpoint and prints the account email, team and Droplet limit. Success proves the token is valid. Do not screenshot this output: it contains the account email. In the evidence, describe it as "account read confirmed".

doctl balance get

Records the starting month-to-date usage. Note the third column: the lab's cost is the difference between this value and the value at teardown, so a starting number is part of the evidence.

สรุปภาษาไทย ขั้นเตรียมความพร้อมตรวจว่าเปิดใช้ 2FA และมีวิธีสำรองแล้ว อาจารย์ถูกเพิ่มเป็น Resource Viewer จากนั้นสร้างโทเคน API แบบกำหนดขอบเขตเอง อายุ 90 วัน ตามตาราง แล้วใช้ `doctl auth init` บันทึกโทเคนไว้ในเครื่อง ตั้งสิทธิ์ไฟล์ config เป็น 600 คำสั่ง `doctl version` และ `doctl compute image list` ตรวจเครื่องมือและอิมเมจ `doctl account get` ยืนยันโทเคน และ `doctl balance get` บันทึกยอดใช้จ่ายเริ่มต้น อย่าถ่ายภาพผลลัพธ์ account get เพราะมีอีเมลบัญชี
中文总结 预检步骤确认已启用 2FA 并设置好备份方式,教师已被添加为 Resource Viewer。然后按表格创建一个自定义作用域、有效期 90 天的 API token,再用 `doctl auth init` 把 token 保存到本机,并把 config 文件的权限设为 600。命令 `doctl version` 和 `doctl compute image list` 检查工具和镜像,`doctl account get` 验证 token,`doctl balance get` 记录初始支出余额。不要对 account get 的结果截图,因为其中包含账号邮箱。

2. Create the project and the tag

Panel path: Projects → Create project, name it course-<id>, choose the purpose Just experimenting.

doctl projects create --name "course-<id>" --purpose "Just experimenting" --format ID --no-header

Creates the project and prints its UUID. Record the UUID: the Droplet is assigned to the project at creation, and the project cannot be an access boundary, so its value is organisational.

doctl compute tag create "week:1"

Creates the tag that the firewall follows. Tags allow letters, numbers, colons, dashes and underscores; = is not allowed. If the tag already exists the call fails harmlessly — move on.

สรุปภาษาไทย สร้างโปรเจกต์ชื่อ course- เพื่อจัดกลุ่มทรัพยากร (ไม่ใช่ขอบเขตสิทธิ์) และบันทึก UUID ไว้ จากนั้นสร้างแท็ก week:1 ซึ่งไฟร์วอลล์จะใช้ผูกกับ Droplet แท็กใช้ตัวอักษร ตัวเลข จุดคู่ ลูกน้ำ และขีดล่างเท่านั้น
中文总结 创建一个名为 course-<id> 的项目来分组资源(它不是权限边界),并记录它的 UUID。然后创建标签 week:1,防火墙会用这个标签绑定到 Droplet。标签只允许字母、数字、冒号、连字符和下划线。

3. Create the SSH key

Panel path: Settings → Security → SSH keys → Add SSH key; paste the public key printed by the first command.

ssh-keygen -t ed25519 -C "course-s1-<id>" -f ~/.ssh/do_s1

Generates an ed25519 keypair. The public half is ~/.ssh/do_s1.pub; the private half is ~/.ssh/do_s1 and never leaves the laptop. ed25519 is the current default and produces a short key that is hard to get wrong.

chmod 600 ~/.ssh/do_s1

Makes the private key readable only by you. SSH refuses to use a key with looser permissions, so this also prevents a frustrating "bad permissions" error later.

doctl compute ssh-key import course-s1-<id> --public-key-file ~/.ssh/do_s1.pub

Uploads only the public half to the account. The account stores it as a named key that a Droplet can reference at creation.

doctl compute ssh-key list --format ID,FingerPrint,Name --no-header

Lists the account's keys with their fingerprints. The Name column makes the row easy to find; record the ID and fingerprint for the Droplet step.

ssh-keygen -E md5 -lf ~/.ssh/do_s1.pub

Prints the MD5 fingerprint of your local public key, the same form doctl lists. The value must match the doctl row — that equality is the evidence that the key you hold is the key the account holds.

สรุปภาษาไทย สร้างคู่กุญแจ ed25519 โดยเก็บกุญแจส่วนตัวไว้บนเครื่องและอัปโหลดเฉพาะกุญแจสาธารณะขึ้นบัญชี ตั้งสิทธิ์ไฟล์กุญแจส่วนตัวเป็น 600 มิฉะนั้น SSH จะปฏิเสธการใช้ จากนั้นตรวจว่า fingerprint จาก `doctl compute ssh-key list` ตรงกับ `ssh-keygen -lf` ซึ่งเป็นหลักฐานว่ากุญแจที่เราถือคือกุญแจที่บัญชีมี
中文总结 创建一对 ed25519 密钥,把私钥保存在本机,只把公钥上传到账号。把私钥文件的权限设为 600,否则 SSH 会拒绝使用它。然后检查 `doctl compute ssh-key list` 输出的 fingerprint 与 `ssh-keygen -lf` 输出的一致,这就是你持有的密钥就是账号所持有的密钥的证据。

4. Create the default-deny firewall

Panel path: Networking → Firewalls → Create Firewall, name it course-<id>-s1, add an inbound rule SSH / TCP 22 / your IP, keep all outbound TCP, UDP and ICMP allowed, and attach it to the tag week:1.

MYIP=$(curl -s https://api.ipify.org)

Asks a public service for the address your laptop appears to use, and stores it in MYIP. The firewall will allow SSH from that single address and nothing else, so a café network change later means updating the rule.

doctl compute firewall create --name "course-<id>-s1" --inbound-rules "protocol:tcp,ports:22,address:$MYIP/32" --outbound-rules "protocol:tcp,ports:0,address:0.0.0.0/0 protocol:udp,ports:0,address:0.0.0.0/0 protocol:icmp,ports:0,address:0.0.0.0/0" --tag-names "week:1" --format ID --no-header

Creates the firewall and prints its ID. /32 means one address, not a range. With no rule for any other inbound port, the default is deny. The three outbound rules let the Droplet fetch packages, resolve DNS and answer ping; a Droplet with no outbound rules is very hard to debug.

doctl compute firewall get <firewall-id>

Prints the firewall's name, status, inbound and outbound rules, and the tags it follows. Read the Inbound Rules block: it must contain exactly one TCP 22 rule whose address ends in /32. Anything else is a defect you fix before creating the Droplet.

สรุปภาษาไทย สร้างไฟร์วอลล์แบบปฏิเสธเป็นค่าเริ่มต้น เปิดเฉพาะ SSH TCP 22 จาก IP ของเครื่องคุณ และเปิดขาออก TCP/UDP/ICMP ทั้งหมด ผูกกับแท็ก week:1 คำสั่ง `doctl compute firewall get` ใช้ตรวจว่ามีกฎขาเข้าเพียงข้อเดียวและลงท้ายด้วย /32 ก่อนสร้าง Droplet
中文总结 创建一个默认拒绝的云防火墙,只开放来自你本机 IP 的 SSH TCP 22,并开放全部 TCP/UDP/ICMP 出站流量,然后绑定标签 week:1。命令 `doctl compute firewall get` 用于在创建 Droplet 之前检查入站规则只有一条,并且地址以 /32 结尾。

5. Create the Droplet and prove the first login

Panel path: Droplets → Create Droplet; choose SGP1, Rocky Linux 10, the Basic plan $6/mo (s-1vcpu-1gb), the SSH key course-s1-<id>, the tags course:42-05-0112, student:<id> and week:1, and the project course-<id>.

doctl compute droplet create "course-<id>-s1" --region sgp1 --image rockylinux-10-x64 --size s-1vcpu-1gb --ssh-keys <key-id> --tag-names "course:42-05-0112,student:<id>,week:1" --project-id <project-uuid> --wait --format ID --no-header

Creates the Droplet and waits until it is active. --ssh-keys accepts the key ID from step 3, not a file path; --tag-names applies all three labels, one of which (week:1) attaches the firewall; --project-id files it under the course project at creation. --wait returns only when the Droplet is running, so the next command can use its address.

doctl compute droplet get <droplet-id> --format PublicIPv4 --no-header

Prints the IPv4 address assigned to the Droplet. That address is what SSH uses, and it changes if the Droplet is destroyed and rebuilt.

mkdir -p data

Creates the data/ folder the evidence files are saved into if it is not already present.

doctl compute droplet list -o json > data/droplet-before.json

Saves the account's Droplet list as JSON before teardown. The notebook reads the fields that prove the Droplet's name, region, size, image, tags and status. On a fresh student account this file contains exactly one Droplet.

ssh -i ~/.ssh/do_s1 root@<droplet-ip> 'hostname; id'

Opens the first key-only session and runs two short commands. hostname prints the Droplet's generated name and id prints uid=0(root); together they prove the key works and that you are root. DigitalOcean disables password authentication on key-created Droplets, so there is no password prompt to fall back on.

exit

Closes the SSH session and returns you to the laptop. Nothing on the Droplet depends on the session staying open.

สรุปภาษาไทย สร้าง Droplet ขนาด s-1vcpu-1gb อิมเมจ Rocky Linux 10 ในภูมิภาค sgp1 พร้อมแท็กสามตัวและโปรเจกต์ จากนั้นอ่าน IP ด้วย `doctl compute droplet get` บันทึกรายการ Droplet เป็น JSON และเข้าสู่เครื่องด้วยกุญแจ SSH เพื่อยืนยันว่า `hostname` และ `id` ทำงาน (ได้ uid=0(root)) ระบบปิดการล็อกอินด้วยรหัสผ่านสำหรับ Droplet ที่สร้างด้วยกุญแจ
中文总结 在区域 sgp1 创建一个规格为 s-1vcpu-1gb、镜像为 Rocky Linux 10 的 Droplet,带上三个标签并放入项目。然后用 `doctl compute droplet get` 读取 IP,把 Droplet 的清单保存为 JSON,并用 SSH 密钥登录机器,确认 `hostname` 和 `id` 能正常工作(得到 uid=0(root))。用密钥创建的 Droplet 会禁用密码登录。

6. Failure drill: lock yourself out and recover from the panel

This is the session's deliberate failure. You will make the firewall reject your own address, watch SSH time out, then restore access from the Control Panel — which proves the management plane works even when the data plane does not.

Panel path: Networking → Firewalls → course--s1 → Rules → Inbound SSH → Edit, change the source to 203.0.113.1/32 (the TEST-NET address that stands for "somewhere else"), and save.

ssh -o ConnectTimeout=5 -i ~/.ssh/do_s1 root@<droplet-ip> 'hostname'

Attempts the login under the broken rule. It must time out or be refused: the firewall drops packets from your address before they reach the Droplet. A timeout here is the expected result, not a bug.

Panel path: Networking → Firewalls → course--s1 → Rules → Inbound SSH → Edit, restore the source to $MYIP/32 and save.

ssh -o ConnectTimeout=5 -i ~/.ssh/do_s1 root@<droplet-ip> 'hostname'

Attempts the same login after the panel change. It must succeed again within a few seconds. Record the elapsed time: DigitalOcean applies firewall rule changes quickly, and the number is part of your evidence.

doctl compute firewall get <firewall-id> -o json > data/firewall-before.json

Saves the restored firewall configuration as JSON before teardown. The notebook asserts one inbound TCP 22 rule from a single /32 address and the three outbound rules.

API extension. The panel is the required recovery path because it is out-of-band. The same change can be made through the API, and the reference run uses it to measure propagation:

doctl compute firewall update <firewall-id> --name "course-<id>-s1" --inbound-rules "protocol:tcp,ports:22,address:203.0.113.1/32" --outbound-rules "protocol:tcp,ports:0,address:0.0.0.0/0 protocol:udp,ports:0,address:0.0.0.0/0 protocol:icmp,ports:0,address:0.0.0.0/0" --tag-names "week:1"

Replaces the whole firewall representation with the broken rule. update resets anything you omit, which is why every rule and the tag are repeated.

doctl compute firewall update <firewall-id> --name "course-<id>-s1" --inbound-rules "protocol:tcp,ports:22,address:$MYIP/32" --outbound-rules "protocol:tcp,ports:0,address:0.0.0.0/0 protocol:udp,ports:0,address:0.0.0.0/0 protocol:icmp,ports:0,address:0.0.0.0/0" --tag-names "week:1"

Restores the rule from your address. Run it only after you have watched the timeout; this is the API path, and the panel path is what the brief requires you to demonstrate.

สรุปภาษาไทย แบบฝึกความล้มเหลวโดยตั้งกฎขาเข้าชั่วคราวให้รับเฉพาะ 203.0.113.1/32 แล้วลอง SSH จะหมดเวลา จากนั้นแก้กฎกลับผ่าน Control Panel ซึ่งพิสูจน์ว่าระนาบจัดการยังใช้งานได้แม้ระนาบข้อมูลล้มเหลว บันทึกเวลาที่กฎมีผลและบันทึกไฟร์วอลล์เป็น JSON ภาคผนวกแสดงเส้นทาง API ที่ใช้ทดสอบเวลาการปรับใช้
中文总结 演练一次故障:临时设置一条入站规则,只接受 203.0.113.1/32,然后尝试 SSH,连接会超时。接着通过 Control Panel 把规则改回来,这证明即使数据平面失效,管理平面仍然可用。记录规则生效的时间,并把防火墙保存为 JSON。附录展示用于测试生效时间的 API 路径。

7. Set the spend alert and read the bill

Panel path: Billing → Spend alerts → Add alert, set a $10 monthly budget and percentage email thresholds, then Billing → Insights for the current usage view.

doctl balance get

Prints the month-to-date balance, the account balance and month-to-date usage. Record the usage before and after the lab; the difference is the lab's real cost. There is no CLI path for creating a spend alert — it is panel-only, and the email is a warning, not a cap.

สรุปภาษาไทย ตั้งการแจ้งเตือนการใช้จ่าย 10 ดอลลาร์ต่อเดือนผ่านหน้า Billing (ไม่มีคำสั่ง CLI) และใช้ `doctl balance get` อ่านยอดใช้จ่ายก่อนและหลังแล็บ ผลต่างคือค่าใช้จ่ายจริง การแจ้งเตือนเป็นเพียงอีเมล ไม่ได้หยุดการใช้จ่าย
中文总结 通过 Billing 页面设置每月 10 美元的支出提醒(没有 CLI 命令),并使用 `doctl balance get` 读取实验前后的支出余额。两者的差额就是真实成本。提醒只是一封邮件,并不会停止支出。

8. Capture the evidence

Take the ten items in the evidence bundle below. Redact the account email, account UUID, project UUID and every token value; a token page is captured with the secret covered and the expiry date visible. Copy the four JSON files into data/ and run the notebook.

Your shell can produce item 8 for you:

history > data/commands-raw.log

Writes the commands you typed to a raw file. Open it, delete or replace the account email, UUIDs, tokens and IP addresses, save the result as data/commands-host.log, and delete the raw file. The published log is the sanitized one; a raw trace is never submitted.

9. Tear down and prove the account is clean

Panel path: Droplets → course--s1 → Destroy and Networking → Firewalls → course--s1 → Delete. If you used the Control Panel, capture the confirmation dialogs; the CLI is faster and produces machine-checkable JSON.

doctl compute droplet delete <droplet-id> --force

Destroys the Droplet without a confirmation prompt. This is the command that stops the meter; powering off would not.

doctl compute firewall delete <firewall-id> --force

Deletes the firewall. It has no cost, but leaving it behind means later Droplets that carry week:1 are silently protected by a rule you have forgotten.

doctl compute droplet list -o json > data/droplet-after.json

Saves the post-teardown Droplet list. On a fresh account it is an empty array; the notebook also accepts an account with unrelated Droplets as long as no week:1 Droplet remains.

doctl compute firewall list -o json > data/firewall-after.json

Saves the post-teardown firewall list. The proof is the same: no firewall carrying week:1.

doctl balance get

Reads the bill after teardown. Month-to-date usage minus the starting value must be under the $0.10 ceiling; an idle Droplet left behind would keep the number growing.

If you ran on a shared instructor slot, also remove the objects the lab created so the next student starts clean:

doctl projects delete <project-uuid> --force

Deletes the project. On your own account, keep it for the course.

doctl compute ssh-key delete <key-id> --force

Deletes the imported public key. On your own account, keep it for the course.

สรุปภาษาไทย ทำลาย Droplet และลบไฟร์วอลล์ แล้วบันทึกรายการหลังรื้อเป็น JSON สองไฟล์ หลักฐานคือไม่มีทรัพยากรที่ติดแท็ก week:1 เหลืออยู่ และอ่านยอดใช้จ่ายอีกครั้งเพื่อยืนยันว่าต่ำกว่า 0.10 ดอลลาร์ หากใช้บัญชีอาจารย์ที่แชร์กัน ให้ลบโปรเจกต์และคีย์ SSH ที่สร้างขึ้นด้วย
中文总结 销毁 Droplet 并删除防火墙,然后把拆除后的清单保存为两个 JSON 文件。证据是不再有带 week:1 标签的资源残留,并且再次读取支出余额以确认低于 0.10 美元。如果使用共享的教师账号,还要删除创建的项目和 SSH 密钥。

Evidence bundle

Submit ten items; the bundle is scored 3/2/1/0.

  1. The 2FA and backup-method page, captured pre-course.
  2. The project and the three Droplet tags.
  3. The SSH key fingerprint from doctl and ssh-keygen side by side.
  4. The token page with the secret covered: scopes and expiry visible.
  5. The firewall rules: one inbound TCP 22 /32, three outbound rules, tag week:1.
  6. The running Droplet with its IP, and the first-login proof (hostname and uid=0(root)).
  7. The $10 spend-alert screenshot.
  8. The sanitized command log — no token, account ID or email.
  9. The empty post-teardown lists, doctl balance get, and the Insights view.
  10. A 150–250 word what this proves note.

The notebook's inventory.json is the machine-checkable companion. The failure-drill log (the timeout, the panel change, the successful retry and the elapsed time) belongs inside item 5.

Cost ceiling

Under $0.10. The main spender is one s-1vcpu-1gb Droplet at $0.00893/hour, so the ceiling is about eleven Droplet-hours. The firewall, project, key, tag and spend alert are free. Read doctl balance get at the start and the end; record both numbers and the difference.

Teardown

Destroy the Droplet, delete the firewall, then prove both lists are empty of week:1 resources. Read the bill. Keep the project, SSH key, token and spend alert on your own account for the rest of the course; delete the project and key only if you used a shared instructor slot. The token expires after 90 days by design.

Failure and recovery chain

  • No card or signup blocked: use an instructor-owned account slot; the evidence shape does not change. Item 1 becomes the instructor's 2FA page.
  • doctl blocked on the network: follow the panel checklist instead; capture each panel screen. The JSON evidence is replaced by screenshots and the instructor records the deviation.
  • Outbound SSH blocked: use the Droplet's browser console for the login proof now, and repeat the SSH login from another network before submission.
  • Droplet creation fails with 403: the token is missing a scope. Create a new token with the full table in step 1; tokens cannot be edited.
  • Private key lost: Rocky Linux's root password cannot be reset from outside. Destroy the Droplet and repeat steps 5–9 with a new key. This is why key custody is a warning, not a drill.

Self-study: the domain and Cloudflare zone (due before Session 2)

The CDN session assumes a domain you own and a Cloudflare zone that is already active. Do this outside the two-hour lab, before Session 2; the TA checks it at the start of S2.

  1. Register a cheap root domain (about $8–12/year, paid by you — it is your asset, not a course purchase). Do not register a subdomain: Cloudflare Free cannot host a subdomain as its own zone.
  2. Create a free Cloudflare account, choose Add a site, enter the root domain, and take the Free plan.
  3. At your registrar, replace the registrar's nameservers with the two Cloudflare nameservers shown in the dashboard. Propagation can take up to 24 hours.
  4. Prove it:
dig NS <root-domain> +short

Prints the nameservers that answer for your domain. The two names must end in .ns.cloudflare.com; an empty or registrar answer means the change has not propagated yet. Take a screenshot of the Cloudflare zone in the Active state as the second proof. The instructor's demo hostname is a fallback for Session 4, not a substitute for your own zone.

สรุปภาษาไทย งานศึกษาด้วยตนเองก่อนเซสชัน 2: จดทะเบียนโดเมนระดับราก (ประมาณปีละ 8–12 ดอลลาร์ จ่ายเอง) สร้างบัญชี Cloudflare ฟรี เพิ่มโดเมน และเปลี่ยนเนมเซิร์ฟเวอร์ที่ผู้ให้บริการจดทะเบียนเป็นของ Cloudflare ซึ่งอาจใช้เวลาถึง 24 ชั่วโมง ตรวจสอบด้วย `dig NS +short` ว่าตอบเป็นชื่อที่ลงท้ายด้วย `.ns.cloudflare.com` และถ่ายภาพโซนที่สถานะ Active
中文总结 第 2 课之前的自学任务:注册一个根域名(每年约 8–12 美元,自费),创建一个免费的 Cloudflare 账号,添加域名,并把注册商处的名称服务器改为 Cloudflare 的名称服务器,这可能需要长达 24 小时。用 `dig NS <root-domain> +short` 检查,应答应是名称以 `.ns.cloudflare.com` 结尾,并截取处于 Active 状态的区域(zone)。

Reference run

The published sequence above is the learner form. The reference run executes it end to end and records the differences below, so no executed command is unexplained. The ssh-keygen call omits the passphrase prompt and writes to a temporary path; the SSH poll repeats the login until the Droplet answers; the image check is the same one from step 1.

ssh-keygen -t ed25519 -N "" -C "course-s1-<id>" -f <temporary-key-path>
ssh -o BatchMode=yes -o ConnectTimeout=5 -i <private-key> root@<droplet-ip> true
doctl compute image list --public --format Slug --no-header | grep -x rockylinux-10-x64

COMMANDS.md records the executed order and the sanitized trace is data/commands-host.log.

Notebook

Open the lab notebook. Save the four JSON files into data/, set LAB_START and LAB_FINISH to your lab's ISO-8601 window (or edit the two values in the cost cell), and run the notebook top to bottom. It writes inventory.json; the final assertion is the completion gate.

Downloads for this session

Each document name opens a rendered view you can read in the browser. The download link beside it gives you the raw Markdown working file: the copy you edit, run and submit. The page above and the lab steps carry the teaching.

lab.md download lab.md
The numbered lab brief: the steps, the commands and the evidence you submit.
refs.md download refs.md
The reference list behind this session's claims.
PLO.md download PLO.md
This session's scoring rows and descriptors.
download notebook.ipynb
The runnable notebook that produces the lab's numbers.

Research question

Under what conditions should the campus media unit keep predictable production work on-premises or at the edge rather than renting it from DigitalOcean?

Submit an 800–1,200 word answer with 5–8 sources at the next session. The rubric and the exemplar guidance show the expected shape.

References — Session 1

  1. Armbrust, M., Fox, A., Griffith, R., Joseph, A. D., Katz, R., Konwinski, A., Lee, G., Patterson, D., Rabkin, A., Stoica, I., & Zaharia, M. (2010). A view of cloud computing. Communications of the ACM, 53(4), 50–58. https://doi.org/10.1145/1721654.1721672
  2. Digital-media relevance: defines elasticity and pay-as-you-go, the economics the unit relies on when its 40-video month meets an idle week.
  3. Still open: when is predictable, high-volume transcoding cheaper on owned hardware than on metered capacity?
  4. Figures: third-party; do not copy without permission — redraw any diagram.
  5. Satyanarayanan, M. (2017). The emergence of edge computing. Computer, 50(1), 30–39. https://doi.org/10.1109/MC.2017.9
  6. Digital-media relevance: explains why distance and bandwidth, not compute, limit interactive media delivery to Chiang Mai viewers.
  7. Still open: what edge footprint is justified for a low-volume regional catalogue when the origin sits in Singapore?
  8. Figures: third-party; redraw by default.
  9. Buyya, R., Yeo, C. S., Venugopal, S., Broberg, J., & Brandic, I. (2009). Cloud computing and emerging IT platforms: Vision, hype, and reality for delivering computing as the 5th utility. Future Generation Computer Systems, 25(6), 599–616. https://doi.org/10.1016/j.future.2008.12.001
  10. Digital-media relevance: frames IaaS, PaaS and SaaS and the service-level language the session and the lab use.
  11. Still open: how comparable are provider SLAs for media-specific guarantees such as sustained egress?
  12. Figures: third-party; redraw by default.

Teaching note. Narrate the anchor (Armbrust et al.) for 5–8 minutes, assign the Satyanarayanan abstract, and close by restating the open problem as the weekly question: under what conditions should the unit keep predictable production work on-premises or at the edge rather than renting it from DigitalOcean? Figures are third-party unless stated; redraw by default.

PLO — Session 1: Cloud foundations

CLO: By the end of this session, the student can explain why a media unit rents elastic capacity and set up a safe, budgeted DigitalOcean account.

PLO Role Research answer Lab evidence Points Evidence Rubric
PLO1 primary 4 0 4 800–1,200-word answer with 5–8 sources; the cloud-vs-on-prem argument for the unit Research 4/3/2/1
PLO3 secondary 0 3 3 The ten-item account, token, firewall, first-login, spend-alert and teardown bundle, plus inventory.json Lab 3/2/1/0
Total 4 3 7

Total: 7 points

Four-level descriptors

Research (4/3/2/1). 4 = a defensible thesis, 5–8 credible sources with independent evidence, a counterargument, the fact sheet applied, correct citations. 3 = a sound answer with curated sources and some independent evidence. 2 = a summary that only partly answers the question. 1 = a comprehension summary with fewer than five sources or no citations. 0 = nothing submitted or misconduct.

Lab (3/2/1/0). 3 = complete and correct evidence, reproducible, the note explains the trade-off, teardown and cost respected. 2 = mostly correct, thin trade-off. 1 = partial evidence, incomplete teardown. 0 = nothing submitted, unsafe data, or no teardown.

The full course arithmetic and the ten questions are in the assessment note; this file is the weekly instance.