AWS Budgets
Set a number, get told when you cross it — and, if you want, have AWS do something about it. Cost Explorer tells you what already happened; a budget on forecasted spend is the only thing here that warns you before the money is gone.
Đặt một con số, được báo khi vượt — và nếu muốn, để AWS tự xử lý luôn. Cost Explorer chỉ kể chuyện đã rồi; budget theo chi phí dự báo mới là thứ duy nhất ở đây cảnh báo trước khi tiền bay mất.
Reach for it / not the right toolKhi nào dùng / khi nào không
Reach for BudgetsChọn Budgets
- "Tell me before we blow the monthly number" → a forecasted-cost budget at 80 %."Báo tôi trước khi vượt hạn mức tháng" → budget theo chi phí dự báo ở mức 80 %.
- A dev sandbox that must stop spending by itself — threshold → Budget Action stops EC2 or slaps on a restrictive SCP.Môi trường sandbox phải tự dừng tiêu tiền — chạm ngưỡng → Budget Action stop EC2 hoặc áp SCP hạn chế.
- Per-team or per-project limits: scope the budget to a cost allocation tag or a linked account.Hạn mức theo team hoặc project: giới hạn budget bằng cost allocation tag hoặc linked account.
- Watching that the RIs / Savings Plans you bought are actually being used — utilisation and coverage budgets.Theo dõi xem RI / Savings Plans đã mua có thật sự được dùng không — budget utilisation và coverage.
Not the right toolKhông phải chỗ dùng
- Analysing where the money went, slicing 12 months by service → Cost Explorer / Cost and Usage Report. Budgets is a tripwire, not a report.Phân tích tiền đi đâu, cắt 12 tháng theo service → Cost Explorer / Cost and Usage Report. Budgets là dây bẫy, không phải báo cáo.
- A hard cap that makes overspending impossible. Nothing in AWS does that; a Budget Action is a reaction, minutes-to-hours late.Một trần cứng khiến không thể vượt chi. AWS không có thứ đó; Budget Action chỉ là phản ứng, trễ vài phút tới vài giờ.
- Reacting to technical signals — CPU, errors, queue depth. That's CloudWatch alarms.Phản ứng với tín hiệu kỹ thuật — CPU, lỗi, độ dài hàng đợi. Đó là alarm của CloudWatch.
- Catching a weird spike right now — Budgets refreshes a few times a day; Cost Anomaly Detection is the anomaly tool.Bắt một cú tăng lạ ngay lúc này — Budgets chỉ làm mới vài lần mỗi ngày; Cost Anomaly Detection mới là công cụ bắt bất thường.
Four budget types, one question eachBốn loại budget, mỗi loại một câu hỏi
Pick the type by the question you're asking. Two of them are about money going out, two are about commitments you already paid for being wasted. Chọn loại theo câu hỏi bạn đang hỏi. Hai loại nói về tiền đang chảy ra, hai loại nói về cam kết đã trả tiền mà đang bị lãng phí.
Scope, notifications, pricePhạm vi, thông báo, giá
The filter list is worth memorising because it's identical to Cost Explorer's: Service, Linked Account, Tag, Purchase Option, Instance Type, Region, Availability Zone, API Operation. If Cost Explorer can slice it, a budget can watch it. Danh sách bộ lọc đáng nhớ vì nó giống hệt Cost Explorer: Service, Linked Account, Tag, Purchase Option, Instance Type, Region, Availability Zone, API Operation. Cost Explorer cắt được cái gì thì budget canh được cái đó.
| What you getBạn có gì | Note to selfGhi nhớ | |
|---|---|---|
| NotificationsThông báo | up to 5 SNS notifications per budget, each with its own threshold and actual/forecast choicetối đa 5 notification SNS mỗi budget, mỗi cái có ngưỡng riêng và chọn thực tế/dự báo riêng | an SNS topic is the hinge — email for humans, Lambda for automationtopic SNS là bản lề — email cho người, Lambda cho tự động hoá |
| ScopePhạm vi | Service · Linked Account · Tag · Purchase Option · Instance Type · Region · AZ · API OperationService · Linked Account · Tag · Purchase Option · Instance Type · Region · AZ · API Operation | the tag must be an activated cost allocation tag first, or it isn't in the listtag phải được kích hoạt ở cost allocation tag trước, nếu không sẽ không có trong danh sách |
| PeriodChu kỳ | daily · monthly · quarterly · annual, recurring or with a fixed end datengày · tháng · quý · năm, lặp lại hoặc có ngày kết thúc cố định | monthly is the default reflex; daily is how you catch a runaway job fasttheo tháng là phản xạ mặc định; theo ngày mới bắt kịp một job chạy loạn |
| PriceGiá | 2 budgets free, then ≈ $0.02 / day / budget2 budget miễn phí, sau đó ≈ $0.02 / ngày / budget | ≈ $0.60 a month each — never the reason to reject a design≈ $0.60 mỗi tháng cho một cái — đừng bao giờ vì giá này mà loại một thiết kế |
| Where it livesNằm ở đâu | the management account sees the whole org; a member account sees only itselfmanagement account thấy cả org; member account chỉ thấy chính nó | that split is exactly the centralized / decentralized choice belowchính sự chia đôi đó là lựa chọn tập trung / phân tán bên dưới |
Budget Actions — when notifying isn't enoughBudget Actions — khi báo thôi là chưa đủ
A budget on its own only shouts. A Budget Action is AWS pulling the handbrake for you when the threshold is breached. Three action types, and each one is a different flavour of "stop them spending". Budget một mình chỉ biết la lên. Budget Action là AWS kéo phanh tay giúp bạn khi ngưỡng bị vượt. Ba loại action, mỗi loại là một kiểu "chặn tiêu tiền" khác nhau.
Centralized vs decentralized in an OrganizationTập trung và phân tán trong một Organization
Same building blocks, opposite ownership. Centralized: the management account watches everyone and can move a spender into a restrictive OU. Decentralized: a CloudFormation StackSet drops the identical budget into every account and each one polices itself. Cùng khối xây dựng, ngược nhau về quyền sở hữu. Tập trung: management account canh mọi account và có thể đẩy kẻ tiêu quá vào một OU hạn chế. Phân tán: một StackSet của CloudFormation thả cùng một budget vào mọi account và mỗi account tự canh mình.
Centralized — one watcher, org-wide reactionTập trung — một người canh, phản ứng toàn org
Note the split at step 4: the Lambda both enforces (move the account, the SCP does the rest) and tells someone. Budget Actions can apply the SCP directly too — the Lambda version is what you write when the reaction is "move the account", not just "attach a policy".
Chú ý chỗ tách nhánh ở bước 4: Lambda vừa cưỡng chế (chuyển account đi, phần còn lại do SCP lo) vừa báo cho ai đó. Budget Actions cũng có thể áp SCP trực tiếp — bản Lambda là thứ bạn viết khi phản ứng là "chuyển account", chứ không chỉ "gắn policy".
Decentralized — the same budget, everywherePhân tán — cùng một budget, ở mọi nơi
The StackSet is the whole trick — you write the budget, the SNS topics and the Lambda once, and every account gets its own copy and reacts locally. Adding an account to the OU deploys it automatically.
StackSet chính là mấu chốt — bạn viết budget, các topic SNS và Lambda một lần, rồi mỗi account có bản sao riêng và tự phản ứng tại chỗ. Thêm account vào OU là nó tự được triển khai.
| CentralizedTập trung | DecentralizedPhân tán | |
|---|---|---|
| Who owns the budgetAi sở hữu budget | management account, one budget per member via an account filtermanagement account, mỗi member một budget qua account filter | each member account, deployed by a StackSettừng member account, được triển khai bằng StackSet |
| ReactionPhản ứng | move the account to a restrictive OU / apply an SCP — org-level enforcementchuyển account sang OU hạn chế / áp SCP — cưỡng chế ở tầm org | local: email on warning, Lambda stops EC2 on criticaltại chỗ: email khi cảnh báo, Lambda stop EC2 khi nghiêm trọng |
| Pick it whenChọn khi | finance must not be bypassable and reaction is a governance decisionbộ phận tài chính không được phép bị lách và phản ứng là quyết định quản trị | teams own their spend, and you want the identical guardrail in every new accountcác team tự chịu trách nhiệm chi phí, và bạn muốn cùng một guardrail trong mọi account mới |
- Budget data is not real time. Cost data refreshes a few times a day, so a threshold can be breached hours before the notification lands. Never design a hard cap around it — design a brake. Dữ liệu budget không thời gian thực. Dữ liệu chi phí làm mới vài lần mỗi ngày, nên ngưỡng có thể bị vượt hàng giờ trước khi thông báo tới. Đừng thiết kế trần cứng quanh nó — hãy coi nó là cái phanh.
- Forecast needs history. A brand-new account or a brand-new tag has nothing to extrapolate from, so forecasted alerts stay quiet for the first weeks. Pair every forecast threshold with an actual one. Dự báo cần lịch sử. Account mới toanh hay tag mới toanh thì không có gì để ngoại suy, nên cảnh báo dự báo im lặng trong vài tuần đầu. Hãy ghép mỗi ngưỡng dự báo với một ngưỡng thực tế.
- A tag-scoped budget only ever sees tagged resources. Untagged spend is invisible to it — activate the key in Cost Allocation Tags and keep an untagged catch-all budget too. Budget theo tag chỉ nhìn thấy tài nguyên có tag. Chi phí không tag là vô hình với nó — hãy kích hoạt key trong Cost Allocation Tags và giữ thêm một budget tổng để hứng phần chưa gắn tag.
- 5 notifications is the cap per budget. Need a sixth threshold, or a different filter? That's a second budget — and the second budget is where the $0.02/day starts. Tối đa 5 notification cho một budget. Cần ngưỡng thứ sáu, hoặc bộ lọc khác? Đó là budget thứ hai — và budget thứ hai là chỗ $0.02/ngày bắt đầu tính.
- A Budget Action needs an IAM role Budgets can assume. An action that silently never fires is almost always a missing or wrongly-trusted role, not a wrong threshold. Budget Action cần một IAM role để Budgets assume. Một action âm thầm không bao giờ chạy hầu như luôn là do thiếu role hoặc trust policy sai, chứ không phải do đặt sai ngưỡng.
Exam reflexesPhản xạ khi thi
| The question says…Đề nói… | AnswerTrả lời |
|---|---|
| "Notify before the monthly spend is exceeded""Báo trước khi vượt chi phí tháng" | a cost budget on forecasted spend → SNS. Actual-spend answers are the distractorbudget chi phí theo dự báo → SNS. Đáp án theo chi phí thực tế là mồi nhử |
| "Automatically stop resources when a threshold is hit, no human""Tự động dừng tài nguyên khi chạm ngưỡng, không cần người" | Budget Actions — stop EC2/RDS, or apply an IAM policy / SCPBudget Actions — stop EC2/RDS, hoặc áp IAM policy / SCP |
| "Same budget and alarms in every account of the org, least ongoing effort""Cùng một budget và cảnh báo trong mọi account của org, ít công duy trì nhất" | CloudFormation StackSets — decentralized deploymentStackSets của CloudFormation — triển khai phân tán |
| "An over-spending account must be restricted centrally""Account tiêu vượt phải bị hạn chế tập trung" | budget in the management account → SNS → Lambda moves it to a restrictive OU with an SCPbudget ở management account → SNS → Lambda chuyển nó sang OU hạn chế có SCP |
| "Alert when our Reserved Instances are underused""Cảnh báo khi Reserved Instances bị dùng thiếu" | a Reservation budget on utilisation — EC2, ElastiCache, RDS, Redshiftbudget Reservation theo utilisation — EC2, ElastiCache, RDS, Redshift |
| "Track spend per project / per team""Theo dõi chi phí theo project / theo team" | budget filtered by an activated cost allocation tag (or by linked account)budget lọc theo cost allocation tag đã kích hoạt (hoặc theo linked account) |