Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sam local start-api gives error while testing SAM application in local

Hi i have a sam application which one lambda function and can be invoked from rest endpoint which is working as expected but when i try to test the sam application locally using sam local start-lambda or sam local start-api or sam local invoke i get the error as :

    self.connect()
  File "C:\Users\divyanayan.awasthi\AppData\Roaming\Python\Python37\site-packages\docker\transport\npipeconn.py", line 31, in connect
    sock.connect(self.npipe_path)
  File "C:\Users\divyanayan.awasthi\AppData\Roaming\Python\Python37\site-packages\docker\transport\npipesocket.py", line 22, in wrapped
    return f(self, *args, **kwargs)
  File "C:\Users\divyanayan.awasthi\AppData\Roaming\Python\Python37\site-packages\docker\transport\npipesocket.py", line 50, in connect
    win32pipe.WaitNamedPipe(address, self._timeout)
pywintypes.error: (2, 'WaitNamedPipe', 'The system cannot find the file specified.')

Sam version used

SAM CLI, version 0.7.0

Is this because i dont have a docker running in my local or some other configuration is required .i have one .py class and template.yml file for SAM application.

like image 325
divyanayan awasthi Avatar asked Dec 05 '18 08:12

divyanayan awasthi


People also ask

What does Sam local start-API do?

Allows you to run your serverless application locally for quick development and testing. When you run this command in a directory that contains your serverless functions and your AWS SAM template, it creates a local HTTP server that hosts all of your functions.

How do I test AWS locally?

You can use the AWS SAM CLI to locally test your AWS CDK applications by running the following commands from the project root directory of your AWS CDK application: sam local invoke. sam local start-api. sam local start-lambda.

How do I run lambda locally with Sam?

You can invoke your AWS Lambda function locally by using the sam local invoke AWS SAM CLI command and providing the function's logical ID and an event file. Alternatively, sam local invoke also accepts stdin as an event. For more information about events, see Event in the AWS Lambda Developer Guide.


1 Answers

Yes we need to install docker locally then sam local works as expected .if you are running sam local on windows then there might a problem to install docker installer as it needs Windows 10 Pro or enterpise version to install.

In case you dont have the above windows configuration then install docker toolbox

https://docs.docker.com/toolbox/toolbox_install_windows/

like image 68
divyanayan awasthi Avatar answered Nov 15 '22 11:11

divyanayan awasthi