AWS:ALB要么立即响应,要么在130秒后响应。
创始人
2024-09-28 07:30:24
0

以下是一个使用AWS SDK for Python(boto3)的示例代码,用于在ALB(Application Load Balancer)的目标组中设置响应超时时间:

import boto3

def update_target_group_response_delay(target_group_arn, response_delay):
    # 创建ELBV2的客户端
    elbv2_client = boto3.client('elbv2')

    # 获取目标组的当前属性
    response = elbv2_client.describe_target_group_attributes(
        TargetGroupArn=target_group_arn
    )

    # 查找"deregistration_delay.timeout_seconds"属性的索引
    deregistration_delay_index = next(
        (index for (index, attr) in enumerate(response['Attributes']) if attr['Key'] == 'deregistration_delay.timeout_seconds'),
        None
    )

    # 如果属性存在,则更新其值;否则,创建新的属性
    if deregistration_delay_index is not None:
        elbv2_client.modify_target_group_attributes(
            TargetGroupArn=target_group_arn,
            Attributes=[
                {
                    'Key': 'deregistration_delay.timeout_seconds',
                    'Value': str(response_delay)
                }
            ]
        )
    else:
        elbv2_client.create_target_group_attributes(
            TargetGroupArn=target_group_arn,
            Attributes=[
                {
                    'Key': 'deregistration_delay.timeout_seconds',
                    'Value': str(response_delay)
                }
            ]
        )

# 示例用法
target_group_arn = 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-target-group/abcdef123456'
response_delay = 130

update_target_group_response_delay(target_group_arn, response_delay)

请将target_group_arn替换为您的目标组的ARN,将response_delay替换为您想要设置的响应超时时间(以秒为单位)。此代码将检查目标组的属性是否包含deregistration_delay.timeout_seconds,如果存在,则更新其值;否则,创建新的属性。

相关内容

热门资讯

辅助透视!wpk透视脚本,wp... 辅助透视!wpk透视脚本,wpk辅助插件(详细辅助必赢教程);1、许多玩家不知道wpk透视脚本辅助软...
wpk俱乐部!wpk线上实战(... wpk俱乐部!wpk线上实战(透视)确实存在有挂(详细辅助详细教程)是一款可以让一直输的玩家,快速成...
透视插件!wpk有没有脚本,w... 透视插件!wpk有没有脚本,wepoker辅助是真的假的(详细辅助普及教程)1.wpk有没有脚本 a...
wepoke辅助机器人!微扑克... wepoke辅助机器人!微扑克ai辅助工具(透视)原本有挂(详细辅助切实教程)微扑克ai辅助工具辅助...
aapoker俱乐部!wepo... aapoker俱乐部!wepoker真的有挂吗(透视)原生有挂(详细辅助微扑克教程);无聊就玩这款a...
透视真的!德普之星怎么作弊,w... 透视真的!德普之星怎么作弊,wepoker辅助分析器(详细辅助wpk教程)1、在德普之星怎么作弊ai...
微扑克游戏辅助器!wepowe... 微扑克游戏辅助器!wepower有机器人吗(透视)原生是真的有挂(详细辅助技巧教程)1、微扑克游戏辅...
透视游戏!wepoker辅助器... 透视游戏!wepoker辅助器安装包,wpk私人局辅助是真的吗(详细辅助插件教程);1、下载好wep...
微扑克ai辅助!微扑克ai人工... 微扑克ai辅助!微扑克ai人工智能(透视)其实真的是有挂(详细辅助解说技巧)是一款可以让一直输的玩家...
透视存在!智星德州菠萝安装,w... 透视存在!智星德州菠萝安装,wepoker免费脚本咨询(详细辅助详细教程);1、透视存在!智星德州菠...