forked from itsrcx/serverless-tumbnail-generator
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdate-lambda.sh
More file actions
executable file
Β·53 lines (41 loc) Β· 1.33 KB
/
update-lambda.sh
File metadata and controls
executable file
Β·53 lines (41 loc) Β· 1.33 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
#!/bin/bash
# Update Lambda Function Code Script
echo "π Updating Lambda function code..."
# Get user input
read -p "Enter project name (default: serverless-image-resizer): " PROJECT_INPUT
PROJECT_NAME=${PROJECT_INPUT:-"serverless-image-resizer"}
read -p "Enter AWS region (default: us-east-1): " REGION_INPUT
REGION=${REGION_INPUT:-"us-east-1"}
FUNCTION_NAME="${PROJECT_NAME}-resizer"
# AWS Profile Setup
AWS_PROFILE_FLAG=""
if [ -f ~/.aws/credentials ]; then
echo "π Available AWS profiles:"
aws configure list-profiles 2>/dev/null || echo "No profiles found"
echo
read -p "Enter profile name (or press Enter for default): " PROFILE_NAME
if [ -n "$PROFILE_NAME" ]; then
AWS_PROFILE_FLAG="--profile $PROFILE_NAME"
echo "β
Using profile: $PROFILE_NAME"
fi
fi
# Create deployment package
echo "π¦ Creating deployment package..."
cd src
zip -r ../lambda-update.zip .
cd ..
# Update Lambda function
echo "π Updating Lambda function: $FUNCTION_NAME"
aws lambda update-function-code \
--function-name $FUNCTION_NAME \
--zip-file fileb://lambda-update.zip \
--region $REGION \
$AWS_PROFILE_FLAG
if [ $? -eq 0 ]; then
echo "β
Lambda function updated successfully!"
else
echo "β Failed to update Lambda function"
fi
# Cleanup
rm -f lambda-update.zip
echo "π Update complete!"