Practice in your account · 25 min
AWS Budgets alerts for the first charge and for your labs
In this lab you will create an AWS Budgets alert that notifies you of the first charge and a budget that only counts the spend of the resources that carry your labs' tag.
In this lab you will create two budgets in AWS Budgets, the AWS service that watches how much you spend and sends you an email when spend goes over a limit you set. The first one notifies you as soon as any charge shows up in your account, and the second one only counts the spend of the resources that carry the cloudpath:lab tag.
A tag is a note you attach to a resource, with a key and a value, such as cloudpath:lab = saa-lab17a. The second budget is an example of what the exam calls cost allocation (domain 4), which consists of knowing how much each project, team or environment spends. For example, an online store that tags its servers with the key area and the value sales or shipping can see at the end of the month how much each area spent, even though everything is in the same account.
Do this lab before the others, because the other five create a load balancer, a database and a CloudFront distribution, and some of those resources charge by the hour while they exist. If the alert isn't in place beforehand, you only find out about the charge when the bill arrives. For example, if you finish the load balancer lab and forget to delete it, the alert notifies you with the first charge instead of letting it keep charging all month.
Before you start
For this lab you need your email at hand, because AWS Budgets asks you to confirm the alerts. If you have a full account, sign in with a user or role that has billing permissions, which are the ones that let you see and manage what the account is charged.
If your account is also in an organization, cost allocation tags can only be activated from the management account, which is the account that created the organization and pays the bill for all of them. For example, if you study with an account your school gave you inside its organization, the person who manages that organization is the one who can activate the tag.
If your account is a new experience account, your project lives in us-east-2 (Ohio) and the console has no Region selector. In that account, Budgets is in the Billing and Cost Management console, and project members can create budgets.
An alert for the first charge
The first budget comes from an AWS Budgets template, which is a ready-made budget you only have to fill in, and notifies you as soon as your spend goes over the Free Tier limits. For example, if an instance you created in a lab stays running and starts charging, you get an email with that first charge. If you already created it in the Cloud Practitioner practice step, don't repeat it.
- Open the Billing and Cost Management console (https://console.aws.amazon.com/cost-management/).
- In the navigation pane, choose Budgets.
- Choose Create budget.
- Under Budget setup, choose Use a template (simplified).
- Under Templates, choose Zero spend budget. This budget notifies you when your spend goes over the Free Tier limits.
- Enter your email in the recipients and choose Create budget.
By default, a budget counts cost after subtracting credits, which are a balance AWS gives you and that pays your charges before you are charged. That is why, while the free plan credit covers your charges, the alert may not go off even though you are spending that credit. For example, if a forgotten database spends part of your credit, as far as the budget is concerned your cost is still zero and it doesn't notify you.
cloud path tip: when you finish each lab, check your credit balance on the Billing and Cost Management home page, because the alert doesn't notify you while the credit covers the spend.
If your account is a new experience account and you don't see Use a template, create a monthly cost budget of 1 USD with an alert on actual spend at 1%. This budget is different from the spend limit in AWS Settings, which only exists in the paid plan and pauses the project when it reaches the cap. The difference is what happens when the limit is reached: the budget only sends you an email and your resources keep running, while the spend limit stops the project.
Your labs' spend by tag
The second budget is created by the [lab17-presupuesto-etiqueta.yaml](/roadmaps/plantillas/lab17-presupuesto-etiqueta.yaml) CloudFormation template, together with an empty, private S3 bucket that carries the cloudpath:lab = saa-lab17a tag. That bucket exists only so the tag key shows up in the console, because a key only shows up when some resource uses it.
The budget is monthly, filtered by that tag, and has two alerts: one at 80% of actual spend and another at 100% of forecasted spend. Actual spend is what you have already spent in the month, and forecasted spend is what AWS calculates you will have spent by the end of the month if you keep the same pace. For example, with this lab's amount of 5 USD, the first alert arrives when your labs have already spent 4 USD, and the second one can arrive before you spend it, as soon as the spending pace points to going over 5 USD.

A tag goes through two waits before it reaches the cost report. After you tag a resource, the tag key takes up to 24 hours to show up in the console, and once you activate it, it takes up to 24 more hours to become active. Activating it is what turns a tag into a cost allocation tag, that is, one that billing reports do use to separate spend. Meanwhile, the filtered budget shows 0 USD, so you activate the tag the day after you create the stack. For example, if you create the stack on a Monday, activate the tag on Tuesday and wait until Wednesday to see the spend in the budget.
- Open the CloudFormation console and choose Create stack, With new resources (standard).
- Choose Upload a template file, upload
lab17-presupuesto-etiqueta.yamland choose Next. - Name the stack
cloudpath-saa-lab17-presupuesto. InCorreoenter your email; leaveMontoMensualat 5 andValorEtiquetaatsaa-lab17a. - Choose Next twice and then Submit. Wait for the stack to reach
CREATE_COMPLETE. - If you get an email from AWS Budgets, confirm the subscription.
- The next day, open Billing and Cost Management, go to Cost allocation tags and to the user-defined tags tab. Select
cloudpath:laband choose Activate. - Open the
cloudpath-saa-lab17a-etiquetabudget in Budgets and check the filter. The key shows up asuser:cloudpath:lab, because the keys you define carry theuser:prefix and the ones AWS creates carryaws:.
The same key works for the whole step, because every template in this step puts the cloudpath:lab tag on its resources, each one with its own value (saa-lab03, saa-lab07, saa-lab08c, saa-lab10, saa-lab13a). If you want a budget that counts the spend of all the labs, create another one from the console with those values in the filter. For example, a budget filtered only by saa-lab07 counts the spend of the load balancer and its instances, and one with all the values counts the spend of the five labs together.
If your account is a new experience account, keep in mind that the Billing documentation for projects doesn't say whether cost allocation tags are available. If activating the tag gives an error, the budget is still created but stays at 0 USD. In that case keep the zero spend budget and write down what the console told you.
True or false?
0 of 3As soon as you tag a resource, the filtered budget starts counting its spend.
In the budget filter, the cloudpath:lab key shows up as user:cloudpath:lab.
While the free plan credit covers your charges, the zero spend budget always notifies you.
How to know you're done
When you finish, you have to see two budgets in Budgets: the zero spend template one and cloudpath-saa-lab17a-etiqueta. To check it from CloudShell, run this command, which first saves your account number and then lists your budgets with their limit and what they have spent so far:
CUENTA=$(aws sts get-caller-identity --query Account --output text)
aws budgets describe-budgets --account-id "$CUENTA" \
--query "Budgets[].[BudgetName,BudgetLimit.Amount,CalculatedSpend.ActualSpend.Amount]" \
--output table
In a full account you can also see the key's status with this command, which has to show "Status": "Active":
aws ce list-cost-allocation-tags --tag-keys cloudpath:lab
Delete what you created
Don't delete anything for now, because budgets don't charge and you will use them in the other five labs of the step. When you finish the step, delete the cloudpath-saa-lab17-presupuesto stack from CloudFormation (Delete), which deletes the empty bucket and the filtered budget.
Keep the zero spend budget, because it is the one that notifies you if something was left running. The key you activated can be deactivated on the same cost allocation tags page.
On the exam
Cost questions that ask to "know how much each department spends" or to "allocate costs by project" are solved with activated cost allocation tags, plus Cost Explorer or Budgets filtered by those tags. Cost Explorer is the AWS service that shows in charts how much you have spent and on what. For example, the store that tags its resources with area = sales and area = shipping opens Cost Explorer, filters it by the area key and sees each area's spend separately.
Also keep in mind that AWS Budgets notifies but doesn't stop resources, unless you configure actions for it, which are steps the budget runs on its own when it reaches the limit. For example, without actions, a budget that goes over only sends you an email, and the instance that caused the spend keeps running.
Which solution do you choose?
A company has a single AWS account and wants to know each month how much each department spends. Which solution meets that requirement?
Next
- Activating user-defined cost allocation tags: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/activating-tags.html
- cloud path practice exams: /examenes?lang=en