是否有方法将新的应用程序目标组附加到现有的自动缩放组
在我下面的代码中,我试图尝试它,但它似乎不起作用
lb = aws_cdk.aws_elasticloadbalancingv2.ApplicationLoadBalancer(self, "ServiceApplicationLB", vpc=vpc, internet_facing=True, security_group=sg)
#Fetching AutoScalingGroup ID from Service Stack
AsgNameOutputs = boto3.Session().client("cloudformation").describe_stacks(StackName="Service")["Stacks"][0]["Outputs"]
AsgNames=[]
for Output in AsgNameOutputs:
if Output["OutputKey"].startswith("AutoScalingGroupName"):
AsgNames.append(Output["OutputValue"])
print("AsgNames: ", AsgNames)
listener = lb.add_listener("Listener", port=80)
applicationTargetGroup = listener.add_targets("Target", port=8080,
health_check={"path": "/ping", "interval": Duration.seconds(30), "port": "8080"})
for AsgName in AsgNames:
asg = aws_cdk.aws_autoscaling.AutoScalingGroup.from_auto_scaling_group_name(self, AsgName, auto_scaling_group_name=AsgName) # FIX ME
#Above line is returning IAutoScalingGroup. Instead I need AutoScalingGroup here so to call the attach_to_application_target_group method
aws_cdk.aws_autoscaling.AutoScalingGroup.attach_to_application_target_group(asg, target_group=applicationTargetGroup) #FIX ME
目前没有回答
相关问题 更多 >
编程相关推荐