-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lambda.sh
More file actions
executable file
·34 lines (25 loc) · 969 Bytes
/
test_lambda.sh
File metadata and controls
executable file
·34 lines (25 loc) · 969 Bytes
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
#!/bin/bash
set -e # Stop the script if any command fails
export AWS_PAGER=""
LAMBDA_NAME="alert"
ZIP_FILE="localtest/lambda_function.zip"
HANDLER="lambda_function.lambda_handler"
ROLE_ARN="arn:aws:iam::000000000000:role/lambda-role"
FILE_TO_INVOKE="sample_log.json"
RESPONSE_FILE="localtest/response.json"
echo "👉 Zipping Lambda function..."
zip -r $ZIP_FILE lambda_function.py > /dev/null
echo "👉 Deleting existing Lambda function (if exists)..."
awslocal lambda delete-function --function-name $LAMBDA_NAME 2> /dev/null || true
echo "👉 Creating new Lambda function..."
awslocal lambda create-function \
--function-name $LAMBDA_NAME \
--runtime python3.13 \
--handler $HANDLER \
--role $ROLE_ARN \
--zip-file fileb://$ZIP_FILE
echo "👉 Invoking Lambda function..."
awslocal lambda invoke --function-name $LAMBDA_NAME $RESPONSE_FILE > /dev/null
echo "👉 Lambda function output:"
cat $RESPONSE_FILE
echo "✅ Test completed."