bug: error when re-deploying a lambda function
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
I start localstack for the first time and I do a sls deploy --local and everything goes ok. But when I do a change in my lambda function and I do sls deploy --local again it throw the following error:
Error:
DELETE_FAILED: ApiGatewayDeployment1702839928281 (AWS::ApiGateway::Deployment)
An error occurred (BadRequestException) when calling the DeleteDeployment operation: Active stages pointing to this deployment must be moved or deleted
Expected Behavior
To re deploy the lambda function correctly.
How are you starting LocalStack?
With the localstack script
Steps To Reproduce
- Run localstack start
- Do a sls deploy --local
- Do a change in a lambda function
- Do a sls deploy --local again
- Should see the error
Environment
- OS: macOS (Sonoma 14.1.2)
- LocalStack: 3.0.2
Anything else?
No response
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.
following....
Seeing this same issue:
Error:
DELETE_FAILED: ApiGatewayDeployment1705955950755 (AWS::ApiGateway::Deployment)
An error occurred (BadRequestException) when calling the DeleteDeployment operation: Active stages pointing to this deployment must be moved or deleted
Here is what is in the docker log:
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/cloudformation/engine/template_deployer.py", line 1177, in _run
2024-01-22 14:41:16 self.do_apply_changes_in_loop(changes, stack)
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/cloudformation/engine/template_deployer.py", line 1251, in do_apply_changes_in_loop
2024-01-22 14:41:16 self.apply_change(change, stack=stack)
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/cloudformation/engine/template_deployer.py", line 1366, in apply_change
2024-01-22 14:41:16 progress_event = executor.deploy_loop(resource_provider_payload) # noqa
2024-01-22 14:41:16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/cloudformation/resource_provider.py", line 719, in deploy_loop
2024-01-22 14:41:16 event = self.execute_action(resource_provider, payload)
2024-01-22 14:41:16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/cloudformation/resource_provider.py", line 801, in execute_action
2024-01-22 14:41:16 return resource_provider.delete(request)
2024-01-22 14:41:16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-22 14:41:16 File "/opt/code/localstack/localstack/services/apigateway/resource_providers/aws_apigateway_deployment.py", line 164, in delete
2024-01-22 14:41:16 api.delete_deployment(restApiId=model["RestApiId"], deploymentId=model["DeploymentId"])
2024-01-22 14:41:16 File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 535, in _api_call
2024-01-22 14:41:16 return self._make_api_call(operation_name, kwargs)
2024-01-22 14:41:16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-22 14:41:16 File "/opt/code/localstack/.venv/lib/python3.11/site-packages/botocore/client.py", line 983, in _make_api_call
2024-01-22 14:41:16 raise error_class(parsed_response, operation_name)
2024-01-22 14:41:16 botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the DeleteDeployment operation: Active stages pointing to this deployment must be moved or deleted
Same error... Error:
DELETE_FAILED: ApiGatewayDeployment1707753626779 (AWS::ApiGateway::Deployment)
An error occurred (BadRequestException) when calling the DeleteDeployment operation: Active stages pointing to this deployment must be moved or deleted
my serverless.yml:
functions:
start:
handler: handler.start
disableLogs: true
timeout: ${ssm:/${self:provider.stage}/${param:serviceName}/CURRENT_LAMBDA_FUNCTION_TIMEOUT, 900}
maximumRetryAttempts: 0
name: ${self:provider.stage}-${param:serviceName}-${param:appName}
environment: ${file(../../components/configs/serverless/environment.yml):environment}
events:
- http:
path: v1/webook/marketa
method: post
my docker-compose:
version: '3.8'
services:
localstack:
image: localstack/localstack:3.1.0
container_name: any-name
ports:
- '${LOCALSTACK_PORT}:4566'
environment:
- SERVICES=ssm,cloudformation,lambda,logs,iam,sqs,events,dynamodb,apigateway
- DEBUG=1
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_DEFAULT_REGION=${AWS_REGION}
- LAMBDA_EXECUTOR=docker-reuse
- TZ=UTC
volumes:
- './.env:/.env'
- './.aws-local:/etc/localstack/init/ready.d'
- '/var/run/docker.sock:/var/run/docker.sock'
- './.tmp/localstack:/var/lib/localstack'
After researching this issue, What I have figured out is this error is by design.
Serverless is using AWS::ApiGateway::Deployment and you can create with that in CE but not delete or update. Modifying requires a subscriptions.... That seems like a weird place to split your CE and Pro. So I guess the only way to actually handle redeploying is to stop and start Localstack. I have not figured out yet if there is some other way to get serverless to use a different way of clearing out gateways.
I read that documentation. It used to work fine with localstack v2.1.0 . Thanks
Same error... Error:
DELETE_FAILED: ApiGatewayDeployment1707753626779 (AWS::ApiGateway::Deployment) An error occurred (BadRequestException) when calling the DeleteDeployment operation: Active stages pointing to this deployment must be moved or deletedmy serverless.yml:
functions: start: handler: handler.start disableLogs: true timeout: ${ssm:/${self:provider.stage}/${param:serviceName}/CURRENT_LAMBDA_FUNCTION_TIMEOUT, 900} maximumRetryAttempts: 0 name: ${self:provider.stage}-${param:serviceName}-${param:appName} environment: ${file(../../components/configs/serverless/environment.yml):environment} events: - http: path: v1/webook/marketa method: postmy docker-compose:
version: '3.8' services: localstack: image: localstack/localstack:3.1.0 container_name: any-name ports: - '${LOCALSTACK_PORT}:4566' environment: - SERVICES=ssm,cloudformation,lambda,logs,iam,sqs,events,dynamodb,apigateway - DEBUG=1 - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_DEFAULT_REGION=${AWS_REGION} - LAMBDA_EXECUTOR=docker-reuse - TZ=UTC volumes: - './.env:/.env' - './.aws-local:/etc/localstack/init/ready.d' - '/var/run/docker.sock:/var/run/docker.sock' - './.tmp/localstack:/var/lib/localstack'
I have the same issue, and I am stuck