infra-cost 0.1.0 → 0.2.0
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.
- package/README.md +362 -0
- package/dist/demo/test-enhanced-ui.js +1662 -0
- package/dist/demo/test-multi-cloud-dashboard.js +3370 -0
- package/dist/index.js +18866 -242
- package/package.json +94 -19
package/README.md
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# infra-cost
|
|
2
|
+
|
|
3
|
+
> Multi-cloud CLI tool for cost analysis across AWS, Google Cloud, Azure, Alibaba Cloud, and Oracle Cloud with Slack integration
|
|
4
|
+
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **Multi-cloud support**: AWS, Google Cloud (GCP), Microsoft Azure, Alibaba Cloud, Oracle Cloud
|
|
8
|
+
- **Enhanced Slack integration**: Detailed cost breakdowns with service-level insights
|
|
9
|
+
- **Flexible authentication**: Environment variables, IAM roles, profiles, and explicit credentials
|
|
10
|
+
- **Multiple output formats**: Fancy tables, plain text, JSON
|
|
11
|
+
- **Automated publishing**: npm and Homebrew with CI/CD pipelines
|
|
12
|
+
- **Modern AWS SDK v3**: Enhanced performance and security
|
|
13
|
+
|
|
14
|
+
## 📦 Installation
|
|
15
|
+
|
|
16
|
+
### npm (Recommended)
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g infra-cost
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Homebrew
|
|
22
|
+
```bash
|
|
23
|
+
brew install codecollab-co/tap/infra-cost
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### npx (No installation required)
|
|
27
|
+
```bash
|
|
28
|
+
npx infra-cost
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 🎯 Quick Start
|
|
32
|
+
|
|
33
|
+
### AWS (Default Provider)
|
|
34
|
+
```bash
|
|
35
|
+
# Using default AWS credentials
|
|
36
|
+
infra-cost
|
|
37
|
+
|
|
38
|
+
# Using specific credentials
|
|
39
|
+
infra-cost --access-key YOUR_KEY --secret-key YOUR_SECRET --region us-east-1
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Multi-Cloud Usage
|
|
43
|
+
```bash
|
|
44
|
+
# Google Cloud Platform
|
|
45
|
+
infra-cost --provider gcp --project-id my-project --key-file /path/to/service-account.json
|
|
46
|
+
|
|
47
|
+
# Microsoft Azure
|
|
48
|
+
infra-cost --provider azure --subscription-id sub-id --tenant-id tenant-id --client-id client-id --client-secret secret
|
|
49
|
+
|
|
50
|
+
# Alibaba Cloud
|
|
51
|
+
infra-cost --provider alicloud --access-key key --secret-key secret --region cn-hangzhou
|
|
52
|
+
|
|
53
|
+
# Oracle Cloud Infrastructure
|
|
54
|
+
infra-cost --provider oracle --user-id user-ocid --tenancy-id tenancy-ocid --fingerprint fingerprint --key-file /path/to/private-key
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🔧 Usage
|
|
58
|
+
|
|
59
|
+
### Command Line Options
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
infra-cost [options]
|
|
63
|
+
|
|
64
|
+
Cloud Provider Options:
|
|
65
|
+
--provider [provider] Cloud provider (aws, gcp, azure, alicloud, oracle) (default: "aws")
|
|
66
|
+
-p, --profile [profile] Cloud provider profile to use (default: "default")
|
|
67
|
+
-r, --region [region] Cloud provider region (default: "us-east-1")
|
|
68
|
+
|
|
69
|
+
AWS/Generic Credentials:
|
|
70
|
+
-k, --access-key [key] Access key (AWS Access Key, etc.)
|
|
71
|
+
-s, --secret-key [key] Secret key (AWS Secret Key, etc.)
|
|
72
|
+
-T, --session-token [key] Session token (AWS Session Token, etc.)
|
|
73
|
+
|
|
74
|
+
Google Cloud Options:
|
|
75
|
+
--project-id [id] GCP Project ID
|
|
76
|
+
--key-file [path] Path to service account JSON file
|
|
77
|
+
|
|
78
|
+
Azure Options:
|
|
79
|
+
--subscription-id [id] Azure Subscription ID
|
|
80
|
+
--tenant-id [id] Azure Tenant ID
|
|
81
|
+
--client-id [id] Azure Client ID
|
|
82
|
+
--client-secret [secret] Azure Client Secret
|
|
83
|
+
|
|
84
|
+
Alibaba Cloud Options:
|
|
85
|
+
(Uses --access-key and --secret-key)
|
|
86
|
+
|
|
87
|
+
Oracle Cloud Options:
|
|
88
|
+
--user-id [id] Oracle User OCID
|
|
89
|
+
--tenancy-id [id] Oracle Tenancy OCID
|
|
90
|
+
--fingerprint [fingerprint] Oracle Public Key Fingerprint
|
|
91
|
+
--key-file [path] Path to private key file
|
|
92
|
+
|
|
93
|
+
Output Options:
|
|
94
|
+
-j, --json Get the output as JSON
|
|
95
|
+
-u, --summary Get only the summary without service breakdown
|
|
96
|
+
-t, --text Get the output as plain text (no colors/tables)
|
|
97
|
+
|
|
98
|
+
Slack Integration:
|
|
99
|
+
-S, --slack-token [token] Token for the slack integration
|
|
100
|
+
-C, --slack-channel [channel] Channel to which the slack integration should post
|
|
101
|
+
|
|
102
|
+
Other Options:
|
|
103
|
+
-V, --version output the version number
|
|
104
|
+
-h, --help display help for command
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 🔐 Authentication
|
|
108
|
+
|
|
109
|
+
### AWS Authentication (Multiple Methods Supported)
|
|
110
|
+
|
|
111
|
+
#### 1. Environment Variables
|
|
112
|
+
```bash
|
|
113
|
+
export AWS_ACCESS_KEY_ID=your_access_key
|
|
114
|
+
export AWS_SECRET_ACCESS_KEY=your_secret_key
|
|
115
|
+
export AWS_REGION=us-east-1
|
|
116
|
+
infra-cost
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### 2. AWS Profiles
|
|
120
|
+
```bash
|
|
121
|
+
# Use default profile
|
|
122
|
+
infra-cost
|
|
123
|
+
|
|
124
|
+
# Use specific profile
|
|
125
|
+
infra-cost --profile production
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### 3. IAM Roles (EC2/Lambda/ECS)
|
|
129
|
+
When running on AWS infrastructure, the CLI automatically uses IAM roles:
|
|
130
|
+
```bash
|
|
131
|
+
infra-cost # Automatically uses attached IAM role
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### 4. AWS SSO
|
|
135
|
+
```bash
|
|
136
|
+
aws sso login --profile my-sso-profile
|
|
137
|
+
infra-cost --profile my-sso-profile
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### 5. Explicit Credentials
|
|
141
|
+
```bash
|
|
142
|
+
infra-cost --access-key KEY --secret-key SECRET --region us-east-1
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Other Cloud Providers
|
|
146
|
+
|
|
147
|
+
**Note**: Multi-cloud providers (GCP, Azure, Alibaba Cloud, Oracle Cloud) are currently in development. The architecture is ready, but API integrations are not yet implemented. Use AWS for full functionality.
|
|
148
|
+
|
|
149
|
+
## 📊 Output Formats
|
|
150
|
+
|
|
151
|
+
### 1. Default Fancy Output
|
|
152
|
+
```bash
|
|
153
|
+
infra-cost
|
|
154
|
+
```
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
### 2. Summary Only
|
|
158
|
+
```bash
|
|
159
|
+
infra-cost --summary
|
|
160
|
+
```
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
### 3. Plain Text
|
|
164
|
+
```bash
|
|
165
|
+
infra-cost --text
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 4. JSON Output
|
|
169
|
+
```bash
|
|
170
|
+
infra-cost --json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 💬 Slack Integration
|
|
174
|
+
|
|
175
|
+
### Enhanced Slack Features
|
|
176
|
+
- **Comprehensive cost breakdown** for all time periods
|
|
177
|
+
- **Service-level details** including Last 7 Days data
|
|
178
|
+
- **Rich formatting** with blocks and sections
|
|
179
|
+
- **Automated workflows** support
|
|
180
|
+
|
|
181
|
+
### Setup
|
|
182
|
+
1. Create a [Slack app](https://api.slack.com/apps?new_app=1)
|
|
183
|
+
2. Add `chat:write` and `chat:write.public` scopes
|
|
184
|
+
3. Get your OAuth token and channel ID
|
|
185
|
+
|
|
186
|
+
### Usage
|
|
187
|
+
```bash
|
|
188
|
+
infra-cost --slack-token xoxb-your-token --slack-channel C1234567890
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Automated Daily Reports
|
|
192
|
+
Set up a GitHub workflow to send daily cost reports:
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
name: Daily AWS Costs
|
|
196
|
+
on:
|
|
197
|
+
schedule:
|
|
198
|
+
- cron: '0 9 * * *' # 9 AM UTC daily
|
|
199
|
+
jobs:
|
|
200
|
+
costs:
|
|
201
|
+
runs-on: ubuntu-latest
|
|
202
|
+
steps:
|
|
203
|
+
- uses: actions/checkout@v4
|
|
204
|
+
- run: |
|
|
205
|
+
npx infra-cost \
|
|
206
|
+
--slack-token ${{ secrets.SLACK_TOKEN }} \
|
|
207
|
+
--slack-channel ${{ secrets.SLACK_CHANNEL }}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 🏗️ Development & Publishing
|
|
211
|
+
|
|
212
|
+
### npm Publishing
|
|
213
|
+
This project includes automated npm publishing with semantic versioning:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Check version status
|
|
217
|
+
npm run version:check
|
|
218
|
+
|
|
219
|
+
# Bump version
|
|
220
|
+
npm run version:bump:patch
|
|
221
|
+
npm run version:bump:minor
|
|
222
|
+
npm run version:bump:major
|
|
223
|
+
|
|
224
|
+
# Dry run publish
|
|
225
|
+
npm run publish:dry
|
|
226
|
+
|
|
227
|
+
# Manual publish
|
|
228
|
+
npm run publish:latest
|
|
229
|
+
npm run publish:beta
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Homebrew Publishing
|
|
233
|
+
Automated Homebrew formula updates via GitHub Actions:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Prepare release (interactive)
|
|
237
|
+
npm run prepare-release
|
|
238
|
+
|
|
239
|
+
# This will:
|
|
240
|
+
# 1. Update version in package.json
|
|
241
|
+
# 2. Update Homebrew formula
|
|
242
|
+
# 3. Run tests and build
|
|
243
|
+
# 4. Create git tag
|
|
244
|
+
# 5. Trigger release workflow
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## 🔧 Development
|
|
248
|
+
|
|
249
|
+
### Build
|
|
250
|
+
```bash
|
|
251
|
+
npm run build
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Type Checking
|
|
255
|
+
```bash
|
|
256
|
+
npm run typecheck
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Version Management
|
|
260
|
+
```bash
|
|
261
|
+
npm run version:check # Check current version status
|
|
262
|
+
npm run version:next # Get next version
|
|
263
|
+
npm run version:set # Set specific version
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## 📋 Requirements & Permissions
|
|
267
|
+
|
|
268
|
+
### AWS Permissions Required
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"Version": "2012-10-17",
|
|
272
|
+
"Statement": [
|
|
273
|
+
{
|
|
274
|
+
"Sid": "InfraCostPermissions",
|
|
275
|
+
"Effect": "Allow",
|
|
276
|
+
"Action": [
|
|
277
|
+
"iam:ListAccountAliases",
|
|
278
|
+
"ce:GetCostAndUsage",
|
|
279
|
+
"sts:GetCallerIdentity"
|
|
280
|
+
],
|
|
281
|
+
"Resource": "*"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Cost Considerations
|
|
288
|
+
- **AWS Cost Explorer**: $0.01 per request
|
|
289
|
+
- **Other providers**: Varies by provider's pricing model
|
|
290
|
+
|
|
291
|
+
## 🏗️ Architecture
|
|
292
|
+
|
|
293
|
+
### Multi-Cloud Provider Pattern
|
|
294
|
+
```
|
|
295
|
+
src/
|
|
296
|
+
├── providers/
|
|
297
|
+
│ ├── factory.ts # Provider factory
|
|
298
|
+
│ ├── aws.ts # AWS implementation ✅
|
|
299
|
+
│ ├── gcp.ts # Google Cloud (placeholder)
|
|
300
|
+
│ ├── azure.ts # Azure (placeholder)
|
|
301
|
+
│ ├── alicloud.ts # Alibaba Cloud (placeholder)
|
|
302
|
+
│ └── oracle.ts # Oracle Cloud (placeholder)
|
|
303
|
+
├── types/
|
|
304
|
+
│ └── providers.ts # Common interfaces
|
|
305
|
+
└── ...
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Key Features
|
|
309
|
+
- **Abstract provider interface** for consistent API
|
|
310
|
+
- **Factory pattern** for provider instantiation
|
|
311
|
+
- **Extensible architecture** for adding new cloud providers
|
|
312
|
+
- **Type-safe implementation** with TypeScript
|
|
313
|
+
|
|
314
|
+
## 🚀 CI/CD Pipelines
|
|
315
|
+
|
|
316
|
+
### Automated Workflows
|
|
317
|
+
- **npm publishing** with semantic versioning
|
|
318
|
+
- **Homebrew formula updates**
|
|
319
|
+
- **Release automation** with GitHub Actions
|
|
320
|
+
- **Multi-platform testing** (Node.js 16, 18, 20)
|
|
321
|
+
|
|
322
|
+
### Quality Assurance
|
|
323
|
+
- **TypeScript compilation** checking
|
|
324
|
+
- **Security auditing** with npm audit
|
|
325
|
+
- **Dependency validation**
|
|
326
|
+
- **Build verification**
|
|
327
|
+
|
|
328
|
+
## 📚 Documentation
|
|
329
|
+
|
|
330
|
+
- [Homebrew Setup Guide](./HOMEBREW_SETUP.md)
|
|
331
|
+
- [npm Publishing Guide](./NPM_PUBLISHING.md)
|
|
332
|
+
|
|
333
|
+
## 🤝 Contributing
|
|
334
|
+
|
|
335
|
+
1. Fork the repository
|
|
336
|
+
2. Create a feature branch
|
|
337
|
+
3. Make your changes
|
|
338
|
+
4. Run `npm run typecheck` and `npm run build`
|
|
339
|
+
5. Submit a pull request
|
|
340
|
+
|
|
341
|
+
## 📄 License
|
|
342
|
+
|
|
343
|
+
MIT © [Code Collab](https://github.com/codecollab-co)
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## 🔄 Recent Updates
|
|
348
|
+
|
|
349
|
+
### v0.1.0 - Multi-Cloud Architecture
|
|
350
|
+
- ✅ **Multi-cloud provider support** (architecture ready)
|
|
351
|
+
- ✅ **Enhanced Slack integration** with detailed breakdowns
|
|
352
|
+
- ✅ **AWS SDK v3 upgrade** for better performance
|
|
353
|
+
- ✅ **IAM roles and environment variables** support
|
|
354
|
+
- ✅ **Automated npm and Homebrew publishing**
|
|
355
|
+
- ✅ **Critical bug fixes** and consistency improvements
|
|
356
|
+
|
|
357
|
+
### Migration from aws-cost-cli
|
|
358
|
+
This tool has evolved from `aws-cost-cli` to `infra-cost` with backward compatibility maintained. Both `infra-cost` and `aws-cost` commands work.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
*For questions or support, please [create an issue](https://github.com/codecollab-co/infra-cost/issues) on GitHub.*
|