cdk-cost-analyzer 0.1.1 → 0.1.3
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/.cdk-cost-analyzer-cache/metadata.json +2 -2
- package/.kiro/specs/fix-pricing-calculators.md +203 -0
- package/.kiro/steering/github-cli-best-practices.md +383 -0
- package/CHANGELOG.md +48 -1
- package/README.md +52 -0
- package/demo/.cdk-cost-analyzer.yaml +68 -0
- package/demo/LICENSE +202 -0
- package/demo/README.md +194 -0
- package/demo/cdk.json +22 -0
- package/demo/cdk.out.1/cdk.out +1 -0
- package/demo/cdk.out.1/demo-dev.assets.json +21 -0
- package/demo/cdk.out.1/demo-dev.template.json +872 -0
- package/demo/cdk.out.1/manifest.json +741 -0
- package/demo/cdk.out.1/tree.json +1 -0
- package/demo/cdk.out.2/cdk.out +1 -0
- package/demo/cdk.out.2/demo-dev.assets.json +21 -0
- package/demo/cdk.out.2/demo-dev.template.json +1455 -0
- package/demo/cdk.out.2/manifest.json +867 -0
- package/demo/cdk.out.2/tree.json +1 -0
- package/demo/cdk.out.3/cdk.out +1 -0
- package/demo/cdk.out.3/demo-dev.assets.json +21 -0
- package/demo/cdk.out.3/demo-dev.template.json +1622 -0
- package/demo/cdk.out.3/manifest.json +950 -0
- package/demo/cdk.out.3/tree.json +1 -0
- package/demo/package.json +99 -0
- package/demo/scripts/seed-slogans.js +55 -0
- package/demo/yarn.lock +4801 -0
- package/dist/cli/index.js +20 -1
- package/dist/pricing/PricingClient.js +23 -2
- package/dist/pricing/RegionMapper.d.ts +5 -0
- package/dist/pricing/RegionMapper.js +48 -0
- package/dist/pricing/calculators/ALBCalculator.d.ts +0 -1
- package/dist/pricing/calculators/ALBCalculator.js +4 -22
- package/dist/pricing/calculators/APIGatewayCalculator.d.ts +0 -1
- package/dist/pricing/calculators/APIGatewayCalculator.js +6 -24
- package/dist/pricing/calculators/CloudFrontCalculator.d.ts +0 -10
- package/dist/pricing/calculators/CloudFrontCalculator.js +4 -31
- package/dist/pricing/calculators/DynamoDBCalculator.d.ts +0 -1
- package/dist/pricing/calculators/DynamoDBCalculator.js +6 -24
- package/dist/pricing/calculators/EC2Calculator.d.ts +0 -1
- package/dist/pricing/calculators/EC2Calculator.js +3 -21
- package/dist/pricing/calculators/ECSCalculator.d.ts +0 -1
- package/dist/pricing/calculators/ECSCalculator.js +4 -22
- package/dist/pricing/calculators/ElastiCacheCalculator.d.ts +0 -1
- package/dist/pricing/calculators/ElastiCacheCalculator.js +3 -21
- package/dist/pricing/calculators/LambdaCalculator.d.ts +0 -1
- package/dist/pricing/calculators/LambdaCalculator.js +4 -22
- package/dist/pricing/calculators/NLBCalculator.d.ts +0 -1
- package/dist/pricing/calculators/NLBCalculator.js +4 -22
- package/dist/pricing/calculators/NatGatewayCalculator.d.ts +0 -1
- package/dist/pricing/calculators/NatGatewayCalculator.js +4 -22
- package/dist/pricing/calculators/RDSCalculator.d.ts +0 -1
- package/dist/pricing/calculators/RDSCalculator.js +4 -22
- package/dist/pricing/calculators/S3Calculator.d.ts +0 -1
- package/dist/pricing/calculators/S3Calculator.js +3 -21
- package/dist/pricing/calculators/VPCEndpointCalculator.d.ts +0 -1
- package/dist/pricing/calculators/VPCEndpointCalculator.js +4 -22
- package/dist/releasetag.txt +1 -1
- package/dist/utils/Logger.d.ts +39 -0
- package/dist/utils/Logger.js +100 -0
- package/docs/RELEASE.md +150 -105
- package/docs/TROUBLESHOOTING.md +81 -2
- package/examples/DEBUG-QUICK-REFERENCE.md +85 -0
- package/examples/debug-logging-example.md +221 -0
- package/package.json +3 -3
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"entries": {
|
|
3
3
|
"AmazonS3:EU (Frankfurt):storageClass:General Purpose|volumeType:Standard": {
|
|
4
4
|
"price": 0.023,
|
|
5
|
-
"timestamp":
|
|
5
|
+
"timestamp": 1768909325265
|
|
6
6
|
},
|
|
7
7
|
"AmazonS3:invalid-region-123:storageClass:General Purpose|volumeType:Standard": {
|
|
8
8
|
"price": 0.023,
|
|
9
|
-
"timestamp":
|
|
9
|
+
"timestamp": 1768909325302
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Fix Pricing Calculator Detection Issues
|
|
3
|
+
status: draft
|
|
4
|
+
created: 2026-01-19
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Fix Pricing Calculator Detection Issues
|
|
8
|
+
|
|
9
|
+
## Problem Statement
|
|
10
|
+
|
|
11
|
+
The cdk-cost-analyzer tool fails to detect and calculate costs for most AWS resources, showing $0.00 for resources that have working calculators. Testing with a real-world CDK stack reveals that only Lambda functions are properly priced, while NAT Gateways, Application Load Balancers, ECS Fargate services, DynamoDB tables, and AutoScaling Groups all show $0.00.
|
|
12
|
+
|
|
13
|
+
## Current Behavior
|
|
14
|
+
|
|
15
|
+
When analyzing a CloudFormation template containing:
|
|
16
|
+
- AWS::EC2::NatGateway
|
|
17
|
+
- AWS::ElasticLoadBalancingV2::LoadBalancer
|
|
18
|
+
- AWS::ECS::Service (Fargate)
|
|
19
|
+
- AWS::DynamoDB::Table
|
|
20
|
+
- AWS::AutoScaling::AutoScalingGroup
|
|
21
|
+
- AWS::Lambda::Function
|
|
22
|
+
|
|
23
|
+
Only the Lambda function returns a cost estimate ($2.08/month). All other resources show `$0.00 [unknown]`.
|
|
24
|
+
|
|
25
|
+
## Root Cause Analysis
|
|
26
|
+
|
|
27
|
+
1. **Pricing API queries work** - Manual testing confirms AWS Pricing API returns correct data
|
|
28
|
+
2. **Calculators exist** - Code inspection shows calculators for all major resource types
|
|
29
|
+
3. **Query generation fails** - The pricing queries generated by calculators don't match AWS Pricing API format
|
|
30
|
+
|
|
31
|
+
### Verified Issues
|
|
32
|
+
|
|
33
|
+
#### NAT Gateway Calculator
|
|
34
|
+
- Calculator exists at `src/pricing/calculators/NatGatewayCalculator.ts`
|
|
35
|
+
- Supports resource type `AWS::EC2::NatGateway`
|
|
36
|
+
- Pricing API query likely fails due to filter mismatch
|
|
37
|
+
|
|
38
|
+
#### ALB Calculator
|
|
39
|
+
- Calculator exists at `src/pricing/calculators/ALBCalculator.ts`
|
|
40
|
+
- Supports resource type `AWS::ElasticLoadBalancingV2::LoadBalancer`
|
|
41
|
+
- Needs to distinguish between ALB and NLB
|
|
42
|
+
|
|
43
|
+
#### ECS Calculator
|
|
44
|
+
- Calculator exists at `src/pricing/calculators/ECSCalculator.ts`
|
|
45
|
+
- Supports resource type `AWS::ECS::Service`
|
|
46
|
+
- Must extract Fargate CPU/memory from task definition
|
|
47
|
+
|
|
48
|
+
#### DynamoDB Calculator
|
|
49
|
+
- Calculator exists at `src/pricing/calculators/DynamoDBCalculator.ts`
|
|
50
|
+
- Supports resource type `AWS::DynamoDB::Table`
|
|
51
|
+
- Pay-per-request pricing requires usage assumptions
|
|
52
|
+
|
|
53
|
+
#### AutoScaling Group Support
|
|
54
|
+
- No calculator for `AWS::AutoScaling::AutoScalingGroup`
|
|
55
|
+
- No calculator for `AWS::AutoScaling::LaunchConfiguration`
|
|
56
|
+
- EC2Calculator exists but doesn't support ASG resources
|
|
57
|
+
|
|
58
|
+
## Expected Behavior
|
|
59
|
+
|
|
60
|
+
For the test stack, the analyzer should report:
|
|
61
|
+
- NAT Gateway: ~$33/month (hourly + data processing)
|
|
62
|
+
- Application Load Balancer: ~$16/month (hourly + LCU charges)
|
|
63
|
+
- ECS Fargate (2 tasks, 0.25 vCPU, 0.5 GB): ~$15-20/month
|
|
64
|
+
- DynamoDB (pay-per-request): $0.00 with usage assumptions note
|
|
65
|
+
- Lambda: $2.08/month (currently working)
|
|
66
|
+
- AutoScaling Group (2 x t3.micro): ~$17.52/month
|
|
67
|
+
|
|
68
|
+
**Total expected: ~$83-103/month**
|
|
69
|
+
|
|
70
|
+
## Proposed Solution
|
|
71
|
+
|
|
72
|
+
### Phase 1: Diagnostic Improvements
|
|
73
|
+
|
|
74
|
+
1. **Add debug logging**
|
|
75
|
+
- Log pricing API queries before execution
|
|
76
|
+
- Log pricing API responses
|
|
77
|
+
- Log filter values used in queries
|
|
78
|
+
- Add `--debug` flag to CLI
|
|
79
|
+
|
|
80
|
+
2. **Improve error messages**
|
|
81
|
+
- Show which filters failed to match
|
|
82
|
+
- Suggest correct filter values
|
|
83
|
+
- Display pricing API error responses
|
|
84
|
+
|
|
85
|
+
### Phase 2: Fix Existing Calculators
|
|
86
|
+
|
|
87
|
+
1. **NAT Gateway Calculator**
|
|
88
|
+
- Verify region prefix generation
|
|
89
|
+
- Test filter combinations against Pricing API
|
|
90
|
+
- Add integration test with real API calls
|
|
91
|
+
|
|
92
|
+
2. **ALB Calculator**
|
|
93
|
+
- Fix LoadBalancer type detection (ALB vs NLB)
|
|
94
|
+
- Verify pricing filters for eu-central-1
|
|
95
|
+
- Add LCU cost calculation
|
|
96
|
+
|
|
97
|
+
3. **ECS Calculator**
|
|
98
|
+
- Extract task definition properties from CloudFormation
|
|
99
|
+
- Calculate Fargate pricing based on vCPU and memory
|
|
100
|
+
- Handle both Fargate and EC2 launch types
|
|
101
|
+
|
|
102
|
+
4. **DynamoDB Calculator**
|
|
103
|
+
- Implement pay-per-request pricing
|
|
104
|
+
- Use usage assumptions from config
|
|
105
|
+
- Add on-demand vs provisioned detection
|
|
106
|
+
|
|
107
|
+
### Phase 3: Add Missing Calculators
|
|
108
|
+
|
|
109
|
+
1. **AutoScaling Group Calculator**
|
|
110
|
+
- Extract instance type from LaunchConfiguration/LaunchTemplate
|
|
111
|
+
- Calculate cost based on min/max/desired capacity
|
|
112
|
+
- Support multiple instance types in mixed instance policy
|
|
113
|
+
|
|
114
|
+
2. **LaunchTemplate Support**
|
|
115
|
+
- Parse AWS::EC2::LaunchTemplate resources
|
|
116
|
+
- Extract instance type and other pricing factors
|
|
117
|
+
- Link to AutoScaling Groups
|
|
118
|
+
|
|
119
|
+
### Phase 4: Testing & Validation
|
|
120
|
+
|
|
121
|
+
1. **Integration Tests**
|
|
122
|
+
- Test against real AWS Pricing API
|
|
123
|
+
- Verify costs for all supported regions
|
|
124
|
+
- Compare with AWS Pricing Calculator
|
|
125
|
+
|
|
126
|
+
2. **Test Fixtures**
|
|
127
|
+
- Add CloudFormation templates for each resource type
|
|
128
|
+
- Include edge cases (mixed instance types, spot instances)
|
|
129
|
+
- Test with actual deployed stacks
|
|
130
|
+
|
|
131
|
+
3. **Documentation**
|
|
132
|
+
- Document supported resource types
|
|
133
|
+
- List known limitations
|
|
134
|
+
- Provide troubleshooting guide
|
|
135
|
+
|
|
136
|
+
## Test Cases
|
|
137
|
+
|
|
138
|
+
### Test Case 1: NAT Gateway Pricing
|
|
139
|
+
```yaml
|
|
140
|
+
Input: CloudFormation template with AWS::EC2::NatGateway
|
|
141
|
+
Region: eu-central-1
|
|
142
|
+
Expected: ~$33/month (hourly rate + data processing)
|
|
143
|
+
Config: usageAssumptions.natGateway.dataProcessedGB = 500
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Test Case 2: Application Load Balancer
|
|
147
|
+
```yaml
|
|
148
|
+
Input: CloudFormation template with AWS::ElasticLoadBalancingV2::LoadBalancer (Type: application)
|
|
149
|
+
Region: eu-central-1
|
|
150
|
+
Expected: ~$16/month (hourly rate + LCU charges)
|
|
151
|
+
Config: usageAssumptions.alb.processedBytesGB = 1000
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Test Case 3: ECS Fargate Service
|
|
155
|
+
```yaml
|
|
156
|
+
Input: CloudFormation template with AWS::ECS::Service + TaskDefinition
|
|
157
|
+
Task: 0.25 vCPU, 0.5 GB memory
|
|
158
|
+
Desired Count: 2
|
|
159
|
+
Region: eu-central-1
|
|
160
|
+
Expected: ~$15-20/month
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Test Case 4: AutoScaling Group
|
|
164
|
+
```yaml
|
|
165
|
+
Input: CloudFormation template with AWS::AutoScaling::AutoScalingGroup
|
|
166
|
+
Instance Type: t3.micro
|
|
167
|
+
Desired Capacity: 2
|
|
168
|
+
Region: eu-central-1
|
|
169
|
+
Expected: ~$17.52/month (2 x $0.012/hour x 730 hours)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Success Criteria
|
|
173
|
+
|
|
174
|
+
1. All calculators return non-zero costs for valid resources
|
|
175
|
+
2. Cost estimates within 10% of AWS Pricing Calculator
|
|
176
|
+
3. Debug mode shows pricing API queries and responses
|
|
177
|
+
4. Integration tests pass against real Pricing API
|
|
178
|
+
5. Documentation updated with supported resources
|
|
179
|
+
|
|
180
|
+
## Implementation Plan
|
|
181
|
+
|
|
182
|
+
1. **Week 1**: Add debug logging and improve error messages
|
|
183
|
+
2. **Week 2**: Fix NAT Gateway and ALB calculators
|
|
184
|
+
3. **Week 3**: Fix ECS and DynamoDB calculators
|
|
185
|
+
4. **Week 4**: Add AutoScaling Group calculator
|
|
186
|
+
5. **Week 5**: Integration tests and documentation
|
|
187
|
+
|
|
188
|
+
## GitHub Issues to Create
|
|
189
|
+
|
|
190
|
+
1. **Add debug logging for pricing API calls** (Phase 1)
|
|
191
|
+
2. **Fix NAT Gateway calculator pricing detection** (Phase 2)
|
|
192
|
+
3. **Fix ALB calculator pricing detection** (Phase 2)
|
|
193
|
+
4. **Fix ECS Fargate calculator pricing detection** (Phase 2)
|
|
194
|
+
5. **Fix DynamoDB calculator pricing detection** (Phase 2)
|
|
195
|
+
6. **Add AutoScaling Group calculator** (Phase 3)
|
|
196
|
+
7. **Add LaunchTemplate support for EC2 pricing** (Phase 3)
|
|
197
|
+
8. **Add integration tests for pricing calculators** (Phase 4)
|
|
198
|
+
|
|
199
|
+
## References
|
|
200
|
+
|
|
201
|
+
- AWS Pricing API: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html
|
|
202
|
+
- Test stack: `demo/cdk.out/demo-dev.template.json`
|
|
203
|
+
- Pricing verification: Manual AWS Pricing API queries confirmed correct pricing data exists
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: GitHub CLI Best Practices
|
|
3
|
+
inclusion: always
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub CLI Best Practices
|
|
7
|
+
|
|
8
|
+
## Authentication
|
|
9
|
+
|
|
10
|
+
Always verify authentication status before creating issues or PRs:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
gh auth status
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Expected output should show:
|
|
17
|
+
- Logged in account
|
|
18
|
+
- Active account: true
|
|
19
|
+
- Required token scopes: repo, workflow
|
|
20
|
+
|
|
21
|
+
## Creating Issues
|
|
22
|
+
|
|
23
|
+
### Basic Issue Creation
|
|
24
|
+
|
|
25
|
+
Use simple, direct syntax to avoid shell escaping issues:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
gh issue create \
|
|
29
|
+
--title "Issue title here" \
|
|
30
|
+
--body "Issue description" \
|
|
31
|
+
--label "bug"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Avoiding Common Pitfalls
|
|
35
|
+
|
|
36
|
+
**DO NOT use complex multi-line bodies with special characters:**
|
|
37
|
+
```bash
|
|
38
|
+
# BAD - Will fail with quotes, backticks, dollar signs
|
|
39
|
+
gh issue create --title "Fix bug" --body "The `$variable` doesn't work"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**DO use simple bodies:**
|
|
43
|
+
```bash
|
|
44
|
+
# GOOD - Simple body
|
|
45
|
+
gh issue create --title "Fix bug" --body "Variable expansion fails in calculator" --label "bug"
|
|
46
|
+
|
|
47
|
+
# GOOD - Use single quotes for special characters
|
|
48
|
+
gh issue create --title "Fix bug" --body 'The calculator fails with $variables and backticks' --label "bug"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**AVOID heredoc (EOF) syntax - it can cause issues in some environments**
|
|
52
|
+
|
|
53
|
+
### Label Management
|
|
54
|
+
|
|
55
|
+
**Check available labels first:**
|
|
56
|
+
```bash
|
|
57
|
+
gh label list
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Only use existing labels:**
|
|
61
|
+
```bash
|
|
62
|
+
# Common labels that usually exist
|
|
63
|
+
--label "bug"
|
|
64
|
+
--label "enhancement"
|
|
65
|
+
--label "documentation"
|
|
66
|
+
|
|
67
|
+
# Avoid custom labels that may not exist
|
|
68
|
+
--label "pricing" # May not exist
|
|
69
|
+
--label "testing" # May not exist
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Multiple labels:**
|
|
73
|
+
```bash
|
|
74
|
+
gh issue create --title "Title" --body "Body" --label "bug,documentation"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Issue Body Best Practices
|
|
78
|
+
|
|
79
|
+
**Keep it simple for CLI:**
|
|
80
|
+
- Use plain text without special formatting
|
|
81
|
+
- Avoid backticks, dollar signs, quotes in CLI body
|
|
82
|
+
- For complex content, use --web flag to open browser editor
|
|
83
|
+
- Or create issue first with simple body, then edit in browser
|
|
84
|
+
|
|
85
|
+
**Example - Simple approach:**
|
|
86
|
+
```bash
|
|
87
|
+
gh issue create \
|
|
88
|
+
--title "Add debug logging" \
|
|
89
|
+
--body "Add --debug flag to show pricing API queries and responses" \
|
|
90
|
+
--label "enhancement"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Example - Complex content:**
|
|
94
|
+
```bash
|
|
95
|
+
# Use --web flag to open browser for complex formatting
|
|
96
|
+
gh issue create --title "Fix NAT Gateway pricing" --label "bug" --web
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Creating Pull Requests
|
|
100
|
+
|
|
101
|
+
### Basic PR Creation
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
gh pr create \
|
|
105
|
+
--title "Fix: NAT Gateway pricing detection" \
|
|
106
|
+
--body "Fixes #26" \
|
|
107
|
+
--base main
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Draft PRs
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
gh pr create --draft --title "WIP: Add AutoScaling calculator" --body "Work in progress"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### PR from Issue
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Create branch and PR linked to issue
|
|
120
|
+
gh issue develop 26 --checkout
|
|
121
|
+
# Make changes, commit
|
|
122
|
+
gh pr create --title "Fix NAT Gateway pricing" --body "Closes #26"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Viewing Issues and PRs
|
|
126
|
+
|
|
127
|
+
### List Issues
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# All open issues
|
|
131
|
+
gh issue list
|
|
132
|
+
|
|
133
|
+
# Filter by label
|
|
134
|
+
gh issue list --label "bug"
|
|
135
|
+
|
|
136
|
+
# Filter by assignee
|
|
137
|
+
gh issue list --assignee "@me"
|
|
138
|
+
|
|
139
|
+
# Show more details
|
|
140
|
+
gh issue list --limit 20
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### View Issue Details
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
gh issue view 26
|
|
147
|
+
gh issue view 26 --web # Open in browser
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### List PRs
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
gh pr list
|
|
154
|
+
gh pr list --state "all"
|
|
155
|
+
gh pr list --author "@me"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Commenting
|
|
159
|
+
|
|
160
|
+
### Add Comment to Issue
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Simple comment
|
|
164
|
+
gh issue comment 26 --body "Working on this now"
|
|
165
|
+
|
|
166
|
+
# Long comment with special characters - use single quotes
|
|
167
|
+
gh issue comment 26 --body 'Fixed the $variable issue. The calculator now works correctly.'
|
|
168
|
+
|
|
169
|
+
# For multi-line comments, keep them simple or use --web flag
|
|
170
|
+
gh issue comment 26 --body 'Update: Fixed pricing queries, added tests, ready for review'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Add Comment to PR
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Simple comment
|
|
177
|
+
gh pr comment 123 --body "LGTM"
|
|
178
|
+
|
|
179
|
+
# Detailed review comment - use single quotes
|
|
180
|
+
gh pr comment 123 --body 'Great work! Just one suggestion: consider using `const` instead of `let` on line 42.'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Comment Best Practices
|
|
184
|
+
|
|
185
|
+
**Use single quotes for comments with special characters:**
|
|
186
|
+
```bash
|
|
187
|
+
# GOOD - Single quotes prevent shell expansion
|
|
188
|
+
gh issue comment 26 --body 'The $variable and `code` work now'
|
|
189
|
+
|
|
190
|
+
# BAD - Double quotes cause shell expansion issues
|
|
191
|
+
gh issue comment 26 --body "The $variable and `code` work now"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**For long multi-line comments, keep them simple:**
|
|
195
|
+
```bash
|
|
196
|
+
# Keep it concise in a single line
|
|
197
|
+
gh issue comment 26 --body 'Completed: Fixed NAT Gateway pricing, added debug logging, updated tests. Next: Review PR and update docs.'
|
|
198
|
+
|
|
199
|
+
# Or use --web flag to open browser for complex formatting
|
|
200
|
+
gh issue comment 26 --web
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Closing and Reopening
|
|
204
|
+
|
|
205
|
+
### Close Issue
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
gh issue close 26
|
|
209
|
+
gh issue close 26 --comment "Fixed in PR #123"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Reopen Issue
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
gh issue reopen 26
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Repository Context
|
|
219
|
+
|
|
220
|
+
### Check Current Repository
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
gh repo view
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Set Repository Context
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Work with different repo
|
|
230
|
+
gh issue list --repo owner/repo
|
|
231
|
+
|
|
232
|
+
# Or set default
|
|
233
|
+
cd /path/to/repo
|
|
234
|
+
gh issue list # Uses current directory's repo
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Common Workflows
|
|
238
|
+
|
|
239
|
+
### Create Issue from Template
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# List available templates
|
|
243
|
+
gh issue create --web
|
|
244
|
+
|
|
245
|
+
# Or use CLI with simple body
|
|
246
|
+
gh issue create --title "Bug report" --body "Description here" --label "bug"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Bulk Operations
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Close multiple issues
|
|
253
|
+
for issue in 10 11 12; do
|
|
254
|
+
gh issue close $issue
|
|
255
|
+
done
|
|
256
|
+
|
|
257
|
+
# Add label to multiple issues
|
|
258
|
+
for issue in 26 27 28; do
|
|
259
|
+
gh issue edit $issue --add-label "priority-high"
|
|
260
|
+
done
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Search Issues
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Search in title and body
|
|
267
|
+
gh issue list --search "pricing calculator"
|
|
268
|
+
|
|
269
|
+
# Search with filters
|
|
270
|
+
gh issue list --search "is:open label:bug pricing"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Error Handling
|
|
274
|
+
|
|
275
|
+
### Common Errors and Solutions
|
|
276
|
+
|
|
277
|
+
**Error: "could not add label: 'labelname' not found"**
|
|
278
|
+
```bash
|
|
279
|
+
# Solution: Check available labels first
|
|
280
|
+
gh label list
|
|
281
|
+
# Use only existing labels
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Error: "authentication required"**
|
|
285
|
+
```bash
|
|
286
|
+
# Solution: Login or refresh token
|
|
287
|
+
gh auth login
|
|
288
|
+
gh auth refresh
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Error: "repository not found"**
|
|
292
|
+
```bash
|
|
293
|
+
# Solution: Verify you're in correct directory or specify repo
|
|
294
|
+
gh repo view # Check current repo
|
|
295
|
+
cd /path/to/correct/repo
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Error: Shell escaping issues with body text**
|
|
299
|
+
```bash
|
|
300
|
+
# Solution: Use single quotes or --web flag
|
|
301
|
+
gh issue create --title "Title" --label "bug" --body 'Complex body with special characters'
|
|
302
|
+
# Or use --web flag to open browser
|
|
303
|
+
gh issue create --title "Title" --label "bug" --web
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Best Practices Summary
|
|
307
|
+
|
|
308
|
+
1. **Always verify auth status** before operations
|
|
309
|
+
2. **Check available labels** before using them
|
|
310
|
+
3. **Keep CLI bodies simple** - use --web flag for complex content
|
|
311
|
+
4. **Use single quotes** for strings with special characters ($, `, ", etc.)
|
|
312
|
+
5. **NEVER use heredoc (EOF) syntax** - it can crash some environments
|
|
313
|
+
6. **Test with one issue** before bulk operations
|
|
314
|
+
7. **Use --web flag** for complex issue creation or editing
|
|
315
|
+
8. **Link issues and PRs** with "Fixes #123" or "Closes #123"
|
|
316
|
+
9. **Check repository context** with `gh repo view`
|
|
317
|
+
10. **Use issue templates** when available
|
|
318
|
+
|
|
319
|
+
## Integration with Workflow
|
|
320
|
+
|
|
321
|
+
### Spec-Driven Development
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# 1. Create spec document first
|
|
325
|
+
vim .kiro/specs/feature-name.md
|
|
326
|
+
|
|
327
|
+
# 2. Create GitHub issues from spec
|
|
328
|
+
gh issue create --title "Implement feature X" --body "See spec in .kiro/specs/feature-name.md" --label "enhancement"
|
|
329
|
+
|
|
330
|
+
# 3. Create branch for issue
|
|
331
|
+
gh issue develop 26 --checkout
|
|
332
|
+
|
|
333
|
+
# 4. Implement and create PR
|
|
334
|
+
gh pr create --title "Implement feature X" --body "Closes #26"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Issue Tracking
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Check your assigned issues
|
|
341
|
+
gh issue list --assignee "@me"
|
|
342
|
+
|
|
343
|
+
# Check issues in current milestone
|
|
344
|
+
gh issue list --milestone "v1.0"
|
|
345
|
+
|
|
346
|
+
# Check issues by project
|
|
347
|
+
gh issue list --search "project:ProjectName"
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Troubleshooting
|
|
351
|
+
|
|
352
|
+
### Debug Mode
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Enable debug output
|
|
356
|
+
GH_DEBUG=1 gh issue create --title "Test" --body "Test"
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Verbose Output
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Show more details
|
|
363
|
+
gh issue list --json number,title,labels,state
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Check Configuration
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
# View current config
|
|
370
|
+
gh config list
|
|
371
|
+
|
|
372
|
+
# Set default editor
|
|
373
|
+
gh config set editor vim
|
|
374
|
+
|
|
375
|
+
# Set default protocol
|
|
376
|
+
gh config set git_protocol https
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## References
|
|
380
|
+
|
|
381
|
+
- Official docs: https://cli.github.com/manual/
|
|
382
|
+
- Issue creation: https://cli.github.com/manual/gh_issue_create
|
|
383
|
+
- PR creation: https://cli.github.com/manual/gh_pr_create
|
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Features
|
|
11
|
+
- Add demo CDK project with ECS Fargate, bastion hosts, and serverless API
|
|
12
|
+
|
|
13
|
+
### Documentation
|
|
14
|
+
- Add GitHub CLI best practices steering document
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
- Fix locale formatting in CustomAssumptions property test
|
|
18
|
+
|
|
10
19
|
### Security
|
|
11
20
|
- Improved command execution security in CDK synthesis by using `shell: false` to prevent command injection vulnerabilities
|
|
12
21
|
|
|
22
|
+
## [0.1.2] - 2025-01-20
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
- Add debug logging for pricing API calls with `--debug` flag
|
|
26
|
+
- Add Logger utility class for consistent debug output
|
|
27
|
+
- Add region normalization logging
|
|
28
|
+
- Add cache status logging (memory/persistent)
|
|
29
|
+
- Add comprehensive debug logging documentation
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- Upgrade dependencies to latest versions
|
|
33
|
+
|
|
34
|
+
## [0.1.1] - 2024-12-11
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
- Enable npm release workflow
|
|
38
|
+
- Add GitHub Actions workflow validation with act pre-commit hook
|
|
39
|
+
- Migrate from Vitest to Jest and improve projen configuration
|
|
40
|
+
- Add dedicated test workflow for GitHub Actions status checks
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
- Update package name to unscoped cdk-cost-analyzer
|
|
44
|
+
- Increase property test timeouts for CDK synthesis from 15s to 30s
|
|
45
|
+
- Enforce npm version consistency in CI workflow
|
|
46
|
+
- Pin Node.js version to 20.18.1 in GitHub Actions workflows
|
|
47
|
+
- Ensure npm ci is used consistently in GitHub Actions
|
|
48
|
+
- Add example project dependencies installation to build workflow
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
- Clean up temporary CDK output files and artifacts
|
|
52
|
+
- Remove temporary log files
|
|
53
|
+
- Exclude CDK output directories from version control
|
|
54
|
+
|
|
55
|
+
### Security
|
|
56
|
+
- Fix security vulnerability in CDK synthesis process
|
|
57
|
+
|
|
13
58
|
## [0.1.0] - 2024-12-10
|
|
14
59
|
|
|
15
60
|
### Added
|
|
@@ -45,5 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
45
90
|
- AWS::ElastiCache::CacheCluster
|
|
46
91
|
- AWS::EC2::VPCEndpoint
|
|
47
92
|
|
|
48
|
-
[Unreleased]: https://github.com/buildinginthecloud/cdk-cost-analyzer/compare/v0.1.
|
|
93
|
+
[Unreleased]: https://github.com/buildinginthecloud/cdk-cost-analyzer/compare/v0.1.2...HEAD
|
|
94
|
+
[0.1.2]: https://github.com/buildinginthecloud/cdk-cost-analyzer/compare/v0.1.1...v0.1.2
|
|
95
|
+
[0.1.1]: https://github.com/buildinginthecloud/cdk-cost-analyzer/compare/v0.1.0...v0.1.1
|
|
49
96
|
[0.1.0]: https://github.com/buildinginthecloud/cdk-cost-analyzer/releases/tag/v0.1.0
|