Deploy to AWS
The function deploys as a container image. The Amazon.Lambda.Tools CLI builds the image, pushes it to Amazon ECR and creates or updates the function in one go.
-
Install the CLI.
Terminal window dotnet tool install -g Amazon.Lambda.Tools -
Fill in
src/Presentation/aws-lambda-tools-defaults.json. The template leavesprofileandregionempty on purpose. We don’t know where you live.{"profile": "default","region": "ap-southeast-2","configuration": "Release","package-type": "image","function-memory-size": 256,"function-timeout": 30,"image-command": "Presentation::Acme.Reviews.Presentation.LambdaFunction.Handler::GetMovies"} -
Deploy.
Terminal window dotnet lambda deploy-function --project-location ./src/PresentationThe CLI asks for a function name and an IAM role the first time.
-
Invoke it for real.
Terminal window aws lambda invoke --function-name acme-reviews-get-movies \--cli-binary-format raw-in-base64-out --payload '{"limit":5}' response.json
One image, many functions
Section titled “One image, many functions”Each Lambda function runs one handler method. To deploy GetAuthors and GetReviews as well, deploy the same image again with a different image-command and function name. They share the code but scale and bill separately.
Settings worth a look
Section titled “Settings worth a look”| Setting | Template default | Why you might change it |
|---|---|---|
function-memory-size |
256 MB | Lambda gives you CPU in proportion to memory, so more memory often means a faster cold start |
function-timeout |
30 seconds | The handler stops its work when the invocation is about to run out of time, so set this to what your callers will wait for |