-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-local.sh
executable file
·56 lines (45 loc) · 1.36 KB
/
deploy-local.sh
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
#!/bin/bash
# Configuration
STACK_NAME="ankibot"
TEMPLATE_FILE="template.yaml"
REGION="us-east-1"
DEPLOYMENT_BUCKET="ankibot-deployment"
# Start LocalStack if not running
if ! curl -s http://localhost:4566/_localstack/health | grep -q "\"s3\": \"running\""; then
echo "Starting LocalStack..."
LOCALSTACK_CONFIG=localstack-config.json localstack start -d
sleep 5
fi
# Create S3 buckets
echo "Creating S3 buckets..."
awslocal s3 mb s3://ankibot-deployment
awslocal s3 mb s3://ankibot-audio-000000000000
awslocal s3 mb s3://ankibot-decks-000000000000
# Create temp directories
mkdir -p build/layer/python
mkdir -p build/functions
# Install dependencies for layer
pip install -r requirements.txt -t build/layer/python
# Create layer package
cd build/layer
zip -r ../../layer.zip .
cd ../..
# Package function code
zip -r build/functions.zip *.py
# Upload packages to S3
awslocal s3 cp layer.zip s3://ankibot-deployment/
awslocal s3 cp build/functions.zip s3://ankibot-deployment/
# Deploy CloudFormation stack
awslocal cloudformation deploy \
--template-file $TEMPLATE_FILE \
--stack-name $STACK_NAME \
--parameter-overrides \
TelegramToken="test-token" \
AnthropicApiKey="test-key" \
DeploymentBucket="ankibot-deployment" \
--capabilities CAPABILITY_NAMED_IAM \
--region $REGION
# Clean up
rm -rf build
rm layer.zip
echo "Deployment to LocalStack complete!"