Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
702 lines (658 loc) · 28.8 KB
/
Copy pathMakefile
File metadata and controls
702 lines (658 loc) · 28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# AWS DevOps Agent - Consolidated Makefile
# Simplified and consolidated commands
.PHONY: help run dev setup clean test
# Default target
help: ## Show this help message
@echo "🚀 AWS DevOps Agent - Available Commands"
@echo "========================================"
@echo ""
@echo "🎯 MAIN COMMANDS"
@echo "=================="
@echo "\033[36mrun\033[0m Run the agent (interactive mode) - MAIN COMMAND"
@echo "\033[36mdev\033[0m Run in demo mode"
@echo "\033[36mquery\033[0m Run a single query (usage: make query QUERY=\"your query\")"
@echo "\033[36mrun-no-account-selection\033[0m Run the agent without interactive account selection"
@echo ""
@echo "🔧 SETUP & INSTALLATION"
@echo "========================="
@echo "\033[36msetup\033[0m Complete setup: create venv, install deps, install MCP servers, install AgentCore"
@echo "\033[36minstall\033[0m Install dependencies (alias for setup)"
@echo "\033[36mclean\033[0m Clean up temporary files and virtual environment"
@echo "\033[36mstatus\033[0m Show project status"
@echo ""
@echo "🔌 MCP SERVER MANAGEMENT"
@echo "========================="
@echo "\033[36mmcp-check\033[0m Check if MCP servers are installed (AWS + GitHub)"
@echo "\033[36mmcp-install\033[0m Install AWS MCP servers + GitHub MCP server from source"
@echo "\033[36mmcp-run\033[0m Run MCP servers directly (development)"
@echo "\033[36mmcp-stop\033[0m Stop all running MCP servers"
@echo "\033[36mmcp-test\033[0m Test MCP server connections"
@echo ""
@echo "🧪 TESTING & DEVELOPMENT"
@echo "========================="
@echo "\033[36mtest\033[0m Run all tests (excludes integration tests)"
@echo "\033[36mtest-terraform\033[0m Run Terraform tests"
@echo "\033[36mtest-integration\033[0m Run integration tests (requires GitHub config)"
@echo "\033[36mtest-github\033[0m Run GitHub integration tests (requires GitHub config)"
@echo "\033[36mtest-complete-workflow\033[0m Run complete workflow test (requires GitHub config)"
@echo "\033[36mgithub-test-connectivity\033[0m Test GitHub repository connectivity (usage: make github-test-connectivity REPO=owner/repo)"
@echo "\033[36mformat\033[0m Format code"
@echo ""
@echo "🚀 AGENTCORE DEPLOYMENT"
@echo "========================"
@echo "\033[36magentcore-env\033[0m Create .env file for AgentCore (usage: make agentcore-env ENV=dev|prod|staging)"
@echo "\033[36magentcore-configure\033[0m Configure AgentCore for deployment"
@echo "\033[36magentcore-validate\033[0m Validate environment configuration"
@echo "\033[36magentcore-build\033[0m Build Docker image for AgentCore deployment"
@echo "\033[36magentcore-test-local\033[0m Test AgentCore deployment locally"
@echo "\033[36magentcore-deploy-verify\033[0m Human verification for production deployment"
@echo "\033[36magentcore-deploy\033[0m Deploy to Bedrock AgentCore (PRODUCTION)"
@echo "\033[36magentcore-status\033[0m Check AgentCore deployment status"
@echo "\033[36magentcore-test\033[0m Test deployed AgentCore agent"
@echo "\033[36magentcore-rollback\033[0m Rollback AgentCore deployment (with verification)"
@echo "\033[36magentcore-monitor\033[0m Monitor AgentCore deployment performance"
@echo ""
@echo "📚 EXAMPLES & DEMOS"
@echo "===================="
@echo "\033[36mexample\033[0m Run example (usage: make example TYPE=cost|iac|compliance|cdk|terraform|security|data-sources|report|github)"
@echo ""
@echo "💡 Quick Start: make setup && make run"
@echo "🔧 AgentCore: make agentcore-configure && make agentcore-deploy"
@echo "📚 Examples: make example TYPE=cost"
@echo ""
@echo "ℹ️ Legacy commands (agentcore-env-dev, agentcore-env-prod, etc.) are still available"
@echo " but use the new consolidated commands above for better experience"
# =============================================================================
# MAIN COMMANDS
# =============================================================================
run: ## Run the agent (interactive mode) - MAIN COMMAND
@echo "🚀 Starting AWS DevOps Agent..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
echo "✅ Using virtual environment: .venv"; \
PYTHONPATH=src python main.py --mode interactive; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
run-no-account-selection: ## Run the agent without interactive account selection
@echo "🚀 Starting AWS DevOps Agent (no account selection)..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
echo "✅ Using virtual environment: .venv"; \
PYTHONPATH=src python main.py --mode interactive --no-account-selection; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
dev: ## Run in demo mode
@echo "🎭 Starting AWS DevOps Agent in demo mode..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python main.py --mode demo; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
query: ## Run a single query (usage: make query QUERY="your query")
@if [ -z "$(QUERY)" ]; then \
echo "❌ Please provide a query: make query QUERY='your query'"; \
exit 1; \
fi
@echo "🔍 Running query: $(QUERY)"
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python main.py --query "$(QUERY)"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
# =============================================================================
# SETUP & INSTALLATION
# =============================================================================
setup: ## Complete setup: create venv, install deps, install MCP servers, install AgentCore
@echo "🔧 Setting up AWS DevOps Agent..."
@echo "1️⃣ Creating virtual environment..."
python3 -m venv .venv
@echo "2️⃣ Installing dependencies..."
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -r requirements_dev.txt
.venv/bin/pip install bedrock-agentcore
@echo "3️⃣ Installing MCP servers (AWS + GitHub)..."
@$(MAKE) mcp-install
@echo "✅ Setup complete!"
@echo "💡 Run 'source .venv/bin/activate' then 'make run'"
@echo "🚀 For AgentCore deployment: 'make agentcore-configure' then 'make agentcore-deploy'"
install: setup ## Install dependencies (alias for setup)
# =============================================================================
# MCP SERVER MANAGEMENT
# =============================================================================
mcp-check: ## Check if MCP servers are installed (AWS + GitHub)
@echo "🔌 Checking MCP servers..."
@echo ""
@if command -v uv >/dev/null 2>&1; then \
echo "✅ uv is available"; \
echo ""; \
echo "Checking installed AWS MCP servers:"; \
uv tool list 2>/dev/null | grep -E "(cost-explorer|cloudwatch|aws-pricing|terraform|dynamodb)" || echo "❌ No AWS MCP servers found"; \
echo ""; \
echo "🔍 Checking GitHub MCP Server status:"; \
if [ -f github-mcp-server/github-mcp-server ]; then \
echo "✅ GitHub MCP Server binary available at github-mcp-server/github-mcp-server"; \
if [ -x github-mcp-server/github-mcp-server ]; then \
echo "✅ GitHub MCP Server binary is executable"; \
else \
echo "⚠️ GitHub MCP Server binary is not executable (run: chmod +x github-mcp-server/github-mcp-server)"; \
fi; \
else \
echo "❌ GitHub MCP Server binary not found"; \
fi; \
echo ""; \
echo "🔑 Checking GitHub configuration:"; \
if [ -f src/aws_devops_agent/config/.env ]; then \
if grep -q "GITHUB_PERSONAL_ACCESS_TOKEN=" src/aws_devops_agent/config/.env; then \
echo "✅ GitHub token found in config file"; \
else \
echo "❌ GitHub token not found in config file"; \
fi; \
else \
echo "❌ Config file not found at src/aws_devops_agent/config/.env"; \
fi; \
if [ -n "$$GITHUB_PERSONAL_ACCESS_TOKEN" ]; then \
echo "✅ GitHub token found in environment variables"; \
else \
echo "⚠️ GitHub token not found in environment variables"; \
fi; \
else \
echo "❌ uv not available. Install with: curl -LsSf https://astral.sh/uv/install.sh \| sh"; \
fi
mcp-install: ## Install AWS MCP servers and GitHub MCP server
@echo "🔌 Installing MCP servers (AWS + GitHub)..."
@if command -v uv >/dev/null 2>&1; then \
echo "Installing cost-explorer-mcp-server..."; \
uv tool install awslabs.cost-explorer-mcp-server@latest || echo "⚠️ Failed to install cost-explorer-mcp-server"; \
echo "Installing cloudwatch-mcp-server..."; \
uv tool install awslabs.cloudwatch-mcp-server@latest || echo "⚠️ Failed to install cloudwatch-mcp-server"; \
echo "Installing aws-pricing-mcp-server..."; \
uv tool install awslabs.aws-pricing-mcp-server@latest || echo "⚠️ Failed to install aws-pricing-mcp-server"; \
echo "Installing terraform-mcp-server..."; \
uv tool install awslabs.terraform-mcp-server@latest || echo "⚠️ Failed to install terraform-mcp-server"; \
echo "Installing dynamodb-mcp-server..."; \
uv tool install awslabs.dynamodb-mcp-server@latest || echo "⚠️ Failed to install dynamodb-mcp-server"; \
echo ""; \
echo "🐙 Installing GitHub MCP Server from source..."; \
if [ -f src/aws_devops_agent/config/.env ]; then \
. src/aws_devops_agent/config/.env; \
if [ -n "$$GITHUB_PERSONAL_ACCESS_TOKEN" ] && command -v go >/dev/null 2>&1; then \
if [ ! -d "./github-mcp-server" ]; then \
echo "📥 Cloning GitHub MCP Server repository..."; \
git clone https://github.com/github/github-mcp-server.git; \
fi; \
echo "🔨 Building GitHub MCP Server..."; \
cd github-mcp-server/cmd/github-mcp-server && go build -o ../../github-mcp-server; \
chmod +x ../../github-mcp-server; \
echo "✅ GitHub MCP Server built successfully"; \
else \
echo "⚠️ GitHub MCP Server skipped - requires Go and GITHUB_PERSONAL_ACCESS_TOKEN in .env"; \
fi; \
else \
echo "⚠️ GitHub MCP Server skipped - configuration file not found"; \
fi; \
echo ""; \
echo "✅ MCP installation completed"; \
echo "💡 Run 'make mcp-check' to verify installation"; \
else \
echo "❌ uv not available. Install with: curl -LsSf https://astral.sh/uv/install.sh \| sh"; \
exit 1; \
fi
mcp-run: ## Run MCP servers directly (development)
@echo "🚀 Running MCP servers directly (AWS + GitHub)..."
@if command -v uvx >/dev/null 2>&1; then \
echo "Starting cost-explorer-mcp-server..."; \
uvx awslabs.cost-explorer-mcp-server@latest & \
echo "Starting cloudwatch-mcp-server..."; \
uvx awslabs.cloudwatch-mcp-server@latest & \
echo "Starting aws-pricing-mcp-server..."; \
uvx awslabs.aws-pricing-mcp-server@latest & \
echo "Starting terraform-mcp-server..."; \
uvx awslabs.terraform-mcp-server@latest & \
echo "Starting dynamodb-mcp-server..."; \
uvx awslabs.dynamodb-mcp-server@latest & \
echo ""; \
echo "🐙 Starting GitHub MCP Server..."; \
if [ -f github-mcp-server/github-mcp-server ] && [ -f src/aws_devops_agent/config/.env ]; then \
. src/aws_devops_agent/config/.env; \
if [ -n "$$GITHUB_PERSONAL_ACCESS_TOKEN" ]; then \
cd github-mcp-server && GITHUB_PERSONAL_ACCESS_TOKEN=$$GITHUB_PERSONAL_ACCESS_TOKEN ./github-mcp-server stdio & \
cd ..; \
echo "✅ GitHub MCP Server started"; \
else \
echo "⚠️ GitHub MCP Server not started - GITHUB_PERSONAL_ACCESS_TOKEN not found in .env"; \
fi; \
else \
echo "⚠️ GitHub MCP Server not started - binary or .env file not found"; \
fi; \
echo ""; \
echo "✅ MCP servers started in background"; \
echo "💡 Use 'make mcp-stop' to stop all servers"; \
else \
echo "❌ uvx not available. Install with: curl -LsSf https://astral.sh/uv/install.sh \| sh"; \
exit 1; \
fi
mcp-stop: ## Stop all running MCP servers
@echo "🛑 Stopping MCP servers..."
@pkill -f "cost-explorer-mcp-server" || true
@pkill -f "cloudwatch-mcp-server" || true
@pkill -f "aws-pricing-mcp-server" || true
@pkill -f "terraform-mcp-server" || true
@pkill -f "dynamodb-mcp-server" || true
@pkill -f "github-mcp-server" || true
@echo "✅ MCP servers stopped"
mcp-test: ## Test MCP server connections
@echo "🧪 Testing MCP server connections..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
echo "🔌 Testing AWS MCP servers..."; \
python tests/integration/test_mcp_integration.py; \
echo ""; \
echo "🐙 Testing GitHub MCP server..."; \
if [ -f github-mcp-server/github-mcp-server ] && [ -f src/aws_devops_agent/config/.env ]; then \
. src/aws_devops_agent/config/.env; \
if [ -n "$$GITHUB_PERSONAL_ACCESS_TOKEN" ]; then \
python scripts/test_github_connectivity.py octocat/Hello-World; \
else \
echo "⚠️ GitHub MCP test skipped - GITHUB_PERSONAL_ACCESS_TOKEN not found"; \
fi; \
else \
echo "⚠️ GitHub MCP test skipped - binary or config not found"; \
fi; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
# =============================================================================
# DEVELOPMENT & TESTING
# =============================================================================
test: ## 🧪 Run core tests (unit + document generation)
@echo "🧪 Running core tests..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/unit/ tests/document_generation/ -v --ignore=tests/unit/test_aws_devops_agent.py --ignore=tests/document_generation/test_agent_document_generation.py; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
test-terraform: ## 🏗️ Run Terraform tests
@echo "🏗️ Running Terraform tests..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/terraform/ -v; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
test-integration: ## 🔗 Run integration tests (requires GitHub config)
@echo "🔗 Running integration tests..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/integration/ -v || [ $$? -eq 2 ]; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
test-complete-workflow: ## 🚀 Run complete workflow test (requires GitHub config)
@echo "🚀 Running complete workflow test..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/integration/test_complete_workflow.py -v || [ $$? -eq 2 ]; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
test-github: ## 🐙 Run GitHub integration tests (requires GitHub config)
@echo "🐙 Running GitHub integration tests..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/integration/test_github_mcp.py -v; \
EXIT_CODE=$$?; \
if [ $$EXIT_CODE -eq 2 ]; then \
echo "✅ GitHub tests skipped (no token configured)"; \
exit 0; \
else \
exit $$EXIT_CODE; \
fi; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
github-test-connectivity: ## 🔗 Test GitHub repository connectivity
@echo "🔗 Testing GitHub repository connectivity..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
if [ -f src/aws_devops_agent/config/.env ]; then \
. src/aws_devops_agent/config/.env; \
if [ -n "$$GITHUB_PERSONAL_ACCESS_TOKEN" ]; then \
python scripts/test_github_connectivity.py $(REPO); \
else \
echo "❌ GITHUB_PERSONAL_ACCESS_TOKEN not found in config"; \
fi; \
else \
echo "❌ Config file not found at src/aws_devops_agent/config/.env"; \
fi; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
test-all: ## 🧪 Run all tests (core + terraform + integration)
@echo "🧪 Running all tests..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
PYTHONPATH=src python -m pytest tests/ -v; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
format: ## Format code
@echo "🎨 Formatting code..."
@if [ -f .venv/bin/activate ]; then \
source .venv/bin/activate && \
black src/ tests/ --line-length=100; \
isort src/ tests/ --profile black; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
@echo "✅ Code formatted"
# =============================================================================
# AGENTCORE DEPLOYMENT
# =============================================================================
agentcore-env: ## Create .env file for AgentCore (usage: make agentcore-env ENV=dev|prod|staging)
@echo "🔧 Creating $(ENV:-dev) .env file..."
@cd deployment/bedrock && \
cp env.example .env && \
if [ "$(ENV)" = "prod" ]; then \
sed -i.bak 's/DEBUG_MODE=false/DEBUG_MODE=false/' .env && \
sed -i.bak 's/LOG_LEVEL=INFO/LOG_LEVEL=WARNING/' .env && \
sed -i.bak 's/HOST=0.0.0.0/HOST=0.0.0.0/' .env; \
elif [ "$(ENV)" = "staging" ]; then \
sed -i.bak 's/DEBUG_MODE=false/DEBUG_MODE=false/' .env && \
sed -i.bak 's/LOG_LEVEL=INFO/LOG_LEVEL=INFO/' .env && \
sed -i.bak 's/HOST=0.0.0.0/HOST=0.0.0.0/' .env; \
else \
sed -i.bak 's/DEBUG_MODE=false/DEBUG_MODE=true/' .env && \
sed -i.bak 's/LOG_LEVEL=INFO/LOG_LEVEL=DEBUG/' .env && \
sed -i.bak 's/HOST=0.0.0.0/HOST=localhost/' .env; \
fi && \
rm .env.bak 2>/dev/null || true && \
echo "✅ $(ENV:-dev) .env file created"
agentcore-configure: ## Configure AgentCore for deployment
@echo "⚙️ Configuring Bedrock AgentCore..."
@if [ -f .venv/bin/activate ]; then \
cd deployment/bedrock && \
if [ ! -f .env ]; then \
echo "📋 Creating .env file from template..."; \
cp env.example .env; \
echo "✅ Created .env file - please customize it for your environment"; \
else \
echo "✅ .env file already exists"; \
fi; \
echo ""; \
echo "📋 AgentCore configuration:"; \
echo " - Entrypoint: app.py"; \
echo " - Environment file: .env"; \
echo " - Agent: AWS DevOps Agent"; \
echo ""; \
echo "⚠️ IMPORTANT: All values in .env are REQUIRED - no defaults for safety"; \
echo "✅ AgentCore configuration completed"; \
echo "💡 Edit deployment/bedrock/.env to customize your settings"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-validate: ## Validate environment configuration
@echo "🔍 Validating environment configuration..."
@python3 scripts/validate_env.py
agentcore-build: ## Build Docker image for AgentCore deployment
@echo "🐳 Building Docker image for AgentCore deployment..."
@if [ -f .venv/bin/activate ]; then \
cd deployment/bedrock && \
cp ../../requirements_production.txt . && \
cp -r ../../src . && \
docker build -t aws-devops-agent:latest . && \
rm -rf src requirements_production.txt && \
echo "✅ Docker image built successfully"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-test-local: ## Test AgentCore deployment locally
@echo "🧪 Testing AgentCore deployment locally..."
@if [ -f .venv/bin/activate ]; then \
cd deployment/bedrock && \
if [ ! -f .env ]; then \
echo "📋 Creating .env file for local testing..."; \
make agentcore-env ENV=dev; \
fi; \
../../.venv/bin/python app.py; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-deploy-verify: ## Human verification for production deployment
@echo "🔒 DEPLOYMENT VERIFICATION REQUIRED"
@echo "=================================="
@echo "⚠️ CRITICAL: This will deploy to PRODUCTION"
@echo ""
@echo "📋 Current Configuration:"
@echo " - Agent: AWS DevOps Agent"
@echo " - Environment: PRODUCTION"
@echo " - Region: $$(aws configure get region 2>/dev/null || echo 'us-east-1')"
@echo " - Account: $$(aws sts get-caller-identity --query Account --output text 2>/dev/null || echo 'Not configured')"
@echo ""
@read -p "❓ Are you authorized to deploy to PRODUCTION? (yes/no): " auth_confirm; \
if [ "$$auth_confirm" != "yes" ]; then \
echo "❌ Deployment aborted - unauthorized"; \
exit 1; \
fi
@read -p "❓ Have you reviewed the deployment configuration? (yes/no): " config_confirm; \
if [ "$$config_confirm" != "yes" ]; then \
echo "❌ Deployment aborted - configuration not reviewed"; \
exit 1; \
fi
@read -p "❓ Are you ready to proceed with PRODUCTION deployment? (yes/no): " final_confirm; \
if [ "$$final_confirm" != "yes" ]; then \
echo "❌ Deployment aborted - not ready"; \
exit 1; \
fi
@echo "✅ All verifications passed - proceeding with deployment"
agentcore-deploy: agentcore-deploy-verify ## Deploy to Bedrock AgentCore (PRODUCTION)
@echo "🚀 Deploying to Bedrock AgentCore (PRODUCTION)..."
@if [ -f .venv/bin/activate ]; then \
cd deployment/bedrock && \
if [ ! -f .env ]; then \
echo "📋 Creating .env file for production deployment..."; \
make agentcore-env ENV=prod; \
fi; \
../../.venv/bin/python app.py; \
echo "✅ Deployment completed"; \
echo "💡 Run 'make agentcore-status' to check deployment status"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-status: ## Check AgentCore deployment status
@echo "📊 Checking AgentCore deployment status..."
@if [ -f .venv/bin/activate ]; then \
echo "🔍 AgentCore Status:"; \
echo " - Agent: AWS DevOps Agent"; \
echo " - Model: $${BEDROCK_MODEL_ID:-claude-3.5-sonnet}"; \
echo " - Debug Mode: $${DEBUG_MODE:-false}"; \
echo " - Port: $${PORT:-8080}"; \
echo " - Host: $${HOST:-0.0.0.0}"; \
echo ""; \
echo "💡 To test the agent, use: make agentcore-test"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-test: ## Test deployed AgentCore agent
@echo "🧪 Testing AgentCore agent..."
@if [ -f .venv/bin/activate ]; then \
cd deployment/bedrock && \
echo "🧪 Testing agent with sample query..."; \
curl -X POST http://localhost:8080/invoke \
-H "Content-Type: application/json" \
-d '{"prompt": "What are your capabilities?"}' \
2>/dev/null || echo "❌ Agent not running. Start with: make agentcore-test-local"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
agentcore-rollback: ## Rollback AgentCore deployment (with verification)
@echo "🔄 ROLLBACK PROCEDURE"
@echo "===================="
@echo "⚠️ WARNING: This will stop the production deployment"
@echo ""
@read -p "❓ Are you sure you want to stop the agent? (yes/no): " rollback_confirm; \
if [ "$$rollback_confirm" != "yes" ]; then \
echo "❌ Rollback aborted"; \
exit 1; \
fi
@echo "🔄 Stopping agent..."
@pkill -f "python.*app.py" || echo "No running agent found"
@echo "✅ Agent stopped"
agentcore-monitor: ## Monitor AgentCore deployment performance
@echo "🔍 Monitoring AgentCore deployment..."
@if [ -f .venv/bin/activate ]; then \
echo "📊 Agent Status:"; \
make agentcore-status; \
echo ""; \
echo "🧪 Testing Agent Functionality:"; \
make agentcore-test; \
echo ""; \
echo "💡 For detailed logs, check the console output when running the agent"; \
else \
echo "❌ Virtual environment not found. Run 'make setup' first"; \
exit 1; \
fi
# =============================================================================
# UTILITIES
# =============================================================================
clean: ## Clean up temporary files and virtual environment
@echo "🧹 Cleaning up..."
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} +
find . -type d -name ".mypy_cache" -exec rm -rf {} +
rm -rf .venv/
@echo "✅ Cleanup complete"
status: ## Show project status
@echo "📊 AWS DevOps Agent - Project Status"
@echo "===================================="
@echo ""
@if [ -f .venv/bin/activate ]; then \
echo "✅ Virtual environment: .venv/"; \
else \
echo "❌ Virtual environment: Not created"; \
fi
@if [ -n "$$VIRTUAL_ENV" ]; then \
echo "✅ Virtual environment: Active ($$VIRTUAL_ENV)"; \
else \
echo "⚠️ Virtual environment: Not active"; \
fi
@echo ""
@echo "🔌 MCP Servers:"
@if command -v uv >/dev/null 2>&1; then \
uv tool list 2>/dev/null | grep -E "(cost-explorer|cloudwatch|aws-pricing)" >/dev/null && echo "✅ AWS MCP servers installed" || echo "❌ AWS MCP servers not installed"; \
else \
echo "❌ uv not available (needed for MCP servers)"; \
fi
@echo ""
@echo "🏗️ Infrastructure Tools:"
@if command -v terraform >/dev/null 2>&1; then \
echo "✅ Terraform CLI: $(shell terraform version -json | jq -r '.terraform_version' 2>/dev/null || echo 'Available')"; \
else \
echo "❌ Terraform CLI: Not installed (optional for Terraform analysis)"; \
fi
@if command -v cdk >/dev/null 2>&1; then \
echo "✅ AWS CDK CLI: $(shell cdk --version 2>/dev/null || echo 'Available')"; \
else \
echo "❌ AWS CDK CLI: Not installed (optional for CDK analysis)"; \
fi
@echo ""
@echo "📁 Project Structure:"
@find . -type d -not -path "./.git*" -not -path "./bkp*" -not -path "./__pycache__*" | head -8
@echo ""
@echo "🐍 Python Files: $(shell find . -name "*.py" -not -path "./bkp*" -not -path "./.git*" | wc -l | tr -d ' ')"
# =============================================================================
# EXAMPLES (Consolidated)
# =============================================================================
example: ## Run example (usage: make example TYPE=cost|iac|compliance|cdk|terraform|security|data-sources|report)
@if [ -z "$(TYPE)" ]; then \
echo "❌ Please provide example type: make example TYPE=cost"; \
echo "Available types: cost, iac, compliance, cdk, terraform, security, data-sources, report"; \
exit 1; \
fi
@case "$(TYPE)" in \
cost) \
echo "💰 Running cost analysis example..."; \
make query QUERY="Analyze my AWS costs and provide optimization recommendations"; \
;; \
iac) \
echo "🏗️ Running IaC analysis example..."; \
make query QUERY="Analyze my Terraform configuration for security and cost optimization"; \
;; \
compliance) \
echo "🔒 Running compliance check example..."; \
make query QUERY="Check my AWS infrastructure for SOC2 compliance"; \
;; \
cdk) \
echo "🏗️ Running CDK analysis example..."; \
make query QUERY="Analyze my CDK project for optimization opportunities and security issues"; \
;; \
terraform) \
echo "🏗️ Running Terraform analysis example..."; \
make query QUERY="Analyze my Terraform project for cost optimization and security issues"; \
;; \
security) \
echo "🛡️ Running AWS security analysis example..."; \
python docs/demos/demo_aws_security_analysis.py; \
;; \
data-sources) \
echo "📊 Running data sources focused demo..."; \
python docs/demos/demo_data_sources_simple.py; \
;; \
report) \
echo "📄 Running document generation example..."; \
make query QUERY="Generate a cost analysis report for my AWS infrastructure"; \
;; \
github) \
echo "🐙 Running GitHub integration example..."; \
make github-test-connectivity REPO=octocat/Hello-World; \
;; \
*) \
echo "❌ Unknown example type: $(TYPE)"; \
echo "Available types: cost, iac, compliance, cdk, terraform, security, data-sources, report, github"; \
exit 1; \
;; \
esac
# Legacy aliases for backward compatibility
deploy: agentcore-deploy ## Deploy to Bedrock Agent Core (legacy - use agentcore-deploy)
agentcore-install: setup ## Install Bedrock AgentCore CLI (legacy - use setup)
agentcore-env-dev: ## Create development .env file (legacy - use agentcore-env ENV=dev)
@make agentcore-env ENV=dev
agentcore-env-prod: ## Create production .env file (legacy - use agentcore-env ENV=prod)
@make agentcore-env ENV=prod
agentcore-env-staging: ## Create staging .env file (legacy - use agentcore-env ENV=staging)
@make agentcore-env ENV=staging
agentcore-health: ## Check AgentCore health status (legacy - use agentcore-test)
@echo "🏥 Checking AgentCore health status..."
@curl -f http://localhost:8080/health || echo "❌ Health check failed - agent may not be running"
agentcore-metrics: ## Get AgentCore metrics (legacy - use agentcore-test)
@echo "📊 Getting AgentCore metrics..."
@curl -s http://localhost:8080/metrics | python3 -m json.tool || echo "❌ Metrics endpoint not available"
agentcore-logs: ## View AgentCore deployment logs (legacy - use agentcore-test-local)
@echo "📝 AgentCore logs are displayed in the console when running"
@echo "💡 To see logs, run the agent with: make agentcore-test-local or make agentcore-deploy"