diff --git a/backend/README.md b/backend/README.md index 4d5a68ef..439618c0 100644 --- a/backend/README.md +++ b/backend/README.md @@ -120,7 +120,27 @@ Now you can run the script with ./run_lambda_local.sh ``` -Then run the script with the following command: +In order to make a request to it, there is a specific format the request must be in, to +emuate lambda. If using postman, the url you want is `http://localhost:8000/2015-03-31/functions/function/invocations` +and you need to pass a body like this: + +```json +{ + "httpMethod": "POST", + "body": "{\"portfolio_id\": 4, \"housing_type\": \"Private\", \"goal\": \"Increase EPC\", \"goal_value\": \"C\", \"trigger_file_path\": \"2/4/portfolio_plan_properties-20230724T093542483Z.csv\"}", + "path": "/v1/plan/trigger", + "resource": "/", + "headers": { + "Accept": "*/*", + "Content-Type": "application/json", + "Authorization": "Bearer YOUR_TOKEN_HERE", + "x-api-key": "YOUR_API_KEY_HERE" + }, + "requestContext": {}, + "multiValueQueryStringParameters": null +} + +``` ```commandline diff --git a/run_lambda_local.sh b/run_lambda_local.sh index b6bba656..abcd5633 100755 --- a/run_lambda_local.sh +++ b/run_lambda_local.sh @@ -4,11 +4,11 @@ IMAGE_NAME="fastapi-lambda-image" TAG="test" PORT="8000" -RIE_PATH="~/.aws-lambda-rie" +RIE_DIR="$HOME/.aws-lambda-rie" DOCKER_ENTRYPOINT="$RIE_PATH/aws-lambda-rie" DOCKER_CMD="/usr/local/bin/python -m awslambdaric backend.app.main.handler" ENV_FILE_PATH="backend/.env" -AWS_CREDENTIALS_PATH="~/.aws/credentials" +AWS_CREDENTIALS_PATH="$HOME/.aws/credentials" # Step 1: Download the AWS Lambda Runtime Interface Emulator if it doesn't exist if [ ! -f "$RIE_PATH/aws-lambda-rie" ]; then @@ -27,9 +27,9 @@ echo "Starting the Docker container..." CONTAINER_ID=$(docker run -d \ --env-file $ENV_FILE_PATH \ -v $AWS_CREDENTIALS_PATH:/root/.aws/credentials \ - -v $RIE_PATH:/aws-lambda \ + -v "$RIE_DIR:/aws-lambda" \ -p $PORT:8080 \ - --entrypoint $DOCKER_ENTRYPOINT \ + --entrypoint "/aws-lambda/aws-lambda-rie" \ $IMAGE_NAME:$TAG $DOCKER_CMD) # Output information