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