I try to create, using SAM CLI, inline Lambda function code.
I have the following template for my Inline function:
HealthFunction:
Type: 'AWS::Serverless::Function'
Properties:
PackageType: Zip
Runtime: nodejs20.x
Handler: index.handler
InlineCode: |
export const handler = (event) => {
return { statusCode: 200 };
}
Timeout: 30
Description: 'Health Lambda function'
Events:
Api:
Type: HttpApi
Properties:
ApiId: !Ref AwsApiGateway
Path: /health
Method: GET
And I just run sam local start-api. Then I get an error:
Initializing the lambda functions containers.
Lambda functions containers initialization failed because of expected str, bytes or os.PathLike object, not NoneType
Error: Lambda functions containers initialization failed
It seems like SAM wants CodeUri property (I assume?), but according to documentation:
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-inlinecode
It is OK to keep CodeUri empty as long as InlineCode is defined.
So where is the problem here?