How do I return a hash from a aws lambda function ?
Using boto3 module.
Here is my code snip
def lambda_handler(event, context):
    global cnt
    any = []
    for node in ec2.instances.filter(Filters=[{'Name': 'instance-state-name', 'Values': ['running']}]):
        inst= node.instance_type
        any.append(inst)
    cnt=collections.Counter(any)
    return cnt
for key, val in cnt.items():
    print key
    print val
Exact code works in python IDE. My goal is to return a variable from AWS lambda function and use in other functions with in the same lambda-function.
Error in lambda logs
module initialization error: global name 'cnt' is not defined
 
     
     
     
    