Hi Nicolas,
Excellent work thank you so much!
I was trying to run it locally, everything seemed fine but I cannot interact with local sam.
here are the steps that I ran:
- updated some dependencies from 0.0.24-alpha to 0.0.25-alpha because it seems 0.0.24-alpha are not available anymore
- build and deploy the first time to create was resources
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
make build
sam deploy --stack-name serverless-rust-demo --resolve-s3 --capabilities CAPABILITY_IAM
sam local start-api --debug --profile default
-try to insert an item
curl -X PUT -H "Content-Type: application/json" -d '{"id"": "i1", "name": "name1", "price": "1"}' http://localhost:3000/i1
some resulting logs
2021-11-17 06:59:10,537 | Mounting PutProductFunction at http://127.0.0.1:3000/{id} [PUT]
2021-11-17 06:59:10,537 | Mounting DeleteProductFunction at http://127.0.0.1:3000/{id} [DELETE]
2021-11-17 06:59:10,537 | Mounting GetProductFunction at http://127.0.0.1:3000/{id} [GET]
2021-11-17 06:59:10,537 | Mounting GetProductsFunction at http://127.0.0.1:3000/ [GET]
2021-11-17 06:59:10,537 | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2021-11-17 06:59:10,537 | Localhost server is starting up. Multi-threading = True
2021-11-17 06:59:10 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2021-11-17 06:59:19,628 | Constructed String representation of Event Version 2.0 to invoke Lambda. Event: {"version": "2.0", "routeKey": "PUT /<id>", "rawPath": "/i1", "rawQueryString": "", "cookies": [], "headers": {"Host": "127.0.0.1:3000", "User-Agent": "curl/7.68.0", "Accept": "*/*", "Content-Type": "application/json", "Content-Length": "44", "X-Forwarded-Proto": "http", "X-Forwarded-Port": "3000"}, "queryStringParameters": {}, "requestContext": {"accountId": "123456789012", "apiId": "1234567890", "http": {"method": "PUT", "path": "/i1", "protocol": "HTTP/1.1", "sourceIp": "127.0.0.1", "userAgent": "Custom User Agent String"}, "requestId": "d448b162-7c1c-4bad-bba2-0f10bf9257f4", "routeKey": "PUT /<id>", "stage": "$default", "time": "16/Nov/2021:19:59:10 +0000", "timeEpoch": 1637092750, "domainName": "localhost", "domainPrefix": "localhost"}, "body": "{\"id\"\": \"i1\", \"name\": \"name1\", \"price\": \"1\"}", "pathParameters": {"id": "i1"}, "stageVariables": null, "isBase64Encoded": false}
2021-11-17 06:59:19,629 | Found one Lambda function with name 'PutProductFunction'
2021-11-17 06:59:19,629 | Invoking bootstrap (provided.al2)
2021-11-17 06:59:19,629 | Environment variables overrides data is standard format
2021-11-17 06:59:19,629 | Loading AWS credentials from session with profile 'default'
2021-11-17 06:59:19,639 | Resolving code path. Cwd=/home/pc/Documents/funspace/serverless-rust-demo-main, CodeUri=/home/pc/Documents/funspace/serverless-rust-demo-main/build/put-product
2021-11-17 06:59:19,639 | Resolved absolute path to code is /home/pc/Documents/funspace/serverless-rust-demo-main/build/put-product
2021-11-17 06:59:19,639 | Code /home/pc/Documents/funspace/serverless-rust-demo-main/build/put-product is not a zip/jar file
2021-11-17 06:59:19,651 | Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided.al2:rapid-1.35.0-arm64.
2021-11-17 06:59:19,651 | Mounting /home/pc/Documents/funspace/serverless-rust-demo-main/build/put-product as /var/task:ro,delegated inside runtime container
2021-11-17 06:59:20,136 | Starting a timer for 5 seconds for function 'PutProductFunction'
START RequestId: ba4e9de5-a60f-499a-9912-74010803ddee Version: $LATEST
{"timestamp":"Nov 16 19:59:20.255","level":"INFO","fields":{"message":"config file not found","path":"~/.aws/config"},"target":"aws_config::profile::parser::source","span":{"name":"load_config_file"},"spans":[{"name":"get_store"},{"name":"load_config_file"}]}
{"timestamp":"Nov 16 19:59:20.270","level":"INFO","fields":{"message":"config file loaded","path":"~/.aws/config","size":"0"},"target":"aws_config::profile::parser::source","span":{"name":"load_config_file"},"spans":[{"name":"get_store"},{"name":"load_config_file"}]}
{"timestamp":"Nov 16 19:59:20.271","level":"INFO","fields":{"message":"config file not found","path":"~/.aws/credentials"},"target":"aws_config::profile::parser::source","span":{"name":"load_credentials_file"},"spans":[{"name":"get_store"},{"name":"load_credentials_file"}]}
{"timestamp":"Nov 16 19:59:20.271","level":"INFO","fields":{"message":"config file loaded","path":"~/.aws/credentials","size":"0"},"target":"aws_config::profile::parser::source","span":{"name":"load_credentials_file"},"spans":[{"name":"get_store"},{"name":"load_credentials_file"}]}
{"timestamp":"Nov 16 19:59:20.273","level":"WARN","fields":{"message":"failed to get selected 'default' profile"},"target":"aws_config::profile::retry_config","span":{"name":"get_store"},"spans":[{"name":"get_store"}]}
{"timestamp":"Nov 16 19:59:20.301","level":"INFO","fields":{"message":"Initializing DynamoDB store with table name: Table"},"target":"products::utils","span":{"name":"get_store"},"spans":[{"name":"get_store"}]}
Error: Error("data did not match any variant of untagged enum LambdaRequest", line: 0, column: 0)
END RequestId: ba4e9de5-a60f-499a-9912-74010803ddee
REPORT RequestId: ba4e9de5-a60f-499a-9912-74010803ddee Init Duration: 0.16 ms Duration: 310.09 msBilled Duration: 400 ms Memory Size: 128 MB Max Memory Used: 128 MB
2021-11-17 06:59:20,734 | Cleaning all decompressed code dirs
2021-11-17 06:59:20,735 | Unable to find Click Context for getting session_id.
2021-11-17 06:59:20,735 | Invalid lambda response received: Lambda response must be valid json
2021-11-17 06:59:20 127.0.0.1 - - [17/Nov/2021 06:59:20] "PUT /i1 HTTP/1.1" 502 -
What am I doing wrong, please?
Thanks