From e3f3ad1e0be129dd03f25ce20c31d86d7e5d1147 Mon Sep 17 00:00:00 2001 From: dzikafoczka Date: Sat, 21 Dec 2024 09:14:37 +0100 Subject: [PATCH] autoscaling --- autoscaling.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/autoscaling.py b/autoscaling.py index b605f18..bf43491 100644 --- a/autoscaling.py +++ b/autoscaling.py @@ -233,7 +233,7 @@ def create_load_balancer_listener(elbv2_client, load_balancer_arn, target_group_ def create_auto_scaling_group(autoscaling_client, launch_template_id, target_group_arn, subnet_id_1, subnet_id_2): # Create Auto Scaling Group - response = autoscaling_client.create_auto_scaling_group( + autoscaling_client.create_auto_scaling_group( AutoScalingGroupName=f"{PREFIX}-asg", LaunchTemplate={ 'LaunchTemplateId': launch_template_id, @@ -256,8 +256,13 @@ def create_auto_scaling_group(autoscaling_client, launch_template_id, target_gro ] ) - print(f"Auto Scaling Group created with ARN: {response['AutoScalingGroups'][0]['AutoScalingGroupARN']}") - return response['AutoScalingGroups'][0]['AutoScalingGroupARN'] + describe_response = autoscaling_client.describe_auto_scaling_groups( + AutoScalingGroupNames=[f"{PREFIX}-asg"] + ) + + asg_arn = describe_response['AutoScalingGroups'][0]['AutoScalingGroupARN'] + print(f"Auto Scaling Group created with ARN: {asg_arn}") + return asg_arn def put_scaling_policies(autoscaling_client, asg_arn): # Put Scaling Policies