Overview
The AWS Cost Explorer node for n8n retrieves cost and usage information from Amazon Web Services (AWS) using the AWS Cost Explorer API. Specifically, with the "Get Cost and Usage" operation, it allows users to query their AWS account for detailed cost and usage metrics over a specified time period, broken down by day, month, or hour. This is useful for monitoring cloud spending, generating reports, and analyzing trends in AWS resource consumption.
Practical examples:
- Automate daily or monthly AWS cost reporting.
- Integrate AWS cost data into dashboards or alerting workflows.
- Analyze historical AWS usage patterns for budgeting or optimization.
Properties
| Name | Meaning |
|---|---|
| Time Start | The start date for retrieving AWS costs. Data for this date is included. |
| Time End | The end date for retrieving AWS costs. Data for this date is excluded. |
| Granularity | How to break down the cost and usage data. Options: DAILY (by day), MONTHLY (by month), HOURLY (by hour). |
| Metrics | The metrics to include in the output. You can specify one or more metric names (e.g., "BlendedCost", "UnblendedCost", "UsageQuantity"). |
Output
The node outputs a json object containing the full response from the AWS Cost Explorer's getCostAndUsage API call. The structure typically includes:
{
"ResultsByTime": [
{
"TimePeriod": { "Start": "YYYY-MM-DD", "End": "YYYY-MM-DD" },
"Total": { /* metric values */ },
"Groups": [ /* if grouped data requested */ ],
"Estimated": true/false
}
// ...more periods
],
"DimensionValueAttributes": [ /* optional, if dimensions used */ ]
}
ResultsByTime: Array of objects, each representing a time period (day/month/hour) with associated cost and usage metrics.Total: Object mapping each requested metric to its value for that period.- Other fields may be present depending on the AWS API response.
Note: No binary data is produced; all output is JSON.
Dependencies
- AWS Account: Requires valid AWS credentials (Access Key ID, Secret Access Key, and Region) configured in n8n.
- n8n AWS Credentials: Must set up an AWS credential in n8n with appropriate permissions for the Cost Explorer API (
ce:GetCostAndUsage). - External Library: Uses the official
aws-sdkpackage.
Troubleshooting
Common issues:
- Invalid credentials: If AWS credentials are incorrect or lack required permissions, the node will throw authentication or authorization errors.
- Date format errors: Dates must be in
YYYY-MM-DDformat. Incorrect formats will result in API errors. - Missing required properties: All properties marked as required must be provided, or the node will fail.
- Unsupported operation: If an unsupported operation is selected, the node will throw an error indicating the operation is not supported.
Error messages and resolutions:
"Operation \"<name>\" not supported!": Ensure you have selected a valid operation ("Get Cost and Usage").- AWS API errors (e.g., "User is not authorized"): Check your AWS IAM policy for necessary permissions.
- Date range errors: Make sure "Time Start" is before "Time End".