View Billing Using AWS-CLI for S3 Service

Step 1: Create a file named filters.json, which will contain the command for billing specific to aws s3.

{
"Dimensions": {
"Key": "SERVICE",
"Values": [
"Amazon Simple Storage Service"
]
}
}

Step 2: Write a command to get the billing for s3 of your AWS account.

Note: Replace the time period as per the monthly spending you want to retrieve.

aws ce get-cost-and-usage \
--time-period Start=YY-MM-DD,End=YY-MM-DD \
--granularity MONTHLY \
--metrics "BlendedCost," "UnblendedCost," "UsageQuantity" \
--group-by Type=DIMENSION,Key=SERVICE Type=TAG,Key=Environment \
--filter file://filters.json

Step 3: After entering the command, you will see the output like this, which contains your monthly cost spent on AWS and also the usage quantity.

How to View Billing Details with AWS CLI: A Step-by-Step Guide

The AWS CLI can help you work with AWS from a command line. Users can control services and do tasks like launch EC2 instances or make S3 buckets. The CLI lets users configure resources for Lambda, EKS, RDS, and more AWS offerings. A big benefit is that users can include CLI commands in scripts, whether shell-based, Python, or other code. This automation handles repeated actions, manages cloud infrastructure, and streamlines operations. The AWS CLI gives users a flexible tool to administer AWS resources. Its scripting integration enables automation, infrastructure as code deployment, and simplified cloud operations management.

The AWS CLI has many commands, each with its own rules. These rules follow a consistent style, making CLI use easier across AWS services. Also, it shows output like JSON, text, and tables, letting you choose how to see it. One great thing about the AWS CLI is how it works with other tools and services. For instance, you can use it with tools like AWS CloudFormation or Terraform that set up infrastructure based on code. Or, you could add it to your CI/CD pipelines to automate tasks.

Similar Reads

Step-By-Step Procedure For View-Billing Using AWS CLI

Step 1: Log in to the AWS Console. Go to the AWS Management Console and log in to your AWS account....

View Billing Using AWS-CLI for S3 Service

Step 1: Create a file named filters.json, which will contain the command for billing specific to aws s3....

Conclusion

In this article, we have gone through a simple introduction of what exactly AWS cli is and why many users prefer to use it. We have also understood the step-by-step procedure for viewing the AWS account bill using AWS cli, and if billing is needed for a specific AWS service, then for that, what is the step-by-step procedure?...

View-Billing — AWS CLI – FAQs

What permissions are needed to view billing information with the AWS CLI?...