Failed to attach debugger
Hi, I am following this tutorial: https://docs.aws.amazon.com/en_pv/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging-python.html
but i do not know how to step through the code. After all configurations is done I am doing:
- run
sam local start-api -d 5890 - hit the URL 127.0.0.1:3000/hello from browser
- start debugger in VSC: I get "failed to attach. Connection refused"
Webpage gets good answer. What am I missing to step through the code?
So I think I've solved. Can it be a bug in the doc because in the template.yaml is required to add the sub-path?
CodeUri: hello_world/**build**
Did you use a boilerplate application, or your own application? Feel free to redact anything sensitive if using your own code, but could be useful to see the template.yaml that was used.
yes boilerplate.
Here the template where I've made the modification above:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
python-debugging
Sample SAM Template for python-debugging
# 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 # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/build
Handler: app.lambda_handler
Runtime: python3.6
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
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
Hm, i get the same error, but making the change you suggest just breakes "sam build" command and doesn't fix connection refused debugging error
Alternatively you can sam build and then do start-api, it will do the codeuri changes for you.
Closing this issue.