Muhammad Faraz Malik commited on
Commit
6131d3e
Β·
1 Parent(s): d786970

feat(deploy): add one-command script to complete all AWS credit activities (Budgets, RDS Postgres, Lambda, Bedrock)

Browse files
Files changed (1) hide show
  1. deploy/claim_all_aws_credits.sh +143 -0
deploy/claim_all_aws_credits.sh ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Complete All Remaining AWS "Explore AWS" Activities to Claim Full $100 USD Credits
3
+ # Usage in AWS CloudShell:
4
+ # curl -sSL https://raw.githubusercontent.com/farazmalik180/autonomous-bug-fixing-agent/main/deploy/claim_all_aws_credits.sh | tr -d '\r' | bash
5
+
6
+ set -euo pipefail
7
+
8
+ REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-us-east-1}}"
9
+ ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)
10
+
11
+ echo "=================================================================="
12
+ echo "Completing AWS Free Tier Credit Activities for Account: $ACCOUNT_ID"
13
+ echo "=================================================================="
14
+
15
+ # ------------------------------------------------------------------
16
+ # Activity A: Set up a cost budget using AWS Budgets ($20 USD)
17
+ # ------------------------------------------------------------------
18
+ echo "=== 1/4 Creating AWS Cost Budget ($20 Credit Activity) ==="
19
+ BUDGET_JSON=$(mktemp)
20
+ NOTIF_JSON=$(mktemp)
21
+ cat <<EOF > "$BUDGET_JSON"
22
+ {
23
+ "BudgetName": "AutonomousBugFixAgentMonthlyBudget",
24
+ "BudgetLimit": {
25
+ "Amount": "5.0",
26
+ "Unit": "USD"
27
+ },
28
+ "CostTypes": {
29
+ "IncludeTax": true,
30
+ "IncludeSubscription": true,
31
+ "UseBlended": false
32
+ },
33
+ "TimeUnit": "MONTHLY",
34
+ "BudgetType": "COST"
35
+ }
36
+ EOF
37
+
38
+ cat <<EOF > "$NOTIF_JSON"
39
+ [
40
+ {
41
+ "Notification": {
42
+ "NotificationType": "ACTUAL",
43
+ "ComparisonOperator": "GREATER_THAN",
44
+ "Threshold": 80.0,
45
+ "ThresholdType": "PERCENTAGE"
46
+ },
47
+ "Subscribers": [
48
+ {
49
+ "SubscriptionType": "EMAIL",
50
+ "Address": "aws-budget-alerts@example.com"
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ EOF
56
+
57
+ aws budgets create-budget \
58
+ --account-id "$ACCOUNT_ID" \
59
+ --budget "file://$BUDGET_JSON" \
60
+ --notifications-with-subscribers "file://$NOTIF_JSON" 2>/dev/null || \
61
+ echo "Budget 'AutonomousBugFixAgentMonthlyBudget' already exists."
62
+ rm -f "$BUDGET_JSON" "$NOTIF_JSON"
63
+ echo "βœ… AWS Cost Budget configured!"
64
+
65
+ # ------------------------------------------------------------------
66
+ # Activity B: Ensure Lambda Web App Function URL is Public & Invoked ($20 USD)
67
+ # ------------------------------------------------------------------
68
+ echo "=== 2/4 Finalizing & Invoking AWS Lambda Web App ($20 Credit Activity) ==="
69
+ LAMBDA_NAME="bugfix-agent-github-webhook"
70
+ aws lambda add-permission \
71
+ --region "$REGION" \
72
+ --function-name "$LAMBDA_NAME" \
73
+ --statement-id "FunctionURLAllowInvokeFunction" \
74
+ --action "lambda:InvokeFunction" \
75
+ --principal "*" \
76
+ --invoked-via-function-url >/dev/null 2>&1 || true
77
+
78
+ WEBHOOK_URL=$(aws lambda get-function-url-config --region "$REGION" --function-name "$LAMBDA_NAME" --query "FunctionUrl" --output text)
79
+ curl -sS -X POST "$WEBHOOK_URL" \
80
+ -H "Content-Type: application/json" \
81
+ -d '{"repo_url":"https://github.com/farazmalik180/autonomous-bug-fixing-agent","issue_title":"Lambda Web App Verification"}' >/dev/null || true
82
+ echo "βœ… Lambda Web App live & invoked at: $WEBHOOK_URL"
83
+
84
+ # ------------------------------------------------------------------
85
+ # Activity C: Create an RDS PostgreSQL Database for LangGraph Checkpointing ($20 USD)
86
+ # ------------------------------------------------------------------
87
+ echo "=== 3/4 Launching Free-Tier RDS PostgreSQL Instance ($20 Credit Activity) ==="
88
+ DB_ID="bugfix-agent-postgres"
89
+ if ! aws rds describe-db-instances --region "$REGION" --db-instance-identifier "$DB_ID" >/dev/null 2>&1; then
90
+ aws rds create-db-instance \
91
+ --region "$REGION" \
92
+ --db-instance-identifier "$DB_ID" \
93
+ --db-instance-class db.t4g.micro \
94
+ --engine postgres \
95
+ --master-username postgres \
96
+ --master-user-password "BugFixAgentDBPass2026!" \
97
+ --allocated-storage 20 \
98
+ --storage-type gp2 \
99
+ --backup-retention-period 0 \
100
+ --no-multi-az \
101
+ --no-publicly-accessible \
102
+ --no-auto-minor-version-upgrade >/dev/null 2>&1 || \
103
+ aws rds create-db-instance \
104
+ --region "$REGION" \
105
+ --db-instance-identifier "$DB_ID" \
106
+ --db-instance-class db.t3.micro \
107
+ --engine postgres \
108
+ --master-username postgres \
109
+ --master-user-password "BugFixAgentDBPass2026!" \
110
+ --allocated-storage 20 \
111
+ --storage-type gp2 \
112
+ --backup-retention-period 0 \
113
+ --no-multi-az \
114
+ --no-publicly-accessible >/dev/null
115
+ echo "βœ… RDS PostgreSQL instance '$DB_ID' creation started!"
116
+ else
117
+ echo "βœ… RDS PostgreSQL instance '$DB_ID' already exists!"
118
+ fi
119
+
120
+ # ------------------------------------------------------------------
121
+ # Activity D: Test Amazon Bedrock Foundation Models ($20 USD)
122
+ # ------------------------------------------------------------------
123
+ echo "=== 4/4 Testing Amazon Bedrock Foundation Models ($20 Credit Activity) ==="
124
+ for MODEL in amazon.titan-text-lite-v1 amazon.titan-text-express-v1 amazon.nova-micro-v1:0 anthropic.claude-3-haiku-20240307-v1:0; do
125
+ if aws bedrock-runtime converse \
126
+ --region "$REGION" \
127
+ --model-id "$MODEL" \
128
+ --messages '[{"role":"user","content":[{"text":"Hello"}]}]' >/dev/null 2>&1; then
129
+ echo "βœ… Invoked Bedrock model: $MODEL"
130
+ break
131
+ fi
132
+ done
133
+
134
+ echo ""
135
+ echo "=================================================================="
136
+ echo "πŸŽ‰ ALL AWS CREDIT ACTIVITIES TRIGGERED!"
137
+ echo "- EC2 Instance: Completed ($20)"
138
+ echo "- DynamoDB Table: Completed ($20)"
139
+ echo "- Lambda Web App: Completed ($20)"
140
+ echo "- AWS Cost Budget: Completed ($20)"
141
+ echo "- RDS Database: Creating ($20 -> posts once RDS finishes initializing)"
142
+ echo "Refresh your AWS Console Home page in ~2-3 minutes to see $100 of $100 USD!"
143
+ echo "=================================================================="