sam local start-api detached mode
See original GitHub issueDescribe your idea/feature/enhancement
Allow sam local start-api
to run detached
Proposal
While SAM is great for local development it can fall short for CI or even test commands. In order to run tests automatically against my api-gateway I need to run sam local start-api
this command continues running until I press Ctrl-C. This works well for local development but I would like to script this out into a CI that will allow me to run integration tests without deploying to aws.
Things to consider:
-
Will this require any updates to the SAM Spec
- No, as far as I know, this should require any updates to the spec.
-
Additional arguments/commands
- By adding a detached mode that also means there must be a non-interrupt way to stop the api. I suggest
sam local stop-api
as a way to stop the api. This command would be dependent on the directory and template that is running and thus the running instance would be a singleton. - I would suggest
-d
as this would follow the docker command scheme and be more familiar to developers.
- By adding a detached mode that also means there must be a non-interrupt way to stop the api. I suggest
Issue Analytics
- State:
- Created 5 years ago
- Reactions:26
- Comments:7 (2 by maintainers)
Top Results From Across the Web
sam local start-api detached mode · Issue #1012 - GitHub
In order to run tests automatically against my api-gateway I need to run sam local start-api this command continues running until I press...
Read more >sam local start-api - AWS Serverless Application Model
Allows you to run your serverless application locally for quick development and testing. When you run this command in a directory that contains...
Read more >sam local start-api - Fig.io
Sets up a local endpoint you can use to test your API. ... When specified, Lambda function will start in debug mode and...
Read more >Invoking Lambda functions Locally with AWS SAM
If you don't know about docker -d means docker runs the container in detached mode. -p means mapping ports to 8000 in the...
Read more >How to run sam local start-api - CircleCI Discuss
When I run sam local start-api in the jbo, I always get Build was canceled. My configuration is like this. Main purpose is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any updates on this?
I think this would be really helpful. I have similar use cases, my current method I am testing (which might be a little dodgy) is to send the
sam
command to the background and redirect all logs to prevent interference.This keeps the local API active while retaining control of the shell. So you could run it multiple times, or re-use the shell to run tests against the local API.
Potential issue when it comes to stopping the background processes if you have multiple running and need to be careful with which you kill.