devops-aws-costlens 1.0.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.
- devops_aws_costlens-1.0.1/.gitignore +117 -0
- devops_aws_costlens-1.0.1/LICENSE +21 -0
- devops_aws_costlens-1.0.1/PKG-INFO +307 -0
- devops_aws_costlens-1.0.1/README.md +282 -0
- devops_aws_costlens-1.0.1/aws_costlens/__init__.py +3 -0
- devops_aws_costlens-1.0.1/aws_costlens/app_controller.py +344 -0
- devops_aws_costlens-1.0.1/aws_costlens/aws_api.py +304 -0
- devops_aws_costlens-1.0.1/aws_costlens/cli_commands.py +252 -0
- devops_aws_costlens-1.0.1/aws_costlens/common_utils.py +309 -0
- devops_aws_costlens-1.0.1/aws_costlens/cost_controller.py +257 -0
- devops_aws_costlens-1.0.1/aws_costlens/main.py +6 -0
- devops_aws_costlens-1.0.1/aws_costlens/models.py +69 -0
- devops_aws_costlens-1.0.1/aws_costlens/pdf_renderer.py +71 -0
- devops_aws_costlens-1.0.1/aws_costlens/profiles_controller.py +202 -0
- devops_aws_costlens-1.0.1/aws_costlens/report_exporter.py +143 -0
- devops_aws_costlens-1.0.1/aws_costlens/visuals.py +38 -0
- devops_aws_costlens-1.0.1/pyproject.toml +76 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# AWS CostLens - .gitignore
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Environments
|
|
58
|
+
.env
|
|
59
|
+
.env.*
|
|
60
|
+
!.env.example
|
|
61
|
+
.venv
|
|
62
|
+
env/
|
|
63
|
+
venv/
|
|
64
|
+
ENV/
|
|
65
|
+
env.bak/
|
|
66
|
+
venv.bak/
|
|
67
|
+
|
|
68
|
+
# IDE / Editor
|
|
69
|
+
.vscode/
|
|
70
|
+
.idea/
|
|
71
|
+
*.swp
|
|
72
|
+
*.swo
|
|
73
|
+
*~
|
|
74
|
+
.project
|
|
75
|
+
.pydevproject
|
|
76
|
+
.settings/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# pyenv
|
|
82
|
+
.python-version
|
|
83
|
+
|
|
84
|
+
# mypy
|
|
85
|
+
.mypy_cache/
|
|
86
|
+
.dmypy.json
|
|
87
|
+
dmypy.json
|
|
88
|
+
|
|
89
|
+
# Pyre type checker
|
|
90
|
+
.pyre/
|
|
91
|
+
|
|
92
|
+
# Output files generated by aws-costlens
|
|
93
|
+
output/
|
|
94
|
+
reports/
|
|
95
|
+
*.pdf
|
|
96
|
+
*.csv
|
|
97
|
+
!requirements*.txt
|
|
98
|
+
|
|
99
|
+
# AWS credentials (NEVER commit these)
|
|
100
|
+
.aws/
|
|
101
|
+
credentials
|
|
102
|
+
config
|
|
103
|
+
|
|
104
|
+
# OS files
|
|
105
|
+
.DS_Store
|
|
106
|
+
Thumbs.db
|
|
107
|
+
Desktop.ini
|
|
108
|
+
|
|
109
|
+
# Logs
|
|
110
|
+
*.log
|
|
111
|
+
logs/
|
|
112
|
+
|
|
113
|
+
# Temporary files
|
|
114
|
+
*.tmp
|
|
115
|
+
*.temp
|
|
116
|
+
.tmp/
|
|
117
|
+
.temp/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ernesto Calzadilla Martínez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devops-aws-costlens
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: AWS Cost Intelligence Tool - Terminal-based cost and resource dashboard.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Calza36/aws-costlens
|
|
6
|
+
Project-URL: Source, https://github.com/Calza36/aws-costlens
|
|
7
|
+
Author: Ernesto Calzadilla Martínez
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: aws,cli,cloud,cost,costlens,dashboard,finops
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Requires-Dist: boto3>=1.37.28
|
|
13
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
14
|
+
Requires-Dist: reportlab>=3.6.1
|
|
15
|
+
Requires-Dist: rich>=14.0.0
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: hatch>=1.9.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: mypy>=1.5.1; extra == 'dev'
|
|
21
|
+
Requires-Dist: types-boto3; extra == 'dev'
|
|
22
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
23
|
+
Requires-Dist: types-reportlab; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# AWS CostLens
|
|
27
|
+
|
|
28
|
+
**AWS Cost Intelligence Tool** - Terminal-based dashboard for AWS cost monitoring and resource scanning.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
╔═══════════════════════════════════════════════╗
|
|
32
|
+
║ AWS CostLens - Cost Intelligence Tool ║
|
|
33
|
+
╚═══════════════════════════════════════════════╝
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- 💵 **Cost Dashboard** - View current and previous period costs by service
|
|
39
|
+
- 📈 **Cost History** - 6-month cost trend visualization with ASCII charts
|
|
40
|
+
- 🔍 **Resource Scan** - Find stopped instances, unused volumes, unattached EIPs, untagged resources
|
|
41
|
+
- 📄 **Export Reports** - PDF, CSV, JSON formats
|
|
42
|
+
- ☁️ **S3 Upload** - Automatically upload reports to S3
|
|
43
|
+
- 🔧 **Multi-Profile** - Support for multiple AWS CLI profiles
|
|
44
|
+
- 📋 **YAML Config** - Configuration file support
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
### From PyPI (Recommended)
|
|
49
|
+
|
|
50
|
+
Install from PyPI using `pip`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install devops-aws-costlens
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or using `pipx` for isolated installation:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pipx install devops-aws-costlens
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
After installation, the command is:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
aws-costlens --help
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### From Source
|
|
69
|
+
|
|
70
|
+
If you want to install from source or contribute:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Clone the repository
|
|
74
|
+
git clone https://github.com/Calza36/aws-costlens.git
|
|
75
|
+
cd aws-costlens
|
|
76
|
+
|
|
77
|
+
# Install in development mode
|
|
78
|
+
pip install -e .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Using Docker
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Build the image
|
|
85
|
+
docker build -t aws-costlens .
|
|
86
|
+
|
|
87
|
+
# Run with AWS credentials mounted
|
|
88
|
+
docker run -v ~/.aws:/root/.aws:ro aws-costlens cost --profiles default
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Start
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Cost dashboard for default profile
|
|
95
|
+
aws-costlens cost
|
|
96
|
+
|
|
97
|
+
# Cost dashboard for specific profiles
|
|
98
|
+
aws-costlens cost --profiles dev prod
|
|
99
|
+
|
|
100
|
+
# All profiles merged
|
|
101
|
+
aws-costlens cost --all-profiles --merge
|
|
102
|
+
|
|
103
|
+
# 6-month cost history
|
|
104
|
+
aws-costlens history --profiles prod
|
|
105
|
+
|
|
106
|
+
# Resource scan
|
|
107
|
+
aws-costlens scan --profiles prod
|
|
108
|
+
|
|
109
|
+
# Generate PDF report
|
|
110
|
+
aws-costlens export --profiles prod --format pdf
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Commands
|
|
114
|
+
|
|
115
|
+
### `cost` - Cost Dashboard
|
|
116
|
+
|
|
117
|
+
Display cost information for AWS accounts.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
aws-costlens cost [options]
|
|
121
|
+
|
|
122
|
+
Options:
|
|
123
|
+
--profiles, -p AWS CLI profile names
|
|
124
|
+
--regions, -r AWS regions to check
|
|
125
|
+
--all-profiles, -a Process all available profiles
|
|
126
|
+
--merge Merge results from multiple profiles of the same account
|
|
127
|
+
--time-range, -t Time range (days or YYYY-MM-DD:YYYY-MM-DD)
|
|
128
|
+
--tag Filter by tag (key=value)
|
|
129
|
+
--config, -c Path to YAML config file
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `history` - Cost History
|
|
133
|
+
|
|
134
|
+
Display 6-month cost history with ASCII visualization.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
aws-costlens history [options]
|
|
138
|
+
|
|
139
|
+
Options:
|
|
140
|
+
--profiles, -p AWS CLI profile names
|
|
141
|
+
--all-profiles, -a Process all available profiles
|
|
142
|
+
--config, -c Path to YAML config file
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `scan` - Resource Scan
|
|
146
|
+
|
|
147
|
+
Find unused and untagged resources.
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
aws-costlens scan [options]
|
|
151
|
+
|
|
152
|
+
Options:
|
|
153
|
+
--profiles, -p AWS CLI profile names
|
|
154
|
+
--regions, -r AWS regions to check
|
|
155
|
+
--all-profiles, -a Process all available profiles
|
|
156
|
+
--config, -c Path to YAML config file
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Scan checks:
|
|
160
|
+
- ⏹️ Stopped EC2 instances
|
|
161
|
+
- 💾 Unused EBS volumes
|
|
162
|
+
- 🌐 Unattached Elastic IPs
|
|
163
|
+
- 🏷️ Untagged resources (EC2, RDS, Lambda, ELBv2)
|
|
164
|
+
|
|
165
|
+
### `export` - Generate Reports
|
|
166
|
+
|
|
167
|
+
Generate and export reports in various formats.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
aws-costlens export [options]
|
|
171
|
+
|
|
172
|
+
Options:
|
|
173
|
+
--profiles, -p AWS CLI profile names
|
|
174
|
+
--all-profiles, -a Process all available profiles
|
|
175
|
+
--merge Merge results from multiple profiles
|
|
176
|
+
--name, -n Base name for report files
|
|
177
|
+
--format, -f Export formats: pdf, csv, json
|
|
178
|
+
--dir, -d Output directory
|
|
179
|
+
--bucket S3 bucket for uploads
|
|
180
|
+
--s3-path S3 path/prefix for reports
|
|
181
|
+
--scan Include resource scan report
|
|
182
|
+
--history Include cost history report
|
|
183
|
+
--config, -c Path to YAML config file
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Configuration File
|
|
187
|
+
|
|
188
|
+
Create a YAML config file for reusable settings. See `config.example.yaml` for a complete example.
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# costlens.yaml
|
|
192
|
+
profiles:
|
|
193
|
+
- dev
|
|
194
|
+
- staging
|
|
195
|
+
- prod
|
|
196
|
+
|
|
197
|
+
regions:
|
|
198
|
+
- us-east-1
|
|
199
|
+
- eu-west-1
|
|
200
|
+
|
|
201
|
+
name: monthly_cost_report
|
|
202
|
+
format:
|
|
203
|
+
- pdf
|
|
204
|
+
- csv
|
|
205
|
+
|
|
206
|
+
bucket: my-reports-bucket
|
|
207
|
+
s3_path: costlens/monthly
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Use with:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
aws-costlens cost --config costlens.yaml
|
|
214
|
+
aws-costlens export --config costlens.yaml
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Docker Compose
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Run cost dashboard
|
|
221
|
+
docker compose run costlens cost --profiles prod
|
|
222
|
+
|
|
223
|
+
# Run scan
|
|
224
|
+
docker compose run costlens scan --all-profiles
|
|
225
|
+
|
|
226
|
+
# Generate reports
|
|
227
|
+
docker compose run costlens export --all-profiles --format pdf csv
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## AWS Permissions Required
|
|
231
|
+
|
|
232
|
+
The following AWS permissions are required:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"Version": "2012-10-17",
|
|
237
|
+
"Statement": [
|
|
238
|
+
{
|
|
239
|
+
"Effect": "Allow",
|
|
240
|
+
"Action": [
|
|
241
|
+
"ce:GetCostAndUsage",
|
|
242
|
+
"budgets:DescribeBudgets",
|
|
243
|
+
"ec2:DescribeInstances",
|
|
244
|
+
"ec2:DescribeVolumes",
|
|
245
|
+
"ec2:DescribeAddresses",
|
|
246
|
+
"ec2:DescribeRegions",
|
|
247
|
+
"rds:DescribeDBInstances",
|
|
248
|
+
"rds:ListTagsForResource",
|
|
249
|
+
"lambda:ListFunctions",
|
|
250
|
+
"lambda:ListTags",
|
|
251
|
+
"elasticloadbalancing:DescribeLoadBalancers",
|
|
252
|
+
"elasticloadbalancing:DescribeTags",
|
|
253
|
+
"sts:GetCallerIdentity",
|
|
254
|
+
"s3:PutObject"
|
|
255
|
+
],
|
|
256
|
+
"Resource": "*"
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Examples
|
|
263
|
+
|
|
264
|
+
### Monthly Cost Report for All Profiles
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
aws-costlens export --all-profiles --merge --format pdf csv json \
|
|
268
|
+
--name monthly_$(date +%Y%m) \
|
|
269
|
+
--dir ./reports
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Scan with S3 Upload
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
aws-costlens export --profiles prod --scan \
|
|
276
|
+
--format pdf \
|
|
277
|
+
--bucket my-audit-bucket \
|
|
278
|
+
--s3-path scans/$(date +%Y/%m)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Filter Costs by Tag
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
aws-costlens cost --profiles prod --tag Environment=production --tag Project=web
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Custom Time Range
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Last 7 days
|
|
291
|
+
aws-costlens cost --profiles prod --time-range 7
|
|
292
|
+
|
|
293
|
+
# Specific date range
|
|
294
|
+
aws-costlens cost --profiles prod --time-range 2025-01-01:2025-01-31
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## License
|
|
298
|
+
|
|
299
|
+
MIT License - See [LICENSE](LICENSE) file.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
**Author:** Ernesto Calzadilla Martínez
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
*Inspired by aws-finops-dashboard*
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# AWS CostLens
|
|
2
|
+
|
|
3
|
+
**AWS Cost Intelligence Tool** - Terminal-based dashboard for AWS cost monitoring and resource scanning.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
╔═══════════════════════════════════════════════╗
|
|
7
|
+
║ AWS CostLens - Cost Intelligence Tool ║
|
|
8
|
+
╚═══════════════════════════════════════════════╝
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 💵 **Cost Dashboard** - View current and previous period costs by service
|
|
14
|
+
- 📈 **Cost History** - 6-month cost trend visualization with ASCII charts
|
|
15
|
+
- 🔍 **Resource Scan** - Find stopped instances, unused volumes, unattached EIPs, untagged resources
|
|
16
|
+
- 📄 **Export Reports** - PDF, CSV, JSON formats
|
|
17
|
+
- ☁️ **S3 Upload** - Automatically upload reports to S3
|
|
18
|
+
- 🔧 **Multi-Profile** - Support for multiple AWS CLI profiles
|
|
19
|
+
- 📋 **YAML Config** - Configuration file support
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### From PyPI (Recommended)
|
|
24
|
+
|
|
25
|
+
Install from PyPI using `pip`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install devops-aws-costlens
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or using `pipx` for isolated installation:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pipx install devops-aws-costlens
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
After installation, the command is:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
aws-costlens --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### From Source
|
|
44
|
+
|
|
45
|
+
If you want to install from source or contribute:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Clone the repository
|
|
49
|
+
git clone https://github.com/Calza36/aws-costlens.git
|
|
50
|
+
cd aws-costlens
|
|
51
|
+
|
|
52
|
+
# Install in development mode
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using Docker
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Build the image
|
|
60
|
+
docker build -t aws-costlens .
|
|
61
|
+
|
|
62
|
+
# Run with AWS credentials mounted
|
|
63
|
+
docker run -v ~/.aws:/root/.aws:ro aws-costlens cost --profiles default
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Cost dashboard for default profile
|
|
70
|
+
aws-costlens cost
|
|
71
|
+
|
|
72
|
+
# Cost dashboard for specific profiles
|
|
73
|
+
aws-costlens cost --profiles dev prod
|
|
74
|
+
|
|
75
|
+
# All profiles merged
|
|
76
|
+
aws-costlens cost --all-profiles --merge
|
|
77
|
+
|
|
78
|
+
# 6-month cost history
|
|
79
|
+
aws-costlens history --profiles prod
|
|
80
|
+
|
|
81
|
+
# Resource scan
|
|
82
|
+
aws-costlens scan --profiles prod
|
|
83
|
+
|
|
84
|
+
# Generate PDF report
|
|
85
|
+
aws-costlens export --profiles prod --format pdf
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
### `cost` - Cost Dashboard
|
|
91
|
+
|
|
92
|
+
Display cost information for AWS accounts.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
aws-costlens cost [options]
|
|
96
|
+
|
|
97
|
+
Options:
|
|
98
|
+
--profiles, -p AWS CLI profile names
|
|
99
|
+
--regions, -r AWS regions to check
|
|
100
|
+
--all-profiles, -a Process all available profiles
|
|
101
|
+
--merge Merge results from multiple profiles of the same account
|
|
102
|
+
--time-range, -t Time range (days or YYYY-MM-DD:YYYY-MM-DD)
|
|
103
|
+
--tag Filter by tag (key=value)
|
|
104
|
+
--config, -c Path to YAML config file
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `history` - Cost History
|
|
108
|
+
|
|
109
|
+
Display 6-month cost history with ASCII visualization.
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
aws-costlens history [options]
|
|
113
|
+
|
|
114
|
+
Options:
|
|
115
|
+
--profiles, -p AWS CLI profile names
|
|
116
|
+
--all-profiles, -a Process all available profiles
|
|
117
|
+
--config, -c Path to YAML config file
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### `scan` - Resource Scan
|
|
121
|
+
|
|
122
|
+
Find unused and untagged resources.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
aws-costlens scan [options]
|
|
126
|
+
|
|
127
|
+
Options:
|
|
128
|
+
--profiles, -p AWS CLI profile names
|
|
129
|
+
--regions, -r AWS regions to check
|
|
130
|
+
--all-profiles, -a Process all available profiles
|
|
131
|
+
--config, -c Path to YAML config file
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Scan checks:
|
|
135
|
+
- ⏹️ Stopped EC2 instances
|
|
136
|
+
- 💾 Unused EBS volumes
|
|
137
|
+
- 🌐 Unattached Elastic IPs
|
|
138
|
+
- 🏷️ Untagged resources (EC2, RDS, Lambda, ELBv2)
|
|
139
|
+
|
|
140
|
+
### `export` - Generate Reports
|
|
141
|
+
|
|
142
|
+
Generate and export reports in various formats.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
aws-costlens export [options]
|
|
146
|
+
|
|
147
|
+
Options:
|
|
148
|
+
--profiles, -p AWS CLI profile names
|
|
149
|
+
--all-profiles, -a Process all available profiles
|
|
150
|
+
--merge Merge results from multiple profiles
|
|
151
|
+
--name, -n Base name for report files
|
|
152
|
+
--format, -f Export formats: pdf, csv, json
|
|
153
|
+
--dir, -d Output directory
|
|
154
|
+
--bucket S3 bucket for uploads
|
|
155
|
+
--s3-path S3 path/prefix for reports
|
|
156
|
+
--scan Include resource scan report
|
|
157
|
+
--history Include cost history report
|
|
158
|
+
--config, -c Path to YAML config file
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Configuration File
|
|
162
|
+
|
|
163
|
+
Create a YAML config file for reusable settings. See `config.example.yaml` for a complete example.
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
# costlens.yaml
|
|
167
|
+
profiles:
|
|
168
|
+
- dev
|
|
169
|
+
- staging
|
|
170
|
+
- prod
|
|
171
|
+
|
|
172
|
+
regions:
|
|
173
|
+
- us-east-1
|
|
174
|
+
- eu-west-1
|
|
175
|
+
|
|
176
|
+
name: monthly_cost_report
|
|
177
|
+
format:
|
|
178
|
+
- pdf
|
|
179
|
+
- csv
|
|
180
|
+
|
|
181
|
+
bucket: my-reports-bucket
|
|
182
|
+
s3_path: costlens/monthly
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Use with:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
aws-costlens cost --config costlens.yaml
|
|
189
|
+
aws-costlens export --config costlens.yaml
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Docker Compose
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Run cost dashboard
|
|
196
|
+
docker compose run costlens cost --profiles prod
|
|
197
|
+
|
|
198
|
+
# Run scan
|
|
199
|
+
docker compose run costlens scan --all-profiles
|
|
200
|
+
|
|
201
|
+
# Generate reports
|
|
202
|
+
docker compose run costlens export --all-profiles --format pdf csv
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## AWS Permissions Required
|
|
206
|
+
|
|
207
|
+
The following AWS permissions are required:
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"Version": "2012-10-17",
|
|
212
|
+
"Statement": [
|
|
213
|
+
{
|
|
214
|
+
"Effect": "Allow",
|
|
215
|
+
"Action": [
|
|
216
|
+
"ce:GetCostAndUsage",
|
|
217
|
+
"budgets:DescribeBudgets",
|
|
218
|
+
"ec2:DescribeInstances",
|
|
219
|
+
"ec2:DescribeVolumes",
|
|
220
|
+
"ec2:DescribeAddresses",
|
|
221
|
+
"ec2:DescribeRegions",
|
|
222
|
+
"rds:DescribeDBInstances",
|
|
223
|
+
"rds:ListTagsForResource",
|
|
224
|
+
"lambda:ListFunctions",
|
|
225
|
+
"lambda:ListTags",
|
|
226
|
+
"elasticloadbalancing:DescribeLoadBalancers",
|
|
227
|
+
"elasticloadbalancing:DescribeTags",
|
|
228
|
+
"sts:GetCallerIdentity",
|
|
229
|
+
"s3:PutObject"
|
|
230
|
+
],
|
|
231
|
+
"Resource": "*"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Examples
|
|
238
|
+
|
|
239
|
+
### Monthly Cost Report for All Profiles
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
aws-costlens export --all-profiles --merge --format pdf csv json \
|
|
243
|
+
--name monthly_$(date +%Y%m) \
|
|
244
|
+
--dir ./reports
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Scan with S3 Upload
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
aws-costlens export --profiles prod --scan \
|
|
251
|
+
--format pdf \
|
|
252
|
+
--bucket my-audit-bucket \
|
|
253
|
+
--s3-path scans/$(date +%Y/%m)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Filter Costs by Tag
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
aws-costlens cost --profiles prod --tag Environment=production --tag Project=web
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Custom Time Range
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Last 7 days
|
|
266
|
+
aws-costlens cost --profiles prod --time-range 7
|
|
267
|
+
|
|
268
|
+
# Specific date range
|
|
269
|
+
aws-costlens cost --profiles prod --time-range 2025-01-01:2025-01-31
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT License - See [LICENSE](LICENSE) file.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
**Author:** Ernesto Calzadilla Martínez
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
*Inspired by aws-finops-dashboard*
|