部署 CDK 时当前正在使用优先级

Priority is currently in use when deploying CDK

我定义cdk :

priority = 0
for path in targets.keys():
    listener.add_targets(
        "TargetGroup" + path + name,
        port=80,
        path_pattern=path + "*",
        priority = priority + 2,
        targets=[targets[path]],
        health_check=healthCheck(path),
    )

部署时,我得到了这个:

Priority '2' is currently in use (Service: AmazonElasticLoadBalancingV2; Status Code: 400; Error Code: PriorityInUse; Request ID: da53a5c6-9856-4e43-b5d8-29ff90d9ab17)

基本上,我将优先级定义为随机:

    ALB_RULE_PRIORITY_RANGE = 1, 50000
    for path in targets.keys():
        listener.add_targets(
            "TargetGroup" + path + name,
            port=80,
            path_pattern=path + "*",
            priority=int(random.randint(*ALB_RULE_PRIORITY_RANGE)),
            targets=[targets[path]],
            health_check=healthCheck(path),
        )