|
| 1 | +#!/bin/bash |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# Current file variables |
| 4 | +# ----------------------------------------------------------------------------- |
| 5 | +debug=false |
| 6 | +parent_folder="../" |
| 7 | +current_path=$(pwd)/ |
| 8 | +current_path_basename=$(basename $(pwd)) |
| 9 | +current_file_full_path=$0 |
| 10 | +# echo $current_filepath |
| 11 | +current_file_name=$(basename -- "$0") |
| 12 | +# echo $current_filename |
| 13 | +if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then |
| 14 | + current_file_full_path="./${current_file_full_path}" |
| 15 | + current_file_path="./" |
| 16 | +else |
| 17 | + current_file_path="${current_file_full_path/$current_file_name/''}" |
| 18 | +fi |
| 19 | + |
| 20 | +current_file_path_basename=$(basename -- "$current_file_path") |
| 21 | +#echo "xxxxx current_file_path_basename $current_file_path_basename" |
| 22 | + |
| 23 | +if [ -z "$current_file_path_basename" ] || [ $current_file_path = "./" ]; then |
| 24 | +# echo 'aq' |
| 25 | + current_parent_folder="../" |
| 26 | +else |
| 27 | +# echo 'naq' |
| 28 | + current_file_path_basename=$current_file_path_basename/ |
| 29 | + current_parent_folder="${current_file_path/$current_file_path_basename/''}" |
| 30 | +fi |
| 31 | + |
| 32 | + |
| 33 | +if [ debug ]; then |
| 34 | + echo '----------------------------------------' |
| 35 | + echo "$0 - Script variables" |
| 36 | + echo '----------------------------------------' |
| 37 | + echo "current_path: $current_path" |
| 38 | + echo "current_path_basename: $current_path_basename" |
| 39 | + echo "current_file_full_path: $current_file_full_path" |
| 40 | + echo "current_file_name: $current_file_name" |
| 41 | + echo "current_file_path: $current_file_path" |
| 42 | + echo "current_parent_folder: $current_parent_folder" |
| 43 | + echo '----------------------------------------' |
| 44 | +fi |
| 45 | + |
| 46 | +echo '----------------------------------------' |
| 47 | +echo "$0 - Booting lambda" |
| 48 | +echo '----------------------------------------' |
| 49 | +echo 'Installing dependencies...' |
| 50 | +echo "Requirements file: ${current_parent_folder}requirements.txt" |
| 51 | +if test -f ${current_parent_folder}requirements.txt; then |
| 52 | + python3 -m pip install -r ${current_parent_folder}requirements.txt -t ${current_parent_folder}vendor |
| 53 | +# cat ${current_parent_folder}requirements.txt |
| 54 | + echo "requirements..." |
| 55 | +fi |
| 56 | + |
| 57 | +echo "Requirements file: ${current_parent_folder}requirements-vendor.txt" |
| 58 | +if test -f ${current_parent_folder}requirement.s-vendor.txt; then |
| 59 | + python3 -m pip install -r ${current_parent_folder}requirements-vendor.txt -t ${current_parent_folder}vendor |
| 60 | +# cat ${current_parent_folder}requirements-vendor.txt |
| 61 | + echo "requirements vendor..." |
| 62 | +fi |
| 63 | + |
| 64 | +read -p "Press enter to continue..." |
| 65 | + |
| 66 | +#echo 'Creating resource dependencies...' |
| 67 | +#echo "${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh" |
| 68 | + |
| 69 | +if test -f "${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh"; then |
| 70 | + |
| 71 | + if test -f ${current_parent_folder}.projectrc; then |
| 72 | + source ${current_parent_folder}.projectrc |
| 73 | + fi |
| 74 | + |
| 75 | + if [ -z "$APP_LAMBDA_NAME" ]; then |
| 76 | + echo 'APP_LAMBDA_NAME not defined' |
| 77 | + exit 1 |
| 78 | + else |
| 79 | + echo '----------------------------------------' |
| 80 | + echo "$0 - Creating the lambda: $APP_LAMBDA_NAME" |
| 81 | + echo '----------------------------------------' |
| 82 | + ${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh $current_filename_path $APP_LAMBDA_NAME |
| 83 | + |
| 84 | + read -p "Press enter to continue..." |
| 85 | + |
| 86 | + if test $APP_LAMBDA_EVENT_SOURCE = true;then |
| 87 | + echo '----------------------------------------' |
| 88 | + echo "$0 - Creating the event source: $APP_LAMBDA_NAME" |
| 89 | + echo '----------------------------------------' |
| 90 | + ${current_parent_folder}scripts/localstack/lambda/create-event-source-mapping.sh $APP_LAMBDA_NAME $APP_QUEUE |
| 91 | + else |
| 92 | + echo 'There is no event source for this lambda' |
| 93 | + fi |
| 94 | + fi |
| 95 | +else |
| 96 | + echo "File not found: ${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh" |
| 97 | +fi |
0 commit comments