AWS – Estimating CloudFormation template costs

How to Install the proxy with squid on Ubuntu Serveur 20.04″ href=”” target=”_blank”>How to Install the proxy with squid on Ubuntu Serveur 20.04

Most of the recipes in this book have been managed and launched using CloudFormation, the AWS Infrastructure as Code service. CloudFormation has a convenient feature that allows you to directly plug in the resources from the template into the Simple Monthly Calculator.

Getting ready

For this recipe, you will need an existing CloudFormation template. The template does not need to be deployed as a stack; just the file is required.

In this example, we will use the template from  Chapter 6, Managing AWS Databases: 06-01-RDS.yaml.

How to do it…

Follow these steps to use a CloudFormation template as the basis for cost estimation:

  1. Run the following command to generate the report:
aws cloudformation estimate-template-cost \
 --template-body \
 file://06-01-RDS.yaml \
 --parameters ParameterKey=VPCId,ParameterValue=test \
 ParameterKey=SubnetIds,ParameterValue=\"test,test\" \
 ParameterKey=DBUsername,ParameterValue=test \
 ParameterKey=DBPassword,ParameterValue=test \
 --query Url \
 --output text

  1. Click or copy and paste the URL into a browser to see the report:

AWS Simple Monthly Calculator
  1. Click on  Amazon  RDS in the left-hand menu to see the individual service page details:

AWS Simple Monthly Calculator—RDS
  1. Click on  Estimate of  your  Monthly Bill to see a total summary of the template resources:

AWS Simple Monthly Calculator—total monthly payment

Using a CloudFormation template can save you a lot of time with the AWS Simple Monthly Calculator.

How it works…

The estimate-template-cost command requires all the parameters of your template. As you can see in the first step, the actual values aren’t important, because the template won’t actually be launched. You simply need to make sure that the type of value you give matches the required type for that parameter (for example, the SubnetIds value must be a list of values in this template).

The region that you specify is important! Some services (but not all) can cost different amounts depending on the region they are in. Generally, the us-east-1 region is the cheapest.

At the end of the command, we limit the output to just the report URL via the --query argument.

You can share the generated URL with others, but you will not be able to retrieve earlier reports unless you keep track of the URL yourself.

On the calculator website, the template’s resources will be pre-populated, even if you can’t immediately see them. The report always defaults to the Amazon EC2 service page, so you will have to go to the relevant service page via the left-hand menu (in this case, Amazon RDS).

Finally, you can see a complete report of your template’s monthly cost on the  Estimate of your Monthly Bill tab. If your template contains many different types of resources/services, you will see them summarized here.

See also

  • The Estimating costs with the Simple Monthly Calculator recipe

Comments are closed.