aws-cost-calculator-cli 1.5.2__tar.gz → 1.9.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aws-cost-calculator-cli might be problematic. Click here for more details.

Files changed (24) hide show
  1. aws_cost_calculator_cli-1.9.1/CHANGES.md +375 -0
  2. aws_cost_calculator_cli-1.9.1/MANIFEST.in +3 -0
  3. {aws_cost_calculator_cli-1.5.2/aws_cost_calculator_cli.egg-info → aws_cost_calculator_cli-1.9.1}/PKG-INFO +170 -24
  4. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/README.md +167 -21
  5. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1/aws_cost_calculator_cli.egg-info}/PKG-INFO +170 -24
  6. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/aws_cost_calculator_cli.egg-info/SOURCES.txt +3 -1
  7. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/api_client.py +2 -1
  8. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/cli.py +553 -44
  9. aws_cost_calculator_cli-1.9.1/cost_calculator/cur.py +244 -0
  10. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/executor.py +59 -92
  11. aws_cost_calculator_cli-1.9.1/cost_calculator/forensics.py +323 -0
  12. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/setup.py +4 -4
  13. aws_cost_calculator_cli-1.5.2/COST_CALCULATION_METHODOLOGY.md +0 -130
  14. aws_cost_calculator_cli-1.5.2/MANIFEST.in +0 -3
  15. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/LICENSE +0 -0
  16. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/aws_cost_calculator_cli.egg-info/dependency_links.txt +0 -0
  17. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/aws_cost_calculator_cli.egg-info/entry_points.txt +0 -0
  18. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/aws_cost_calculator_cli.egg-info/requires.txt +0 -0
  19. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/aws_cost_calculator_cli.egg-info/top_level.txt +0 -0
  20. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/__init__.py +0 -0
  21. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/drill.py +0 -0
  22. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/monthly.py +0 -0
  23. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/cost_calculator/trends.py +0 -0
  24. {aws_cost_calculator_cli-1.5.2 → aws_cost_calculator_cli-1.9.1}/setup.cfg +0 -0
@@ -0,0 +1,375 @@
1
+ # Changelog
2
+
3
+ ## Version 1.8.0 (2025-11-07)
4
+
5
+ ### Added
6
+ - **New `cc investigate` command** - Multi-stage cost investigation tool
7
+ - Combines cost analysis, resource inventory, and CloudTrail events
8
+ - Automatically finds SSO profiles for accounts
9
+ - Generates comprehensive markdown reports
10
+ - Supports `--no-cloudtrail` flag for faster execution
11
+ - Example: `cc investigate --profile myprofile --account 123456789012`
12
+
13
+ ### Changed
14
+ - **Package cleanup** - Excluded backend, tests, and notebooks from PyPI distribution
15
+ - Backend code is only for Lambda deployment, not needed in CLI package
16
+ - Reduces package size and eliminates unnecessary files
17
+
18
+ ### Security
19
+ - Verified no sensitive data (company names, account IDs) in PyPI package
20
+ - All example data uses generic placeholders
21
+
22
+ ## Version 1.7.0 (2025-11-06)
23
+
24
+ ### Added
25
+ - **`--resources` flag for `cc drill` command**: Resource-level cost analysis using CUR data
26
+ - Shows individual resource IDs (EC2 instances, RDS databases, S3 buckets, etc.)
27
+ - Queries AWS Cost and Usage Report via Athena
28
+ - Works with both local execution and Lambda backend
29
+ - Requires `--service` filter to be specified
30
+ - Example: `cc drill --service "EC2 - Other" --account 123456789012 --resources`
31
+ - Displays top 50 resources by cost with usage types and regions
32
+ - **`cc setup-cur` command**: Configure CUR settings for resource-level queries
33
+ - Saves configuration to `~/.config/cost-calculator/cur_config.json`
34
+ - Prompts for: Athena database, table name, S3 output location
35
+ - Required before using `--resources` flag
36
+
37
+ ### Security
38
+ - **CRITICAL**: Removed all hardcoded sensitive data from CUR queries
39
+ - No hardcoded account IDs
40
+ - No hardcoded database names
41
+ - No hardcoded S3 bucket paths
42
+ - All configuration must be provided by user via `cc setup-cur`
43
+
44
+ ### Technical Details
45
+ - New module: `cost_calculator/cur.py` for local CUR queries
46
+ - New module: `backend/algorithms/cur.py` for Lambda CUR queries
47
+ - Updated `backend/handlers/drill.py` to support resource-level queries
48
+ - Service-to-product-code mapping for flexible service name handling
49
+ - Athena query execution with automatic polling and result parsing
50
+ - CUR configuration loaded from `~/.config/cost-calculator/cur_config.json` or environment variables
51
+
52
+ ## Version 1.6.3 (2025-11-06)
53
+
54
+ ### Added
55
+ - **`cc setup-api` command**: Automatically configure COST_API_SECRET
56
+ - Saves to `~/.zshrc` or `~/.bashrc` on Mac/Linux
57
+ - Saves to Windows user environment variables
58
+ - Prompts for secret with hidden input
59
+ - Updates existing configuration if already present
60
+
61
+ ## Version 1.6.2 (2025-11-06)
62
+
63
+ ### Fixed
64
+ - Updated installation instructions to use PyPI instead of local editable install
65
+
66
+ ## Version 1.6.1 (2025-11-06)
67
+
68
+ ### Fixed
69
+ - Sanitized all documentation to remove company-specific references
70
+ - Removed real account IDs and credentials from examples
71
+ - Updated all examples to use generic placeholder names
72
+
73
+ ## Version 1.6.0 (2025-11-06) - YANKED
74
+
75
+ **Note:** This version was yanked due to unsanitized documentation containing company-specific information.
76
+
77
+ ### Added
78
+ - **Flexible Authentication**: Multiple authentication methods for all commands
79
+ - `--sso <profile>`: SSO authentication with automatic login if session expired
80
+ - `--access-key-id`, `--secret-access-key`, `--session-token`: Static credentials
81
+ - Environment variable support: `AWS_PROFILE` for SSO, `AWS_ACCESS_KEY_ID` for static
82
+ - Auto SSO login: CLI automatically runs `aws sso login` if session is expired
83
+ - Applied authentication flags to all commands: `calculate`, `trends`, `monthly`, `drill`
84
+
85
+ ### Changed
86
+ - Enhanced profile loading to check `AWS_PROFILE` environment variable for SSO support
87
+ - Updated README with comprehensive authentication documentation
88
+
89
+ ### Benefits
90
+ - No manual SSO login required - CLI handles it automatically
91
+ - Support for temporary credentials via CLI flags
92
+ - Flexible authentication for different use cases (CI/CD, local dev, etc.)
93
+
94
+ ## Version 1.5.0 (2024-11-04)
95
+
96
+ ### Added
97
+ - **Analyze Command**: Pandas-based aggregations and statistical analysis
98
+ - `cc analyze --type summary`: Aggregate costs across all weeks (sum, avg, std, min, max)
99
+ - `cc analyze --type volatility`: Identify high-volatility services and outliers
100
+ - `cc analyze --type trends`: Auto-detect increasing/decreasing cost trends
101
+ - `cc analyze --type search`: Filter services by pattern or minimum cost
102
+ - **Profile Management**: CRUD operations for account profiles
103
+ - `cc profile list`: List all profiles
104
+ - `cc profile get --name <profile>`: Get profile details
105
+ - `cc profile create/update/delete`: Manage profiles in DynamoDB
106
+ - **Lambda Enhancements**:
107
+ - New Analyze Lambda function with AWS Data Wrangler layer (pandas/numpy)
108
+ - New Profiles Lambda function for DynamoDB operations
109
+ - 2GB memory, 900s timeout for analyze function
110
+ - Time series analysis and statistical aggregations
111
+
112
+ ### Changed
113
+ - Suppressed progress messages in JSON output mode for cleaner parsing
114
+ - Updated API client to support new analyze and profiles endpoints
115
+
116
+ ### Fixed
117
+ - JSON output now properly formatted without extra echo statements
118
+
119
+ ## Version 1.4.0 (2025-11-04)
120
+
121
+ ### Features Added
122
+
123
+ #### Lambda API Backend Support
124
+ - **Hybrid execution**: CLI now supports both local and Lambda API execution
125
+ - Set `COST_API_URL` and `COST_API_SECRET` environment variables to use Lambda backend
126
+ - Falls back to local execution if API not configured
127
+ - **Identical results**: API and local execution produce exactly the same output
128
+ - No changes to CLI interface - completely transparent to users
129
+
130
+ #### Configuration
131
+ - Environment variables:
132
+ - `COST_API_URL`: Base URL for Lambda API
133
+ - `COST_API_SECRET`: Shared secret for API authentication
134
+ - Alternative: `~/.config/cost-calculator/api_config.json`
135
+
136
+ #### Benefits
137
+ - **Centralized logic**: Cost analysis runs on Lambda
138
+ - **Multiple interfaces**: Same backend for CLI, web UI, Jupyter
139
+ - **No code changes**: Existing CLI commands work identically
140
+ - **Flexible deployment**: Choose local or API execution
141
+
142
+ ### Example Usage
143
+ ```bash
144
+ # Use local execution (default)
145
+ cc trends --profile myprofile
146
+
147
+ # Use Lambda API
148
+ export COST_API_URL="https://xxx.lambda-url.us-east-1.on.aws"
149
+ export COST_API_SECRET="your-secret"
150
+ cc trends --profile myprofile # Same command, uses API
151
+ ```
152
+
153
+ ### Documentation
154
+ - Added API client module
155
+ - Added executor module for hybrid execution
156
+ - Updated README with API configuration instructions
157
+
158
+ ---
159
+
160
+ ## Version 1.3.0 (2025-11-04)
161
+
162
+ ### Features Added
163
+
164
+ #### Drill-Down Cost Analysis
165
+ - **New command:** `cc drill --profile <name>`
166
+ - Investigate cost changes at different levels of detail with automatic grouping
167
+ - **Funnel approach**: Start broad, drill deeper based on findings
168
+ - Supports three filter types:
169
+ - `--service`: Filter by service name (e.g., "EC2 - Other")
170
+ - `--account`: Filter by account ID
171
+ - `--usage-type`: Filter by usage type
172
+ - Filters can be combined for deeper analysis
173
+
174
+ #### Automatic Grouping Logic
175
+ The command automatically shows the next level of detail:
176
+ - **No filters** → Shows services (same as trends)
177
+ - **Service only** → Shows accounts using that service
178
+ - **Account only** → Shows services in that account
179
+ - **Service + Account** → Shows usage types within that service/account
180
+ - **All three filters** → Shows regions
181
+
182
+ #### What It Shows
183
+ - Week-over-week comparisons (default: 4 weeks)
184
+ - Top 10 increases and decreases at the appropriate detail level
185
+ - Total rows showing sum of top 10 changes
186
+ - Percentage change and dollar amount
187
+ - Filters out noise (>$10 and >5% change)
188
+ - Most recent comparisons first
189
+
190
+ #### Use Cases
191
+ - **Investigate spikes**: See EC2 costs up? Drill to find which account
192
+ - **Account analysis**: Which services are driving costs in a specific account?
193
+ - **Service deep-dive**: Which usage types within EC2 are increasing?
194
+ - **Root cause analysis**: Follow the funnel from service → account → usage type
195
+
196
+ ### Example Workflow
197
+ ```bash
198
+ # 1. Start broad - see EC2 costs up $1000
199
+ cc trends --profile myprofile
200
+
201
+ # 2. Drill by service - see which accounts
202
+ cc drill --profile myprofile --service "EC2 - Other"
203
+ # Output: Account 123 is +$800
204
+
205
+ # 3. Drill deeper - see usage types
206
+ cc drill --profile myprofile --service "EC2 - Other" --account 123
207
+ # Output: DataTransfer-Regional-Bytes is +$750
208
+ ```
209
+
210
+ ### Documentation
211
+ - Updated README.md with drill-down examples and funnel approach
212
+ - Added drill command to CLI help
213
+ - Documented automatic grouping logic
214
+
215
+ ---
216
+
217
+ ## Version 1.2.0 (2025-11-04)
218
+
219
+ ### Features Added
220
+
221
+ #### Month-over-Month Cost Analysis
222
+ - **New command:** `cc monthly --profile <name>`
223
+ - Analyzes month-over-month cost changes at service level
224
+ - Compares consecutive calendar months (October vs September, etc.)
225
+ - Generates comprehensive markdown report
226
+ - Supports custom number of months: `--months 12`
227
+ - JSON output option: `--json-output`
228
+ - Custom output file: `--output monthly_trends.md`
229
+
230
+ #### What It Shows
231
+ - Service-level aggregation (total cost per service)
232
+ - Top 10 increases and decreases per month comparison
233
+ - Total rows showing sum of top 10 changes
234
+ - Percentage change and dollar amount for each service
235
+ - Filters out noise (>$50 and >5% change)
236
+ - Most recent comparisons first (reverse chronological)
237
+
238
+ #### Use Cases
239
+ - Monthly cost review and budget tracking
240
+ - Identifying large month-over-month changes
241
+ - Understanding seasonal cost patterns
242
+ - Tracking major service additions or removals
243
+ - Long-term cost trend analysis
244
+
245
+ ### Example Output
246
+ ```
247
+ October 2025 → November 2025
248
+ Increases: 1, Decreases: 10
249
+ Top: Savings Plans for AWS Compute usage (+$231,161.46)
250
+ ```
251
+
252
+ ### Documentation
253
+ - Updated README.md with monthly command examples
254
+ - Added monthly report documentation
255
+
256
+ ---
257
+
258
+ ## Version 1.1.0 (2025-11-04)
259
+
260
+ ### Features Added
261
+
262
+ #### Cost Trends Analysis with Dual Methodology
263
+ - **New command:** `cc trends --profile <name>`
264
+ - Analyzes cost changes with **two comparison methods**:
265
+ 1. **Week-over-Week (WoW)**: Compares consecutive weeks - catches immediate spikes
266
+ 2. **Trailing 30-Day (T-30)**: Compares to 4 weeks ago - shows sustained trends
267
+ - **Service-level aggregation**: Shows total cost per service (not usage type detail)
268
+ - Generates comprehensive markdown report with both methodologies
269
+ - Supports custom number of weeks: `--weeks 18`
270
+ - JSON output option: `--json-output`
271
+ - Custom output file: `--output weekly_trends.md`
272
+
273
+ #### What It Shows
274
+ - **Week-over-Week section**: Consecutive week comparisons (Monday to Sunday)
275
+ - **T-30 section**: 30-day baseline comparisons
276
+ - Top 10 cost increases and decreases for each comparison
277
+ - **Total rows**: Sum of top 10 changes for quick assessment
278
+ - Percentage change and dollar amount for each service
279
+ - Automatically filters out noise (>$10 and >5% change)
280
+ - Most recent comparisons first (reverse chronological)
281
+
282
+ #### Why Two Methodologies?
283
+ - **WoW**: Catches immediate changes, spikes, and weekly volatility
284
+ - **T-30**: Filters out noise, reveals sustained trends and real cost changes
285
+ - Together they provide both **immediate alerts** and **trend analysis**
286
+
287
+ #### Use Cases
288
+ - Weekly cost monitoring and anomaly detection
289
+ - Identifying sudden cost spikes (WoW) vs sustained increases (T-30)
290
+ - Understanding which services are trending up or down
291
+ - Tracking cost optimization efforts over time
292
+ - Distinguishing temporary spikes from permanent cost changes
293
+
294
+ ### Example Output
295
+ ```
296
+ WEEK-OVER-WEEK:
297
+ Week of Oct 19 → Week of Oct 26
298
+ Increases: 4, Decreases: 10
299
+ Top: EC2 - Other (+$949.12)
300
+
301
+ TRAILING 30-DAY (T-30):
302
+ Week of Oct 26 vs Week of Sep 28
303
+ Increases: 10, Decreases: 10
304
+ Top: EC2 - Other (+$886.39)
305
+ ```
306
+
307
+ ### Documentation
308
+ - Updated README.md with dual methodology explanation
309
+ - Added trends report format documentation
310
+ - Updated CLI help text
311
+
312
+ ---
313
+
314
+ ## Version 1.0.0 (2025-11-04)
315
+
316
+ ### Features Added
317
+
318
+ #### 1. Static AWS Credentials Support
319
+ - **New command:** `cc configure --profile <name>`
320
+ - Allows using static AWS credentials instead of SSO
321
+ - Supports temporary credentials with session tokens
322
+ - Credentials stored securely in `~/.config/cost-calculator/credentials.json` (600 permissions)
323
+
324
+ #### 2. Dual Authentication Methods
325
+ - **SSO Method:** For interactive use (existing)
326
+ ```bash
327
+ aws sso login --profile my_sso_profile
328
+ cc calculate --profile myprofile
329
+ ```
330
+
331
+ - **Static Credentials Method:** For automation/CI (new)
332
+ ```bash
333
+ cc configure --profile myprofile
334
+ # Enter: Access Key ID, Secret Access Key, Session Token (optional)
335
+ cc calculate --profile myprofile
336
+ ```
337
+
338
+ #### 3. Enhanced Help Documentation
339
+ - Updated `cc --help` with authentication method examples
340
+ - Added comprehensive guides:
341
+ - `COST_CALCULATION_METHODOLOGY.md` - Formula explanation
342
+ - `WEEKLY_COST_HISTORY.md` - Historical cost trends
343
+ - `PYPI_UPLOAD_GUIDE.md` - Publishing instructions
344
+
345
+ #### 4. PyPI Packaging
346
+ - Prepared for PyPI distribution as `aws-cost-calculator-cli`
347
+ - Added proper metadata, classifiers, and dependencies
348
+ - Created upload script: `./upload_to_pypi.sh`
349
+ - Added LICENSE (MIT), MANIFEST.in, .gitignore
350
+
351
+ ### Security Enhancements
352
+ - Credentials file permissions set to 600 (owner read/write only)
353
+ - Sensitive files excluded from git (.gitignore)
354
+ - No credentials leaked in error messages or logs
355
+
356
+ ### Documentation
357
+ - **README.md:** Installation and usage guide
358
+ - **COST_CALCULATION_METHODOLOGY.md:** Detailed formula explanation
359
+ - **WEEKLY_COST_HISTORY.md:** 18 weeks of historical data
360
+ - **PYPI_UPLOAD_GUIDE.md:** Publishing instructions
361
+
362
+ ### Commands Available
363
+ 1. `cc init` - Initialize profile with account list
364
+ 2. `cc configure` - Configure AWS credentials (NEW)
365
+ 3. `cc calculate` - Calculate costs
366
+ 4. `cc list-profiles` - List configured profiles
367
+
368
+ ### Configuration Files
369
+ - `~/.config/cost-calculator/profiles.json` - Profile configurations
370
+ - `~/.config/cost-calculator/credentials.json` - AWS credentials (NEW)
371
+
372
+ ### Next Steps
373
+ 1. Test with temporary AWS credentials
374
+ 2. Upload to PyPI
375
+ 3. Install from PyPI: `pip install aws-cost-calculator-cli`
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGES.md
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws-cost-calculator-cli
3
- Version: 1.5.2
3
+ Version: 1.9.1
4
4
  Summary: AWS Cost Calculator CLI - Calculate daily and annual AWS costs across multiple accounts
5
- Home-page: https://github.com/yourusername/cost-calculator
5
+ Home-page: https://github.com/trilogy-group/aws-cost-calculator
6
6
  Author: Cost Optimization Team
7
7
  Author-email:
8
- Project-URL: Documentation, https://github.com/yourusername/cost-calculator/blob/main/README.md
8
+ Project-URL: Documentation, https://github.com/trilogy-group/aws-cost-calculator/blob/main/README.md
9
9
  Keywords: aws cost calculator billing optimization cloud
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Intended Audience :: Developers
@@ -43,66 +43,210 @@ A CLI tool to quickly calculate AWS costs across multiple accounts.
43
43
  ## Installation
44
44
 
45
45
  ```bash
46
- cd ~/cost-calculator
47
- pip install -e .
46
+ pip install aws-cost-calculator-cli
47
+ ```
48
+
49
+ Or upgrade to the latest version:
50
+ ```bash
51
+ pip install --upgrade aws-cost-calculator-cli
48
52
  ```
49
53
 
50
54
  ## Quick Start
51
55
 
52
- ### 1. Login to AWS SSO
56
+ ### Authentication Methods
53
57
 
58
+ The CLI supports three authentication methods:
59
+
60
+ #### 1. SSO (Recommended)
54
61
  ```bash
55
- aws sso login --profile my_aws_profile
62
+ # The CLI will automatically trigger SSO login if needed
63
+ cc calculate --profile myprofile --sso my_sso_profile
56
64
  ```
57
65
 
58
- **Note:** You need to do this before running cost calculations. The SSO session typically lasts 8-12 hours.
59
-
60
- ### 2. Initialize a profile
66
+ #### 2. Static Credentials
67
+ ```bash
68
+ cc calculate --profile myprofile \
69
+ --access-key-id ASIA... \
70
+ --secret-access-key ... \
71
+ --session-token ...
72
+ ```
61
73
 
74
+ #### 3. Environment Variables
62
75
  ```bash
63
- cc init --profile myprofile \
64
- --aws-profile my_aws_profile \
65
- --accounts "123456789012,234567890123,345678901234"
76
+ # For SSO
77
+ export AWS_PROFILE=my_sso_profile
78
+ cc calculate --profile myprofile
79
+
80
+ # For static credentials
81
+ export AWS_ACCESS_KEY_ID=ASIA...
82
+ export AWS_SECRET_ACCESS_KEY=...
83
+ export AWS_SESSION_TOKEN=...
84
+ cc calculate --profile myprofile
66
85
  ```
67
86
 
68
- ### 3. Calculate costs
87
+ ### Basic Usage
69
88
 
70
89
  ```bash
71
90
  # Default: Today minus 2 days, going back 30 days
72
- cc calculate --profile myprofile
91
+ cc calculate --profile myprofile --sso my_sso_profile
73
92
 
74
93
  # Specific start date
75
- cc calculate --profile myprofile --start-date 2025-11-04
94
+ cc calculate --profile myprofile --sso my_sso_profile --start-date 2025-11-04
76
95
 
77
96
  # Custom offset and window
78
- cc calculate --profile myprofile --offset 2 --window 30
97
+ cc calculate --profile myprofile --sso my_sso_profile --offset 2 --window 30
79
98
 
80
99
  # JSON output
81
- cc calculate --profile myprofile --json-output
100
+ cc calculate --profile myprofile --sso my_sso_profile --json-output
82
101
  ```
83
102
 
84
103
  ### 4. Analyze cost trends
85
104
 
105
+ All commands support the same authentication options:
106
+
86
107
  ```bash
87
- # Analyze last 3 weeks (default)
108
+ # With SSO
109
+ cc trends --profile myprofile --sso my_sso_profile
110
+
111
+ # With static credentials
112
+ cc trends --profile myprofile --access-key-id ASIA... --secret-access-key ... --session-token ...
113
+
114
+ # With environment variables
115
+ export AWS_PROFILE=my_sso_profile
88
116
  cc trends --profile myprofile
89
117
 
90
118
  # Analyze more weeks
91
- cc trends --profile myprofile --weeks 5
119
+ cc trends --profile myprofile --sso my_sso_profile --weeks 5
92
120
 
93
121
  # Custom output file
94
- cc trends --profile myprofile --output weekly_trends.md
122
+ cc trends --profile myprofile --sso my_sso_profile --output weekly_trends.md
95
123
 
96
124
  # JSON output
97
- cc trends --profile myprofile --json-output
125
+ cc trends --profile myprofile --sso my_sso_profile --json-output
126
+ ```
127
+
128
+ ### 5. Monthly and drill-down analysis
129
+
130
+ ```bash
131
+ # Monthly trends
132
+ cc monthly --profile myprofile --sso my_sso_profile
133
+
134
+ # Drill down by service
135
+ cc drill --profile myprofile --sso my_sso_profile --service "EC2 - Other"
136
+
137
+ # Drill down by account
138
+ cc drill --profile myprofile --sso my_sso_profile --account 123456789012
98
139
  ```
99
140
 
100
- ### 5. List profiles
141
+ ### 6. List profiles
101
142
 
102
143
  ```bash
103
144
  cc list-profiles
104
145
  ```
105
146
 
147
+ ## Authentication
148
+
149
+ ### Overview
150
+
151
+ The CLI supports three authentication methods, all of which work with every command (`calculate`, `trends`, `monthly`, `drill`):
152
+
153
+ ### Method 1: SSO (Recommended)
154
+
155
+ The CLI automatically handles SSO login if your session has expired:
156
+
157
+ ```bash
158
+ cc calculate --profile myprofile --sso my_sso_profile
159
+ ```
160
+
161
+ **How it works:**
162
+ 1. CLI checks if SSO session is valid using `aws sts get-caller-identity`
163
+ 2. If expired, automatically runs `aws sso login --profile my_sso_profile`
164
+ 3. Opens browser for authentication
165
+ 4. Proceeds with cost calculation once authenticated
166
+
167
+ **Benefits:**
168
+ - No manual SSO login required
169
+ - Automatic session refresh
170
+ - Most secure method
171
+ - Works with AWS IAM Identity Center
172
+
173
+ ### Method 2: Static Credentials
174
+
175
+ Pass temporary credentials directly via CLI flags:
176
+
177
+ ```bash
178
+ cc calculate --profile myprofile \
179
+ --access-key-id ASIA... \
180
+ --secret-access-key ... \
181
+ --session-token ...
182
+ ```
183
+
184
+ **Use cases:**
185
+ - CI/CD pipelines
186
+ - Temporary credentials from STS
187
+ - Automated scripts
188
+ - When SSO is not available
189
+
190
+ ### Method 3: Environment Variables
191
+
192
+ Set credentials in your shell environment:
193
+
194
+ ```bash
195
+ # For SSO
196
+ export AWS_PROFILE=my_sso_profile
197
+ cc calculate --profile myprofile
198
+
199
+ # For static credentials
200
+ export AWS_ACCESS_KEY_ID=ASIA...
201
+ export AWS_SECRET_ACCESS_KEY=...
202
+ export AWS_SESSION_TOKEN=...
203
+ cc calculate --profile myprofile
204
+ ```
205
+
206
+ **Benefits:**
207
+ - No need to pass credentials with each command
208
+ - Works with existing AWS CLI configuration
209
+ - Can be set in shell profile (~/.zshrc, ~/.bashrc)
210
+
211
+ ### Profile Configuration
212
+
213
+ Profiles can be stored locally or fetched from a backend API:
214
+
215
+ **Local storage:** `~/.config/cost-calculator/profiles.json`
216
+ ```json
217
+ {
218
+ "myprofile": {
219
+ "accounts": ["123456789012", "234567890123", ...]
220
+ }
221
+ }
222
+ ```
223
+
224
+ **Backend API:** Set `COST_API_SECRET` environment variable
225
+
226
+ Quick setup (saves to shell profile):
227
+ ```bash
228
+ cc setup-api
229
+ # Enter your API secret when prompted (input will be hidden)
230
+ ```
231
+
232
+ **CUR Configuration (for --resources flag):**
233
+
234
+ To use resource-level queries, configure CUR settings:
235
+ ```bash
236
+ cc setup-cur
237
+ # Enter: Database name, table name, S3 output location
238
+ ```
239
+
240
+ This saves configuration to `~/.config/cost-calculator/cur_config.json`
241
+
242
+ Or set manually:
243
+ ```bash
244
+ export COST_API_SECRET="your-api-secret"
245
+ cc calculate --profile myprofile --sso my_sso_profile
246
+ ```
247
+
248
+ The CLI will automatically fetch profile configuration from the backend if `COST_API_SECRET` is set.
249
+
106
250
  ## How It Works
107
251
 
108
252
  ### Date Calculation
@@ -240,11 +384,13 @@ The `drill` command allows you to investigate cost changes at different levels o
240
384
  1. **Start broad:** `cc trends` → See EC2 costs up $1000
241
385
  2. **Drill by service:** `cc drill --service "EC2 - Other"` → See which accounts
242
386
  3. **Drill deeper:** `cc drill --service "EC2 - Other" --account 123` → See usage types
387
+ 4. **Resource-level:** `cc drill --service "EC2 - Other" --account 123 --resources` → See individual instance IDs
243
388
 
244
389
  **Features:**
245
390
  - **Week-over-week cost analysis**: Compare costs between consecutive weeks
246
391
  - **Month-over-month cost analysis**: Compare costs between consecutive months
247
392
  - **Drill-down analysis**: Analyze costs by service, account, or usage type
393
+ - **Resource-level analysis**: See individual resource IDs and costs using CUR data (NEW in v1.7.0)
248
394
  - **Pandas aggregations**: Time series analysis with sum, avg, std across all weeks
249
395
  - **Volatility detection**: Identify services with high cost variability and outliers
250
396
  - **Trend detection**: Auto-detect increasing/decreasing cost patterns
@@ -262,7 +408,7 @@ cc drill --profile myprofile --service "EC2 - Other"
262
408
  Showing top accounts:
263
409
  Week of Oct 19 → Week of Oct 26
264
410
  Increases: 3, Decreases: 2
265
- Top: 887649220066 (+$450.23)
411
+ Top: 123456789012 (+$450.23)
266
412
  ```
267
413
 
268
414
  The report is saved to `drill_down.md` by default.