Closed roncrush closed 1 year ago
@roncrush Thanks for opening the issue. I think you are affected feature request https://github.com/aws/aws-extensions-for-dotnet-cli/issues/196. Could you please check and confirm?
Thanks, Ashish
@ashishdhingra Thanks for the quick response. We actually recently updated the Amazon Lambda Tools package as part of our move from Windows to MacOS. The old version we were using was 4.3.0 and this case was working then, which is why I've reported it as a bug.
Hi @roncrush,
Good afternoon.
Issue appears to be reproducible. Below are the steps followed:
sam init --package-type Image --base-image amazon/dotnet6-base
to create project named HelloWorld
by choosing AWS Quick Start Templates
.HelloWorld/src/HelloWorld
directory containing the .csproj
and other files.helloworldtest
.
View push commands
to build and push docker image.<<account-id>>.dkr.ecr.us-east-2.amazonaws.com/helloworldtest:latest
)../../template.yaml
to add the ImageUri
property.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Sample SAM Template for HelloWorld
Globals: Function: Timeout: 10 MemorySize: 128
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
PackageType: Image
ImageUri: <
Outputs:
HelloWorldApi: Description: "API Gateway endpoint URL for Prod stage for Hello World function" Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" HelloWorldFunction: Description: "Hello World Lambda Function ARN" Value: !GetAtt HelloWorldFunction.Arn HelloWorldFunctionIamRole: Description: "Implicit IAM Role created for Hello World function" Value: !GetAtt HelloWorldFunctionRole.Arn
- Executed the command `dotnet lambda deploy-serverless --s3-bucket some-s3-bucket --s3-prefix "bug/" --stack-name "test-bug" --template ../../template.yaml`
Amazon Lambda Tools for .NET Core applications (5.6.3) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Processing CloudFormation resource HelloWorldFunction
Initiate packaging of ./src/HelloWorld for resource HelloWorldFunction
Building Docker image for /Users/<
Timestamp Logical Resource Id Status
3/15/2023 4:19 PM test-bug CREATE_IN_PROGRESS
3/15/2023 4:19 PM HelloWorldFunctionRole CREATE_IN_PROGRESS
3/15/2023 4:19 PM HelloWorldFunctionRole CREATE_IN_PROGRESS
3/15/2023 4:19 PM HelloWorldFunctionRole CREATE_COMPLETE
3/15/2023 4:19 PM HelloWorldFunction CREATE_IN_PROGRESS
3/15/2023 4:19 PM HelloWorldFunction CREATE_IN_PROGRESS
3/15/2023 4:19 PM HelloWorldFunction CREATE_COMPLETE
3/15/2023 4:20 PM ServerlessRestApi CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApi CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApi CREATE_COMPLETE
3/15/2023 4:20 PM HelloWorldFunctionHelloWorldPermissionProd CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApiDeployment47fc2d5f9d CREATE_IN_PROGRESS
3/15/2023 4:20 PM HelloWorldFunctionHelloWorldPermissionProd CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApiDeployment47fc2d5f9d CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApiDeployment47fc2d5f9d CREATE_COMPLETE
3/15/2023 4:20 PM ServerlessRestApiProdStage CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApiProdStage CREATE_IN_PROGRESS
3/15/2023 4:20 PM ServerlessRestApiProdStage CREATE_COMPLETE
3/15/2023 4:20 PM HelloWorldFunctionHelloWorldPermissionProd CREATE_COMPLETE
3/15/2023 4:20 PM test-bug CREATE_COMPLETE
Stack finished updating with status: CREATE_COMPLETE
Output Name Value
HelloWorldFunctionIamRole arn:aws:iam::<
As you could see from the output above, I didn't got the error reported by you. It ignored `ImageUri` property all together and pushed image to a new ECR repository. The reason is that per https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-imageuri, `Building your application with necessary Metadata entries takes precedence over ImageUri, so if you specify both then ImageUri is ignored.`.
Thereafter, I removed `Metadata` entries and re-executed `dotnet lambda deploy-serverless --s3-bucket some-s3-bucket --s3-prefix "bug/" --stack-name "test-bug" --template ../../template.yaml` command. This gave the error reported by you:
Amazon Lambda Tools for .NET Core applications (5.6.3) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Processing CloudFormation resource HelloWorldFunction
Initiate packaging of <
I think the related open feature request https://github.com/aws/aws-extensions-for-dotnet-cli/issues/196 does not document/validates the absence of `Metadata` properties (since it was reported as a feature request), hence is duplicate of this issue.
I would validate if this worked on [Amazon.Lambda.Tools](https://www.nuget.org/packages/Amazon.Lambda.Tools/)) version `4.3.0`. If it does, then we would classify this as a bug instead of a feature request and take it from there.
Thanks,
Ashish
Hey @ashishdhingra
As a temporary fix we ended up downgrading back to 4.3.0
and it started deploying properly. I didn't test with the template.yaml
you've shown, but it did work with the template.yaml
that's on the initial post. When I updated to the latest version of the tool it stopped working again.
I would validate if this worked on Amazon.Lambda.Tools) version
4.3.0
. If it does, then we would classify this as a bug instead of a feature request and take it from there.
This appears to work in version 4.3.0
of Amazon.Lambda.Tools. Closing other open feature request https://github.com/aws/aws-extensions-for-dotnet-cli/issues/196 to track it as part of this issue.
The fix has been released as part of Amazon.Lambda.Tools version 5.6.5
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.
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:
Reproduction Steps
Globals: Function: Timeout: 10 MemorySize: 128
Resources: HelloWorldFunction: Type: AWS::Serverless::Function Properties: PackageType: Image ImageUri:
dotnet lambda deploy-serverless --s3-bucket "some-bucket-for-testing-bug" --s3-prefix "bug/" --stack-name "test-bug" --template "template.yaml"