-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Zappa Undeploy Fails when you have event source as Kinesis #1252
Description
When you have Kinesis as event source to trigger AWS lambda, while performing "undeploy" , we are having "Key error" and undpeloy is failing.
We are getting below error while undeploying.
File "/var/task/venv/local/lib/python2.7/site-packages/zappa/cli.py", line 1087, in undeploy self.unschedule() # removes event triggers, including warm up event. File "/var/task/venv/local/lib/python2.7/site-packages/zappa/cli.py", line 1193, in unschedule events=events, File "/var/task/venv/local/lib/python2.7/site-packages/zappa/core.py", line 2460, in unschedule_events print("Removed event " + name + " (" + str(event_source['events']) + ").") KeyError: 'events
Expected Behavior
zappa undeploy should be success
Actual Behavior
zappa undeploy Failing
Possible Fix
Permanent Solution :
This portion of the code is causing the issue. we should check 'events' before we print this below line.
print("Removed event " + name + " (" + str(event_source['events']) + ").")
Line 2464 in 7012e25
| print("Removed event " + name + " (" + str(event_source['events']) + ").") |
"events": [
{
"function": "functions.lambda_handler",
"event_source": {
"arn": "arn:aws:kinesis:*:*:stream/stream_name",
"starting_position": "LATEST",
"batch_size": 1,
"enabled": true,
},
"name": "name_lambda"
}
],
Temporary fix.
change the configuration
"events": [
{
"function": "functions.lambda_handler",
"event_source": {
"arn": "arn:aws:kinesis:::stream/stream_name",
"starting_position": "LATEST",
"batch_size": 1,
"enabled": true,
"events"= []
},
"name": "name_lambda"
}
],
Steps to Reproduce
- Have events in zappa settings like below.
"events": [
{
"function": "functions.lambda_handler",
"event_source": {
"arn": "arn:aws:kinesis:::stream/stream_name",
"starting_position": "LATEST",
"batch_size": 1,
"enabled": true
},
"name": "name_lambda"
}
], - zappa undeploy
Your Environment
- Zappa version used: zappa==0.44.3
- Operating System and Python version: lambci/lambda:build-python2.7
- The output of
pip freeze: - Link to your project (optional):
- Your
zappa_settings.py:
{
"dev": {
"aws_environment_variables": {
"ENV1": "dev",
"ENV2": "dev"
},
"aws_region": "ap-southeast-2",
"debug": true,
"events": [
{
"function": "functions.lambda_handler",
"event_source": {
"arn": "arn:aws:kinesis:::stream/stream-dev",
"starting_position": "LATEST",
"batch_size": 1,
"enabled": true,
"events" : []
},
"name": "event_name"
}
],
"keep_warm": false,
"log_level": "DEBUG",
"manage_roles": false,
"memory_size": 128,
"parameter_depth": 1,
"project_name": "project_name",
"role_name": "project_name-role",
"runtime": "python2.7",
"s3_bucket": "project_name-dev",
"timeout_seconds": 300,
"use_apigateway": false,
"use_precompiled_packages": false,
"vpc_config": {
"SecurityGroupIds": [
"sg-xyz"
],
"SubnetIds": [
"subnet-xyz1",
"subnet-xyz2"
]
}
}
}