Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Image Build/Rebuild for sam local start-api ? #6678

Closed
kPOWz opened this issue Feb 12, 2024 · 3 comments
Closed

Prevent Image Build/Rebuild for sam local start-api ? #6678

kPOWz opened this issue Feb 12, 2024 · 3 comments
Labels
area/local/start-api sam local start-api command blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days type/question

Comments

@kPOWz
Copy link

kPOWz commented Feb 12, 2024

We love sam local start-api, it has allowed us to change some developer workflows that mean a lot for our DUX/quality of life.

We are leveraging sam local start-api with a CDKv2 IaC setup

We've noticed over time when we send a succession of API calls to the SAM local URL/server, the Docker container is rebuilt each time. Is this necessary ? Is there any built in way/option to avoid this?

Scenario:
An api with 5 endpoints running locally via sam local start-api
issue 1 API call to each of the 5 endpoints back to back

Current:
Container is created & exits 5 times
example:
Invoking src.handler.handler (python3.10)
PowertoolsLayer17979D4B is a local Layer in the template
cvmlinspectingservicecommonsA6DCC1FF is a local Layer in the template
Building image............................
Using local image: samcli/lambda-python:3.10-arm64-3de4efa8f0a02d608ba35a629.

Desired:
Container is created & exits 1 times

@kPOWz kPOWz added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Feb 12, 2024
@hawflau hawflau transferred this issue from aws/serverless-application-model Feb 12, 2024
@hawflau hawflau added type/question area/local/start-api sam local start-api command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Feb 12, 2024
@hawflau
Copy link
Contributor

hawflau commented Feb 12, 2024

Hey @kPOWz thanks for raising the issue. I've transferred the issue here (aws/aws-sam-cli) since this is a CLI-specific question.

sam local start-api creates one container for each Lambda Function defined in your template. Are your 5 endpoints pointing to 5 different Lambda Functions? If so, this is why you saw 5 containers are created. You can use --warm-containers EAGER to create all containers at startup. Or --warm-containers LAZY to prevent created containers from exiting. See here for more info.

Please let us know if you have further question.

@hawflau hawflau added the blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days label Feb 12, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Mar 6, 2024

Closing this issue since it has been inactive for a while. Please feel free to try out @hawflau's suggestions and one a new issue if you still have questions/concerns.

@hnnasit hnnasit closed this as completed Mar 6, 2024
Copy link
Contributor

github-actions bot commented Mar 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/local/start-api sam local start-api command blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days type/question
Projects
None yet
Development

No branches or pull requests

3 participants