Closed boozedog closed 8 months ago
Thanks @boozedog for raising this issue. Could you please share your template with us so we can investigate your problem.
Thanks @boozedog for raising this issue. Could you please share your template with us so we can investigate your problem.
sure it is from the helloworld sample
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
lambda-sam
Sample SAM Template for lambda-sam
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
Metadata:
DockerTag: nodejs18.x-v1
DockerContext: ./hello-world
Dockerfile: Dockerfile
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
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
@moelasmar
@moelasmar i should also point out that sam build
works fine but I want the live editing feature so I don't want to build
prior to start-api
@moelasmar any thoughts?
Hi @boozedog ,
As far as I understand, you want to run sam local start-api
but you don't want to build it before since you want the live editing feature. That will work with ZIP lambda functions with interpreted runtimes, since we just mount the source folder and it let's you to live edit your code.
However the template you have above is a IMAGE type lambda function, which needs to be build before running it (we need the local docker image to invoke). For that reason, this won't work. You can either switch using a ZIP lambda function, or you can test in the cloud with sam sync
command.
Closing this issue since it's been inactive for a while. Feel free to try out @mndeveci's suggestions and open a new issue if you still have questions/concerns.
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.
@mndeveci Your explanation of this issue makes sense.
After doing a sam build
, the output from sam local start-api
states:
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. If you used sam build before
running local commands, you will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI if you update your AWS SAM template
At the very minimum the output message should reflect reality, which is one does need to need to rebuild/restart/reload when using container images.
Description:
Steps to reproduce:
Observed result:
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
:SAM CLI, version 1.100.0
Add --debug flag to command you are running