@ -806,6 +806,8 @@ def create_autoscaling_group(connection, module):
launch_configs = describe_launch_configurations ( connection , launch_config_name )
launch_configs = describe_launch_configurations ( connection , launch_config_name )
if len ( launch_configs [ ' LaunchConfigurations ' ] ) == 0 :
if len ( launch_configs [ ' LaunchConfigurations ' ] ) == 0 :
module . fail_json ( msg = " No launch config found with name %s " % launch_config_name )
module . fail_json ( msg = " No launch config found with name %s " % launch_config_name )
if desired_capacity is None :
desired_capacity = min_size
ag = dict (
ag = dict (
AutoScalingGroupName = group_name ,
AutoScalingGroupName = group_name ,
LaunchConfigurationName = launch_configs [ ' LaunchConfigurations ' ] [ 0 ] [ ' LaunchConfigurationName ' ] ,
LaunchConfigurationName = launch_configs [ ' LaunchConfigurations ' ] [ 0 ] [ ' LaunchConfigurationName ' ] ,
@ -952,9 +954,13 @@ def create_autoscaling_group(connection, module):
attach_lb_target_groups ( connection , group_name , list ( tgs_to_attach ) )
attach_lb_target_groups ( connection , group_name , list ( tgs_to_attach ) )
# check for attributes that aren't required for updating an existing ASG
# check for attributes that aren't required for updating an existing ASG
desired_capacity = desired_capacity if desired_capacity is not None else as_group [ ' DesiredCapacity ' ]
# check if min_size/max_size/desired capacity have been specified and if not use ASG values
min_size = min_size if min_size is not None else as_group [ ' MinSize ' ]
if min_size is None :
max_size = max_size if max_size is not None else as_group [ ' MaxSize ' ]
min_size = as_group [ ' MinSize ' ]
if max_size is None :
max_size = as_group [ ' MaxSize ' ]
if desired_capacity is None :
desired_capacity = as_group [ ' DesiredCapacity ' ]
launch_config_name = launch_config_name or as_group [ ' LaunchConfigurationName ' ]
launch_config_name = launch_config_name or as_group [ ' LaunchConfigurationName ' ]
launch_configs = describe_launch_configurations ( connection , launch_config_name )
launch_configs = describe_launch_configurations ( connection , launch_config_name )