Skip to content

Zappa Undeploy Fails when you have event source as Kinesis #1252

@mthipparthi

Description

@mthipparthi

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']) + ").")

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

  1. 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"
    }
    ],
  2. 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"
    ]
    }
    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions