aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 86 forks source link

Fixed an issue lambda deploy-serverless command tries to build image when ImageUri is set in template without any Metadata. #272

Closed ashishdhingra closed 1 year ago

ashishdhingra commented 1 year ago

Issue #, if available: #264

Description of changes: Fixed an issue lambda deploy-serverless command tries to build image when ImageUri is set in template without any Metadata.

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..

In customer reported scenario, metadata is not present in YAML (orJSON) template. In such case, it should not try to build the Docker image locally, instead should use the ImageUri set in the CloudFormation template. Currently, before this fix, it tries to validate the ImageUri as local path and fails the validation check.

NOTE: We could have added a validation check to verify if image pointed out by the ImageUri exists in ECR, however, there is no API to get image by ImageUri.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

ashishdhingra commented 1 year ago

We are going to need a test that we can use a template that has an image uri set to an already pushed image.

@normj Added tests for YAML and JSON template.

Could you please advise on the following:

Thanks, Ashish