Sub topic 2
Budgets and alerts
Assume you know basic AWS compute, storage, and networking services. You should also be comfortable running terminal commands and reading JSON.
Budgets and alerts
A budget compares actual or forecast spending with a limit. It does not stop resource creation or shut down services. Use it to notify an owner before an unexpected bill becomes large.
Create a monthly cost budget with the AWS CLI:
aws budgets create-budget \
--account-id 123456789012 \
--budget file://budget.json \
--notifications-with-subscribers file://notifications.jsonThe budget file can define a 1,000 USD monthly limit:
{
"BudgetName": "monthly-total",
"BudgetLimit": { "Amount": "1000", "Unit": "USD" },
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}An actual-spend notification at 80 percent gives the owner time to investigate:
[
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 80,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{ "SubscriptionType": "EMAIL", "Address": "[email protected]" }
]
}
]Use separate budgets for important accounts, teams, or products. Add forecast notifications when a service is likely to exceed its limit later in the month.
Finding idle resources
Idle resources produce costs without providing useful capacity. EBS volumes with status available are detached from an EC2 instance:
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].{Id:VolumeId,SizeGiB:Size,Created:CreateTime}' \
--output tableConfirm the volume is not needed for recovery or auditing before deleting it. Also review unattached elastic IP addresses, unused load balancers, old snapshots, and stopped instances.
Rightsizing over-provisioned resources
Rightsizing means changing a resource to match observed demand. Review CPU, memory, network, and storage metrics over a representative period. A database with low CPU but high memory use should not be reduced based on CPU alone.
| Finding | Safer action |
|---|---|
| Consistently low utilization | Test a smaller instance |
| Predictable nightly inactivity | Schedule stopping or scaling |
| Short, interruptible batch work | Consider spot capacity |
Make one change at a time and watch latency, errors, and saturation after the change.
Storage tiering and lifecycle policies
Lifecycle rules move or delete objects automatically. This example moves log objects after 30 days and deletes them after 365 days:
{
"Rules": [
{
"ID": "logs-tiering",
"Status": "Enabled",
"Filter": { "Prefix": "logs/" },
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" }
],
"Expiration": { "Days": 365 }
}
]
}Apply it with:
aws s3api put-bucket-lifecycle-configuration \
--bucket my-example-bucket \
--lifecycle-configuration file://lifecycle.jsonStandard-IA reduces storage cost but charges for retrieval and has minimum storage-duration rules. Use it only when access is infrequent.
Exercise
An unattached 500 GiB volume is used for a required disaster-recovery copy. Should you delete it?
Show answer
No. Confirm its ownership and purpose first. Review its snapshot and retention strategy, then delete or tier it only if the recovery requirement remains satisfied.