Closed davidjb closed 5 months ago
Thanks @davidjb. This particular validation is relevant to subsequent local commands, so to me this seems like something worth implementing. I will take it to the team for prioritization.
The expectation of this issue was the feature request in #3244. We will track that feature request there.
For this issue specifically, our fix is to catch and handle the container creation error and display an error message. Customers can also run sam validate --lint
to validate their template, although not the exact functionality suggested in #3244
Patch is released in v1.115.0. Closing
Description:
As described in https://github.com/aws/aws-sam-cli/issues/6110, SAM (
build
,local invoke
, etc) doesn't attempt to validate values for functionMemorySize
.This value should be with 128 and 10240 MB according to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-memorysize but values such as
1
,-1
, etc are allowed. For a Docker-based local invocation, a value < 6 MB will cause Docker to refuse to start the container.Steps to reproduce:
template.yml
:Observed result:
sam build MyFunction
succeeds, despiteMemorySize: 1
being an invalid value. Trying to invokesam local invoke MyFunction
fails because Docker requires a minimum of 6MB of memory allocated:Expected result:
Validation errors would be shown when the SAM config is loaded, before the values are used for building and builds would not succeed when invalid values are used.
As per https://github.com/aws/aws-sam-cli/issues/3244, this value will be validated but only at deploy time, assuming you're able to create a configuration that is able to be built but not deploy.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)