8 Aws Cur Command Examples (with examples)
In this article, we will explore 8 different use cases of the AWS CUR (Cost and Usage Report) command. These use cases will cover creating, querying, and deleting AWS usage report definitions. We will provide code examples for each use case, along with the motivation behind using them, an explanation of each argument, and an example output.
1. Create an AWS cost and usage report definition from a JSON file
aws cur put-report-definition --report-definition file://path/to/report_definition.json
Motivation: This use case allows you to create an AWS cost and usage report definition using a JSON file. This is useful when you have a predefined configuration for your usage reports and want to automate the creation process.
Arguments:
--report-definition
: The path to the JSON file containing the report definition. This file should include all the necessary configuration details for the report.
Example Output: None. If the command runs successfully, it will create a new usage report definition based on the provided JSON file.
2. List usage report definitions defined for the logged in account
aws cur describe-report-definitions
Motivation: This use case allows you to list all the usage report definitions defined for the logged-in account. It can be useful to check the existing report definitions and their configurations.
Arguments: None
Example Output:
{
"ReportDefinitions": [
{
"ReportName": "example-report",
"TimeUnit": "DAILY",
"Format": "textOrCsv",
"Compression": "ZIP",
"AdditionalSchemaElements": [
"RESOURCES"
],
"S3Bucket": "example-bucket",
"S3Prefix": "reports/",
"S3Region": "us-west-2",
"S3RegionDefault": "us-west-2",
"AdditionalArtifacts": []
}
]
}
This example output shows a single usage report definition with information about its name, time unit, format, compression, additional schema elements, S3 bucket and prefix, S3 region, and additional artifacts.
3. Delete a usage report definition
aws cur --region aws_region delete-report-definition --report-name report
Motivation: This use case allows you to delete a specific usage report definition. It can be helpful when you no longer need a particular report.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report to be deleted.
Example Output: None. If the command runs successfully, it will delete the specified usage report definition.
These were the three use cases provided by the AWS CUR command. Now let’s move on to the next set of use cases.
4. Modify a usage report definition
aws cur modify-report-definition --region aws_region --report-name report --report-definition file://path/to/report_definition.json
Motivation: This use case allows you to modify an existing usage report definition. It can be useful when you need to update the configuration of a report without recreating it from scratch.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report to be modified.--report-definition
: The path to the JSON file containing the updated report definition.
Example Output: None. If the command runs successfully, it will modify the specified usage report definition based on the updated JSON file.
5. Enable a usage report
aws cur enable-report --region aws_region --report-name report
Motivation: This use case allows you to enable a usage report that was previously disabled. Enabling a report allows you to start receiving cost and usage data for that report.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report to be enabled.
Example Output: None. If the command runs successfully, it will enable the specified usage report.
6. Disable a usage report
aws cur disable-report --region aws_region --report-name report
Motivation: This use case allows you to disable a usage report. Disabling a report stops the generation and delivery of cost and usage data for that report. It can be useful when you no longer need the data or temporarily want to halt the report.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report to be disabled.
Example Output: None. If the command runs successfully, it will disable the specified usage report.
7. Generate a usage report
aws cur start-report-creation --region aws_region --report-name report
Motivation: This use case allows you to generate a usage report manually. It can be useful when you need to immediately generate a report outside of the scheduled generation time.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report to be generated.
Example Output: None. If the command runs successfully, it will initiate the generation of the specified usage report.
8. Check the status of a usage report generation
aws cur describe-report-creation --region aws_region --report-name report
Motivation: This use case allows you to check the status of a usage report generation. It can be helpful to monitor the progress or identify any issues during the generation process.
Arguments:
--region
: The AWS region where the report definition exists.--report-name
: The name of the report for which you want to check the generation status.
Example Output:
{
"ReportCreationStatus": "SUCCEEDED"
}
This example output indicates that the usage report generation was successful.
Conclusion
In this article, we explored eight different use cases for the AWS CUR command. We covered creating and deleting usage report definitions, modifying report definitions, enabling and disabling reports, generating reports, and checking report generation status. Each use case was accompanied by code examples, motivations for usage, explanations of arguments, and example outputs. By understanding and utilizing these use cases, you can effectively manage AWS cost and usage reporting in your organization.