-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (78 loc) · 2.94 KB
/
Copy pathMakefile
File metadata and controls
96 lines (78 loc) · 2.94 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
.PHONY: help init plan apply destroy test clean cost-estimate
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
init: ## Initialize Terraform
terraform init
terraform validate
plan: ## Run Terraform plan
terraform plan -out=tfplan
apply: ## Apply Terraform configuration
terraform apply tfplan
deploy: init plan apply ## Full deployment (init, plan, apply)
@echo "Deployment complete!"
@make show-credentials
show-credentials: ## Display API credentials
@echo ""
@echo "=========================================="
@echo "API Credentials"
@echo "=========================================="
@echo "Endpoint: $$(terraform output -raw api_endpoint)"
@echo "API Key: $$(terraform output -raw api_key)"
@echo "=========================================="
@echo ""
test: ## Run API tests
@if [ -z "$$BEDROCK_API_ENDPOINT" ]; then \
export BEDROCK_API_ENDPOINT=$$(terraform output -raw api_endpoint); \
fi; \
if [ -z "$$BEDROCK_API_KEY" ]; then \
export BEDROCK_API_KEY=$$(terraform output -raw api_key); \
fi; \
chmod +x examples/test_api.sh; \
./examples/test_api.sh "$$BEDROCK_API_ENDPOINT" "$$BEDROCK_API_KEY"
quick-test: ## Quick API test (single request)
@curl -X POST "$$(terraform output -raw api_endpoint)" \
-H "Content-Type: application/json" \
-H "x-api-key: $$(terraform output -raw api_key)" \
-d '{"messages":[{"role":"user","content":"Hello!"}],"max_tokens":50}' | jq '.'
cost-estimate: ## Run cost calculator
python3 cost_calculator.py
logs: ## Tail Lambda logs
@aws logs tail /aws/lambda/bedrock-claude-api --follow
destroy: ## Destroy all resources
@echo "WARNING: This will destroy all resources!"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
terraform destroy; \
fi
clean: ## Clean temporary files
rm -rf .terraform/
rm -f tfplan
rm -f lambda.zip
rm -f api_credentials.txt
rm -f terraform.tfstate.backup
format: ## Format Terraform files
terraform fmt -recursive
validate: ## Validate Terraform configuration
terraform validate
outputs: ## Show all Terraform outputs
terraform output
status: ## Show deployment status
@echo "Terraform Status:"
@terraform show -json | jq -r '.values.root_module.resources[] | "\(.type).\(.name): \(.values.id // "pending")"'
update-model: ## Update default model (usage: make update-model MODEL=claude-3-5-haiku)
@if [ -z "$(MODEL)" ]; then \
echo "Usage: make update-model MODEL=<model-id>"; \
exit 1; \
fi
terraform apply -var="default_model_id=$(MODEL)"
check-access: ## Check Bedrock model access
@echo "Checking Bedrock model access..."
@aws bedrock list-foundation-models \
--region $$(terraform output -raw aws_region 2>/dev/null || echo us-east-1) \
--by-provider anthropic \
--query 'modelSummaries[*].[modelId,modelName]' \
--output table