Skip to content

sam local invoke with pre-built image #7993

Closed

Description

@hikouki-gumo

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

...

Activity

  1. added
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on Apr 18, 2025
  2. royassis commented on Apr 27, 2025

    @royassis

    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.

  3. vicheey commented on Jun 23, 2025

    @vicheey
    Contributor

    Do you mind providing a sample image function any step to reproduce?

  4. added
    blocked/close-if-inactiveBlocked for >14 days with no response, will be closed if still inactive after 7 days
    and removed
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on May 12, 2026
  5. reedham-aws commented on May 28, 2026

    @reedham-aws
    Contributor

    Closing this issue as inactive, feel free to reopen if you have any more questions.

  6. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    Comments on closed issues are hard for our team to see.
    If you need more assistance, please either tag a team member or open a new issue that references this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/close-if-inactiveBlocked for >14 days with no response, will be closed if still inactive after 7 days

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions