@@ -143,10 +143,11 @@ def component_auto_scaling_group(definition, configuration, args, info, force, a
143143 configuration .get ('HealthCheckGracePeriod' , 300 )
144144
145145 if "AutoScaling" in configuration :
146- definition ["Resources" ][asg_name ]["Properties" ]["MaxSize" ] = configuration ["AutoScaling" ]["Maximum" ]
147- definition ["Resources" ][asg_name ]["Properties" ]["MinSize" ] = configuration ["AutoScaling" ]["Minimum" ]
148-
149- definition ["Resources" ][asg_name ]["Properties" ]["DesiredCapacity" ] = max (configuration ["AutoScaling" ]["Minimum" ], 1 )
146+ as_conf = configuration ["AutoScaling" ]
147+ definition ["Resources" ][asg_name ]["Properties" ]["MaxSize" ] = as_conf ["Maximum" ]
148+ definition ["Resources" ][asg_name ]["Properties" ]["MinSize" ] = as_conf ["Minimum" ]
149+ definition ["Resources" ][asg_name ]["Properties" ]["DesiredCapacity" ] = max (as_conf ["Minimum" ],
150+ as_conf .get ('DesiredCapacity' , 1 ))
150151
151152 # ScaleUp policy
152153 definition ["Resources" ][asg_name + "ScaleUp" ] = {
@@ -174,11 +175,11 @@ def component_auto_scaling_group(definition, configuration, args, info, force, a
174175 }
175176 }
176177
177- metric_type = configuration [ "AutoScaling" ] ["MetricType" ]
178+ metric_type = as_conf ["MetricType" ]
178179 metricfn = globals ().get ('metric_{}' .format (metric_type .lower ()))
179180 if not metricfn :
180181 raise click .UsageError ('Auto scaling MetricType "{}" not supported.' .format (metric_type ))
181- definition = metricfn (asg_name , definition , configuration [ "AutoScaling" ] , args , info , force )
182+ definition = metricfn (asg_name , definition , as_conf , args , info , force )
182183 else :
183184 definition ["Resources" ][asg_name ]["Properties" ]["MaxSize" ] = 1
184185 definition ["Resources" ][asg_name ]["Properties" ]["MinSize" ] = 1
0 commit comments