-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·74 lines (62 loc) · 2.34 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·74 lines (62 loc) · 2.34 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
#!/bin/bash
# IntelliNemo Agent Deployment Script
set -e
PROJECT_NAME="intellinemo-agent"
ENVIRONMENT="dev"
REGION="us-east-1"
echo "🚀 Deploying IntelliNemo Agent..."
# Check if NVIDIA API key is provided
if [ -z "$NVIDIA_API_KEY" ]; then
echo "❌ Error: NVIDIA_API_KEY environment variable is required"
echo "Please set it with: export NVIDIA_API_KEY=your_nvidia_api_key"
exit 1
fi
# Check AWS CLI configuration
if ! aws sts get-caller-identity > /dev/null 2>&1; then
echo "❌ Error: AWS CLI not configured or no valid credentials"
echo "Please run: aws configure"
exit 1
fi
echo "✅ Prerequisites check passed"
# Package Lambda function
echo "📦 Packaging Lambda function..."
cd src/lambda
zip -r ../../lambda-deployment.zip .
cd ../..
# Deploy CloudFormation stack
echo "☁️ Deploying CloudFormation stack..."
aws cloudformation deploy \
--template-file infrastructure/cloudformation/main-stack.json \
--stack-name ${PROJECT_NAME}-${ENVIRONMENT} \
--parameter-overrides \
ProjectName=${PROJECT_NAME} \
Environment=${ENVIRONMENT} \
NvidiaApiKey=${NVIDIA_API_KEY} \
--capabilities CAPABILITY_NAMED_IAM \
--region ${REGION}
# Update Lambda function code
echo "🔄 Updating Lambda function code..."
FUNCTION_NAME="${PROJECT_NAME}-${ENVIRONMENT}-agent"
aws lambda update-function-code \
--function-name ${FUNCTION_NAME} \
--zip-file fileb://lambda-deployment.zip \
--region ${REGION}
# Get stack outputs
echo "📋 Getting deployment information..."
aws cloudformation describe-stacks \
--stack-name ${PROJECT_NAME}-${ENVIRONMENT} \
--query 'Stacks[0].Outputs' \
--region ${REGION}
echo "✅ Deployment completed successfully!"
echo ""
echo "🧪 To test the deployment:"
echo "1. Create a test CloudWatch alarm:"
echo " aws cloudwatch put-metric-alarm --alarm-name test-cpu-alarm --alarm-description 'Test alarm' --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 80 --comparison-operator GreaterThanThreshold --evaluation-periods 1"
echo ""
echo "2. Trigger the alarm:"
echo " aws cloudwatch set-alarm-state --alarm-name test-cpu-alarm --state-value ALARM --state-reason 'Testing IntelliNemo Agent'"
echo ""
echo "3. Check Lambda logs:"
echo " aws logs tail /aws/lambda/${FUNCTION_NAME} --follow"
# Cleanup
rm -f lambda-deployment.zip