get_savings_plans_utilization
Retrieve AWS Savings Plans utilization percentages for specified date ranges to monitor cost optimization effectiveness.
Instructions
Retrieves Savings Plans utilization percentages.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | Start date (YYYY-MM-DD). | |
| end_date | Yes | End date (YYYY-MM-DD). |
Implementation Reference
- src/index.ts:1098-1113 (handler)Handler function that calls AWS Cost Explorer's GetSavingsPlansUtilizationCommand with the provided time period, processes the response to extract utilization metrics (percentage, commitments), and returns formatted JSON.if (name === "get_savings_plans_utilization") { const command = new GetSavingsPlansUtilizationCommand({ TimePeriod: { Start: (args as any).start_date, End: (args as any).end_date } }); const response = await costExplorerClient.send(command); const utils = response.SavingsPlansUtilizationsByTime?.map(u => ({ Date: u.TimePeriod?.Start, UtilizationPercentage: u.Utilization?.UtilizationPercentage + "%", TotalCommitment: u.Utilization?.TotalCommitment, UsedCommitment: u.Utilization?.UsedCommitment, UnusedCommitment: u.Utilization?.UnusedCommitment })) || []; return { content: [{ type: "text", text: JSON.stringify(utils, null, 2) }] }; }
- src/index.ts:257-268 (registration)Tool registration entry in the ListTools response, including name, description, and input schema definition (Zod-like object requiring start_date and end_date).{ name: "get_savings_plans_utilization", description: "Retrieves Savings Plans utilization percentages.", inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." } }, required: ["start_date", "end_date"] } },
- src/index.ts:260-267 (schema)Input schema for the tool, defining required string parameters for start_date and end_date in YYYY-MM-DD format.inputSchema: { type: "object", properties: { start_date: { type: "string", description: "Start date (YYYY-MM-DD)." }, end_date: { type: "string", description: "End date (YYYY-MM-DD)." } }, required: ["start_date", "end_date"] }
- src/index.ts:24-24 (helper)Import of GetSavingsPlansUtilizationCommand from AWS SDK Cost Explorer client.import { CostExplorerClient, GetCostAndUsageCommand, GetCostForecastCommand, GetAnomaliesCommand, GetSavingsPlansUtilizationCommand, GetReservationUtilizationCommand } from "@aws-sdk/client-cost-explorer";
- src/index.ts:58-58 (helper)Initialization of the CostExplorerClient used by the handler.const costExplorerClient = new CostExplorerClient({});