-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Describe the bug
According to the docs for "AWS::Serverless::Function" the "ImageUri" property can be set if the image has already been pushed to somewhere like ECR (https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-imageuri).
The behavior I'm seeing with the command "lambda deploy-serverless" is that it treats the "ImageUri" like a local path as if it's trying to build the image and push it.
Expected Behavior
The command should result in the function being successfully deployed by the CloudFormation stack.
Current Behavior
The following error appears:
Processing CloudFormation resource <Function Name>
Initiate packaging of <ImageUri> for resource
Directory that the field <Function Name>/CodeUri-Or-ImageUri is pointing doesn't exist
Reproduction Steps
- Initialize the hello world sample:
sam init --package-type Image --base-image amazon/dotnet6-base
- Manually build and deploy the Dockerfile to somewhere like ECR.
- Update the template.yaml file to look like this (replace the <ImageUri> with the deployed image URI):
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Template to test bug with ImageUri
Globals:
Function:
Timeout: 10
MemorySize: 128
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: <ImageUri>
4, Run the "dotnet lambda deploy-serverless" command (will need a S3 bucket):
dotnet lambda deploy-serverless --s3-bucket "some-bucket-for-testing-bug" --s3-prefix "bug/" --stack-name "test-bug" --template "template.yaml"
Possible Solution
It seems like the packaging step should be skipped for Lambda Functions that have an ImageUri set without any metadata.
Additional Information/Context
No response
Targeted .NET platform
6.0.302
CLI extension version
| Package Id | Version | Commands |
|---|---|---|
| amazon.lambda.tools | 5.6.3 | dotnet-lambda |
| dotnet-ef | 6.0.8 | dotnet-ef |
Environment details (OS name and version, etc.)
macOS Monterey Version 12.6