|
|
|
@ -98,16 +98,17 @@ def create_scaling_policy(connection, module):
|
|
|
|
|
policy = scalingPolicies[0]
|
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
|
|
#min_adjustment_step attribute is only relevant if the adjustment_type
|
|
|
|
|
#is set to percentage change in capacity, so it is a special case
|
|
|
|
|
# min_adjustment_step attribute is only relevant if the adjustment_type
|
|
|
|
|
# is set to percentage change in capacity, so it is a special case
|
|
|
|
|
if getattr(policy, 'adjustment_type') == 'PercentChangeInCapacity':
|
|
|
|
|
if getattr(policy, 'min_adjustment_step') != module.params.get('min_adjustment_step'):
|
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
#set the min adjustment step incase the user decided to change their adjustment type to percentage
|
|
|
|
|
# set the min adjustment step incase the user decided to change their
|
|
|
|
|
# adjustment type to percentage
|
|
|
|
|
setattr(policy, 'min_adjustment_step', module.params.get('min_adjustment_step'))
|
|
|
|
|
|
|
|
|
|
#check the remaining attributes
|
|
|
|
|
# check the remaining attributes
|
|
|
|
|
for attr in ('adjustment_type','scaling_adjustment','cooldown'):
|
|
|
|
|
if getattr(policy, attr) != module.params.get(attr):
|
|
|
|
|
changed = True
|
|
|
|
@ -117,8 +118,7 @@ def create_scaling_policy(connection, module):
|
|
|
|
|
if changed:
|
|
|
|
|
connection.create_scaling_policy(policy)
|
|
|
|
|
policy = connection.get_all_policies(policy_names=[sp_name])[0]
|
|
|
|
|
module.exit_json(changed=changed, name=policy.name, arn=policy.policy_arn, as_name=policy.as_name, scaling_adjustment=policy.scaling_adjustment, cooldown=policy.cooldown, adjustment_type=policy.adjustment_type, min_adjustment_step=policy.min_adjustment_step)
|
|
|
|
|
module.exit_json(changed=changed)
|
|
|
|
|
module.exit_json(changed=changed, name=policy.name, arn=policy.policy_arn, as_name=policy.as_name, scaling_adjustment=policy.scaling_adjustment, cooldown=policy.cooldown, adjustment_type=policy.adjustment_type, min_adjustment_step=policy.min_adjustment_step)
|
|
|
|
|
except BotoServerError, e:
|
|
|
|
|
module.fail_json(msg=str(e))
|
|
|
|
|
|
|
|
|
@ -172,9 +172,3 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|