繁体   English   中英

使用 lambda boto3 描述侦听器规则计数

[英]Describe listener rule count using lambda boto3

我只是在 Lambda function 和长度 function 上使用下面的代码来计算监听器规则。 然而,即使 ALB 有超过 20 条规则,它总是返回值 2。

import json
import boto3
    
def lambda_handler(event, context):
    client = boto3.client('elbv2')
    response1 = client.describe_listeners(
    ListenerArns=[
        'arn:aws:elasticloadbalancing:eu-west-2:account_id:listener/app/my_load_balancer_listener',
         ],
    )
    tot = len(response1)
    return response1

像这样获取 output。

Response as 2 

获取规则,你应该使用describe_rules

def lambda_handler(event, context):
    client = boto3.client('elbv2')
    response1 = client.describe_rules(
    ListenerArn='arn:aws:elasticloadbalancing:eu-west-2:account_id:listener/app/my_load_balancer_listener',
    )
    tot = len(response1['Rules'])
    return tot

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM