AWS Cost Optimize

AWS Cost Optimize

Guides an agent to analyse AWS resources and infrastructure code for cost savings, then file a GitHub issue per optimisation plus one epic to coordinate the work.

Skill files1 file
SKILL.md195 lines
1
---
2
name: aws-cost-optimize
3
description: 'Analyze AWS resources used in the app (IaC files and/or resources in a target account/region) and optimize costs - creating GitHub issues for identified optimizations.'
4
---
5
6
# AWS Cost Optimize
7
8
This workflow analyzes Infrastructure-as-Code (IaC) files and AWS resources to generate cost optimization recommendations. It creates individual GitHub issues for each optimization opportunity plus one EPIC issue to coordinate implementation, enabling efficient tracking and execution of cost savings initiatives.
9
10
## Prerequisites
11
- AWS CLI configured and authenticated (`aws sts get-caller-identity` succeeds)
12
- GitHub MCP server configured and authenticated
13
- Target GitHub repository identified
14
- AWS resources deployed (IaC files optional but helpful)
15
16
## Workflow Steps
17
18
### Step 1: Get AWS Cost Optimization Best Practices
19
**Action**: Retrieve cost optimization best practices before analysis
20
**Tools**: `fetch` to retrieve AWS documentation
21
**Process**:
22
1. **Load Best Practices**:
23
- Fetch `https://docs.aws.amazon.com/cost-management/latest/userguide/cost-optimization-best-practices.html`
24
- Fetch the AWS Well-Architected Cost Optimization pillar summary
25
- Use these practices to inform subsequent analysis and recommendations
26
27
### Step 2: Discover AWS Infrastructure
28
**Action**: Dynamically discover and analyze AWS resources and configurations
29
**Tools**: AWS CLI + Local file system access
30
**Process**:
31
1. **Account & Region Discovery**:
32
- Execute `aws sts get-caller-identity` to confirm account
33
- Execute `aws configure get region` to determine default region
34
35
2. **Resource Discovery** (per region):
36
- EC2 instances: `aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,InstanceType,State.Name,Tags]'`
37
- RDS instances: `aws rds describe-db-instances --query 'DBInstances[].[DBInstanceIdentifier,DBInstanceClass,Engine,MultiAZ]'`
38
- Lambda functions: `aws lambda list-functions --query 'Functions[].[FunctionName,Runtime,MemorySize,Architectures]'`
39
- ECS clusters/services: `aws ecs list-clusters` then `aws ecs describe-services`
40
- S3 buckets: `aws s3api list-buckets --query 'Buckets[].Name'`
41
- ElastiCache clusters: `aws elasticache describe-cache-clusters`
42
- NAT Gateways: `aws ec2 describe-nat-gateways`
43
- Load Balancers: `aws elbv2 describe-load-balancers`
44
45
3. **IaC Detection**:
46
- Scan for IaC files: `**/*.tf`, `**/*.yaml` (CloudFormation/SAM), `**/*.json` (CloudFormation), `**/cdk.json`, `lib/**/*.ts` (CDK)
47
- Parse resource definitions to understand intended configurations
48
- Do NOT use application code files — only IaC files as the source of truth
49
- If no IaC files found: STOP and report to user
50
51
### Step 3: Collect Usage Metrics & Validate Current Costs
52
**Action**: Gather utilization data and verify actual resource costs
53
**Tools**: AWS CLI (CloudWatch, Cost Explorer)
54
**Process**:
55
1. **CloudWatch Metrics** (last 7 days):
56
```bash
57
# EC2 CPU utilization
58
aws cloudwatch get-metric-statistics \
59
--namespace AWS/EC2 --metric-name CPUUtilization \
60
--dimensions Name=InstanceId,Value=<id> \
61
--start-time $(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ) \
62
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
63
--period 3600 --statistics Average
64
65
# Lambda duration
66
aws cloudwatch get-metric-statistics \
67
--namespace AWS/Lambda --metric-name Duration \
68
--dimensions Name=FunctionName,Value=<name> \
69
--start-time $(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ) \
70
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
71
--period 86400 --statistics Average,Maximum
72
```
73
74
2. **AWS Cost Explorer**:
75
```bash
76
aws ce get-cost-and-usage \
77
--time-period Start=$(date -u -d '30 days ago' +%Y-%m-%d),End=$(date -u +%Y-%m-%d) \
78
--granularity MONTHLY --metrics BlendedCost \
79
--group-by Type=DIMENSION,Key=SERVICE
80
```
81
82
3. **Calculate Baseline Metrics**: CPU/Memory averages, Lambda invocation rates, data transfer patterns, and a realistic current monthly total.
83
84
### Step 4: Generate Cost Optimization Recommendations
85
**Action**: Analyze resources to identify optimization opportunities
86
**Process**:
87
1. **Apply Optimization Patterns**:
88
89
**Compute**:
90
- EC2: Right-size based on CPU/memory (<20% average → downsize), convert On-Demand to Savings Plans, migrate to Graviton/ARM (up to 40% cheaper)
91
- Lambda: Reduce memory for idle functions, switch to `arm64` (20% cheaper)
92
- ECS/EKS: Use Fargate Spot for dev/batch workloads
93
94
**Database**:
95
- RDS: Right-size instance class, convert single-AZ for dev, use Aurora Serverless v2 for variable load
96
- DynamoDB: Switch Provisioned → On-Demand for unpredictable traffic
97
- ElastiCache: Right-size node type based on memory utilization
98
99
**Storage**:
100
- S3: Lifecycle policies (Standard → Standard-IA after 30d → Glacier after 90d), enable Intelligent-Tiering
101
- EBS: Delete unattached volumes, convert gp2 → gp3 (same performance, 20% cheaper)
102
103
**Network**:
104
- Consolidate NAT Gateways for non-production environments
105
- Use VPC endpoints for S3/DynamoDB to avoid NAT Gateway charges
106
107
2. **Calculate Priority Score**:
108
```
109
Priority Score = (Value Score × Monthly Savings) / (Risk Score × Implementation Days)
110
High: Score > 20 | Medium: Score 5-20 | Low: Score < 5
111
```
112
113
### Step 5: User Confirmation
114
**Action**: Present summary and get approval before creating GitHub issues
115
116
```
117
🎯 AWS Cost Optimization Summary
118
119
📊 Analysis Results:
120
• Total Resources Analyzed: X
121
• Current Monthly Cost: $X
122
• Potential Monthly Savings: $Y
123
• Optimization Opportunities: Z
124
• High Priority Items: N
125
126
🏆 Recommendations:
127
1. [Resource]: [Current] → [Target] = $X/month savings - [Risk] | [Effort]
128
...
129
130
💡 This will create Y individual GitHub issues + 1 EPIC issue.
131
132
❓ Proceed with creating GitHub issues? (y/n)
133
```
134
135
Wait for user confirmation before proceeding.
136
137
### Step 6: Create Individual Optimization Issues
138
**Action**: Create separate GitHub issues for each optimization. Label with "cost-optimization" (green) and "aws" (orange).
139
140
**Title**: `[COST-OPT] [Resource Type] - [Brief Description] - $X/month savings`
141
142
**Body**:
143
````markdown
144
## 💰 Cost Optimization: [Brief Title]
145
146
**Monthly Savings**: $X | **Risk Level**: [Low/Medium/High] | **Effort**: X days
147
148
### 📋 Description
149
[Clear explanation of the optimization and why it's needed]
150
151
### 🔧 Implementation
152
153
**IaC Files Detected**: [Yes/No]
154
155
```bash
156
# IaC modification (preferred) or AWS CLI fallback
157
```
158
159
### 📊 Evidence
160
- Current Configuration: [details]
161
- Usage Pattern: [evidence from CloudWatch]
162
- Cost Impact: $X/month → $Y/month
163
164
### ✅ Validation Steps
165
- [ ] Test in non-production environment
166
- [ ] Verify no performance degradation via CloudWatch
167
- [ ] Confirm cost reduction in AWS Cost Explorer
168
169
### ⚠️ Risks & Considerations
170
- [Risk and mitigation]
171
172
**Priority Score**: X | **Value**: X/10 | **Risk**: X/10
173
````
174
175
### Step 7: Create EPIC Coordinating Issue
176
**Action**: Create master tracking issue. Label with "cost-optimization" (green), "aws" (orange), "epic" (purple).
177
178
**Title**: `[EPIC] AWS Cost Optimization Initiative - $X/month potential savings`
179
180
**Body**: Executive summary with account/region details, Mermaid architecture diagram of current resources, prioritized checklist linking all individual issues (High → Medium → Low), progress tracking, and success criteria (>80% of estimated savings realized, no performance degradation).
181
182
## Error Handling
183
- **AWS Authentication Failure**: Guide through `aws configure`
184
- **No Resources Found**: Create informational issue about AWS resource deployment
185
- **Insufficient Permissions**: List required IAM read-only permissions
186
- **GitHub Creation Failure**: Output formatted recommendations to console
187
- **Cost Explorer Not Enabled**: Guide user to enable in AWS Console
188
189
## Success Criteria
190
- ✅ All cost estimates verified against actual configurations and AWS pricing
191
- ✅ Individual GitHub issues created for each optimization
192
- ✅ EPIC issue provides comprehensive coordination and tracking
193
- ✅ All recommendations include specific AWS CLI or IaC commands
194
- ✅ User confirmation obtained before creating issues
195

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,684 prompts

More by @OpenSourceBuffGuy

See all
Vermilion Jade Halftone prompt image

Vermilion Jade Halftone

Defines a dense sci-fi film poster style on teal-green paper with giant vermilion Chinese title glyphs, cream highlights and ink-black halftone with print wear.

image-prompt, json-prompt, placeholders, poster, sci-fi, printmaking, typography, vintage, text-rendering, vertical-format, widescreen, graphic-design, for-designers, for-artists, limited-palette, film-grain, cinematic, china, structured-output, long-form, advanced, style-reference, concept-art, halftone

Arize Dataset prompt image

Arize Dataset

Creates, lists, exports and appends examples to Arize datasets with the ax CLI, covering dataset versions, file-based creation and troubleshooting setup errors.

agent-skill, llm-evaluation, llm, command-line, data-engineering, csv, json-output, structured-output, for-developers, for-prompt-engineers, for-data-analysts, tool-use, troubleshooting, step-by-step-guide, long-form, database, api, machine-learning, cheat-sheet, code, arize

Launch Ground Operations Manager prompt image

Launch Ground Operations Manager

Plans launch site ground operations: ground support equipment, propellant and safety systems, maintenance and staffing to keep fast turnaround safe.

system-prompt, expert-advice, operations, safety, engineering, planner, for-engineers, for-managers, xml-tags, structured-output, guardrails, risk-management, compliance, space, aviation, long-form, advanced, report, playbook, process-improvement

Reviews

Loading reviews…

Discussion

Loading comments…