Skip to content

local development not working? #587

Open
@tarasglek

Description

@tarasglek

I tried deno-zip, fastapi-zip, rust-actix-web-zip/

I'm able to sam build, sam deploy, but local env does not work for me
In examples/fastapi-zip/

sam local start-api  --debug
2025-03-26 10:16:30,286 | No config file found in this directory.
2025-03-26 10:16:30,287 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/samconfig.toml'
2025-03-26 10:16:30,287 | Config file location: /home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/samconfig.toml
2025-03-26 10:16:30,288 | Config file '/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/samconfig.toml' does not exist
2025-03-26 10:16:30,289 | Using SAM Template at /home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/template.yaml
2025-03-26 10:16:30,297 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/samconfig.toml'
2025-03-26 10:16:30,297 | Using config file: samconfig.toml, config environment: default
2025-03-26 10:16:30,298 | Expand command line arguments to:
2025-03-26 10:16:30,298 | --template_file=/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/template.yaml --host=127.0.0.1 --port=3000 --static_dir=public
--layer_cache_basedir=/home/taras/.aws-sam/layers-pkg --container_host=localhost --container_host_interface=127.0.0.1
2025-03-26 10:16:30,342 | local start-api command is called
2025-03-26 10:16:31,358 | No Parameters detected in the template
2025-03-26 10:16:31,367 | Sam customer defined id is more priority than other IDs. Customer defined id for resource FastAPIFunction is FastAPIFunction
2025-03-26 10:16:31,367 | There is no customer defined id or cdk path defined for resource ServerlessHttpApi, so we will use the resource logical id as the resource id
2025-03-26 10:16:31,368 | 0 stacks found in the template
2025-03-26 10:16:31,368 | No Parameters detected in the template
2025-03-26 10:16:31,375 | Sam customer defined id is more priority than other IDs. Customer defined id for resource FastAPIFunction is FastAPIFunction
2025-03-26 10:16:31,375 | There is no customer defined id or cdk path defined for resource ServerlessHttpApi, so we will use the resource logical id as the resource id
2025-03-26 10:16:31,376 | 2 resources found in the stack
2025-03-26 10:16:31,376 | Found Serverless function with name='FastAPIFunction' and CodeUri='FastAPIFunction'
2025-03-26 10:16:31,376 | --base-dir is not presented, adjusting uri FastAPIFunction relative to
/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/template.yaml
2025-03-26 10:16:31,377 | Found '1' API Events in Serverless function with name 'FastAPIFunction'
2025-03-26 10:16:31,378 | Detected Inline Swagger definition
2025-03-26 10:16:31,378 | Parsing Swagger document using 3.0 specification
2025-03-26 10:16:31,378 | Found '0' authorizers in resource 'ServerlessHttpApi'
2025-03-26 10:16:31,378 | Lambda function integration not found in Swagger document at path='$default' method='x-amazon-apigateway-any-method'
2025-03-26 10:16:31,379 | Found '0' APIs in resource 'ServerlessHttpApi'
2025-03-26 10:16:31,379 | authorizer not found or disabled, returning early
2025-03-26 10:16:31,379 | Removed duplicates from '0' Explicit APIs and '1' Implicit APIs to produce '1' APIs
2025-03-26 10:16:31,379 | 1 APIs found in the template
2025-03-26 10:16:31,381 | add catch-all route
2025-03-26 10:16:31,382 | Mounting FastAPIFunction at http://127.0.0.1:3000$default [X-AMAZON-APIGATEWAY-ANY-METHOD]
2025-03-26 10:16:31,382 | 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. If you used sam build before running local commands, you will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI
if you update your AWS SAM template
2025-03-26 10:16:31,382 | Localhost server is starting up. Multi-threading = True
2025-03-26 10:16:31,383 | Setting SIGTERM interrupt handler
2025-03-26 10:16:31 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:3000
2025-03-26 10:16:31 Press CTRL+C to quit
curl localhost:3000
{"message":"Internal server error"}

Rest of logs from sam

2025-03-26 10:16:53,045 | Constructed Event Version 2.0 to invoke Lambda. Event: {'version': '2.0', 'routeKey': '$default', 'rawPath': '/', 'rawQueryString': '', 'cookies': [], 'headers':
{'Host': 'localhost:3000', 'User-Agent': 'curl/8.5.0', 'Accept': '*/*', 'X-Forwarded-Proto': 'http', 'X-Forwarded-Port': '3000'}, 'requestContext': {'accountId': '123456789012', 'apiId':
'1234567890', 'http': {'method': 'GET', 'path': '/', 'protocol': 'HTTP/1.1', 'sourceIp': '127.0.0.1', 'userAgent': 'Custom User Agent String'}, 'requestId':
'0074744c-2b9e-4cd9-83a0-4b7ef19a88a8', 'routeKey': '$default', 'stage': '$default', 'time': '26/Mar/2025:10:16:30 +0000', 'timeEpoch': 1742984190, 'domainName': 'localhost',
'domainPrefix': 'localhost'}, 'body': '', 'pathParameters': {}, 'stageVariables': None, 'isBase64Encoded': False}
2025-03-26 10:16:53,047 | Found one Lambda function with name 'FastAPIFunction'
2025-03-26 10:16:53,047 | Invoking run.sh (python3.12)
2025-03-26 10:16:53,047 | Loading AWS credentials from session with profile 'None'
2025-03-26 10:16:53,599 | Resolving code path. Cwd=/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build,
CodeUri=/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/FastAPIFunction
2025-03-26 10:16:53,600 | Resolved absolute path to code is /home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/FastAPIFunction
2025-03-26 10:16:53,600 | Resolving code path. Cwd=/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build,
CodeUri=/home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/FastAPIFunction
2025-03-26 10:16:53,600 | Resolved real code path to /home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/FastAPIFunction
2025-03-26 10:16:53,601 | Code /home/taras/Downloads/aws-lambda-web-adapter/examples/fastapi-zip/.aws-sam/build/FastAPIFunction is not a zip/jar file
2025-03-26 10:16:54,225 | Cleaning all decompressed code dirs
2025-03-26 10:16:54,225 | Exception on / [GET]
Traceback (most recent call last):
  File "flask/app.py", line 1511, in wsgi_app
  File "flask/app.py", line 919, in full_dispatch_request
  File "flask/app.py", line 917, in full_dispatch_request
  File "flask/app.py", line 902, in dispatch_request
  File "samcli/local/apigw/local_apigw_service.py", line 731, in _request_handler
  File "samcli/local/apigw/local_apigw_service.py", line 619, in _invoke_lambda_function
  File "samcli/commands/local/lib/local_lambda.py", line 169, in invoke
  File "samcli/lib/telemetry/metric.py", line 325, in wrapped_func
  File "samcli/local/lambdafn/runtime.py", line 229, in invoke
  File "samcli/local/lambdafn/runtime.py", line 100, in create
  File "samcli/local/docker/lambda_container.py", line 106, in __init__
  File "samcli/local/docker/lambda_container.py", line 261, in _get_image
  File "samcli/local/docker/lambda_image.py", line 203, in build
  File "samcli/local/layers/layer_downloader.py", line 77, in download_all
  File "samcli/local/layers/layer_downloader.py", line 111, in download
  File "samcli/local/layers/layer_downloader.py", line 160, in _fetch_layer_uri
  File "samcli/local/layers/layer_downloader.py", line 141, in _fetch_layer_uri
  File "botocore/client.py", line 569, in _api_call
  File "botocore/client.py", line 1023, in _make_api_call
botocore.errorfactory.InvalidParameterValueException: An error occurred (InvalidParameterValueException) when calling the GetLayerVersion operation: Invalid Layer name:
arn:aws:lambda:us-east-1:753240598075:layer:LambdaAdapterLayerX86
2025-03-26 10:16:54,227 | Lambda execution failed (<InternalServerError '500: Internal Server Error'>,)
2025-03-26 10:16:54 127.0.0.1 - - [26/Mar/2025 10:16:54] "GET / HTTP/1.1" 502 -
sam --version
SAM CLI, version 1.135.0

Tried examples from HEAD and 0.9.0 release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions