stackery local start-api command allows you to run a local HTTP server. You can invoke functions triggered by your API, and can start any function in your stack.
Only follow this guide once you have set up your local serverless development environment using our local development guide.
Running a Local API
To use the
stackery local start-api command, your stack needs to include an API resource and be deployed in order to interact with additional cloud resources. In this example, we will be using the
local-demo stack from the local serverless development doc mentioned above:
- In your terminal or shell,
cdto the root directory of your
- Run the following command to start your local api:
stackery local start-api --stack-name local-demo --env-name test --aws-profile <your aws profile name>
Note that unlike the
stackery local invoke command, we do not need to designate the function ID, even if there are multiple functions in the stack. There is also no need for the
--watch flag, as the HTTP server keeps running until you stop it.
You should see a message like this that gives you your HTTP address:
- To stop running the local server, enter
CTRL + C
stackery local api command uses port 3000 by default. You can change the port by appending a
--port flag followed by your designated port number.
The default host is
127.0.0.1. If you would like to change the host, append a
--host flag to the command.
template.yaml does not reside in the repo's root directory, you can designate its location relative to the root using the
If you are using a debugger, you can pass debugging values as flags and they are passed through directly to the SAM CLI. The following flags are supported:
Read the AWS docs on sam local start-api for more information about local api configuration.