0

i need to list listener rules count but still i get a output as null without any error.my complete project was getting email notification from when listener rules created on elastic load balancer.

import json
import boto3

def lambda_handler(event, context):
    client = boto3.client('elbv2')
    response = client.describe_listeners(
    ListenerArns=[
        'arn:aws:elasticloadbalancing:ap-south-1:my_alb_listener',
    ],
)

print('response')

Here is the output of my code

Response null

techiies
  • 51
  • 7

1 Answers1

2

Response is null because your indentation is incorrect and you are not returning anything from your handler. It should be:

import json
import boto3

def lambda_handler(event, context):
    client = boto3.client('elbv2')
    response = client.describe_listeners(
    ListenerArns=[
        'arn:aws:elasticloadbalancing:ap-south-1:my_alb_listener',
      ],
    )

    return response
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I just used above code on Lambda function and length function to calculate listner rules. However it always return the value as 2 even ALB has more than 20 rules. – techiies Mar 28 '22 at 09:09
  • tot = len(response1) return response1 – techiies Mar 28 '22 at 09:10