sam local invoke with pre-built image
Description
My function uses dependencies from a private Github repository and I have to --mount feature of BuildKit to build Docker image, but SAM does not support BuildKit. Then I have to build image separately first and then define that pre-built image in field ImageUri of template.yaml.
Issue happens when I test on local, SAM must build on fly image to run function -> It can not build image, then can not invoke local.
Is there any way to invoke sam local for this use case? Or SAM does not support that?
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Resources:
FormDataExtractionFunction:
# No MetaData definition
Type: AWS::Serverless::Function
Properties:
FunctionName: "my-lambda-function"
PackageType: Image
ImageUri: "library/test-lambda:latest" # Specify local image
...
Not 100% sure, but try editing the AWS::Serverless::Function resource in your template.yaml:
Remove
Metadata:
Dockerfile: Dockerfile
DockerContext: ./functions/<somefunc>
Set you local prebuilt image to
ImageUri: myimage:latest
**update Sadly you won't be able to run and debug it using vscode/pycharm aws toolkit, without the metadata section.
Do you mind providing a sample image function any step to reproduce?