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,如果存在,则更新其值;否则,创建新的属性。

相关内容

热门资讯

今日百科!德州局怎么透视(辅助... 今日百科!德州局怎么透视(辅助挂)切实有挂(的确有挂辅助器)1、让任何用户在无需安装教程第三方神器的...
热点推荐!wepoker游戏下... 热点推荐!wepoker游戏下载(辅助挂)切实是有挂(有挂细节辅助脚本)进入游戏-大厅左侧-新手福利...
我来教大家!werplan有挂... 我来教大家!werplan有挂吗(辅助挂)本来是真的有挂(有挂解惑辅助app)1、打开软件启动之后找...
终于知道!wpk作弊(辅助挂)... 终于知道!wpk作弊(辅助挂)本来真的是有挂(有挂方略辅助技巧)1、进入游戏-大厅左侧-新手福利-激...
普及知识!wepoker私人局... 普及知识!wepoker私人局开挂视频(辅助挂)都是真的有挂(有挂解密辅助插件)1、实时透视辅助更新...
揭秘攻略!pokemmo手机版... 揭秘攻略!pokemmo手机版脚本(辅助挂)本来存在有挂(有挂功能辅助插件)脚本下载中分为三种模型:...
重大通报!hhpoker作弊实... 重大通报!hhpoker作弊实战视频(辅助挂)切实真的是有挂(有挂透明挂辅助脚本)1、有没有辅助教程...
揭秘关于!智星德州辅助译码插件... 揭秘关于!智星德州辅助译码插件靠谱吗(辅助挂)其实是真的有挂(有挂方针辅助脚本)该软件可以轻松地帮助...
信息共享!xpoker辅助神器... 信息共享!xpoker辅助神器(辅助挂)好像是真的有挂(确实有挂辅助脚本)1. 选牌创建新账号,点击...
科普分享!hh poker辅助... 科普分享!hh poker辅助有用吗(辅助挂)总是真的是有挂(竟然有挂辅助插件)1、进入到是否有挂之...