|
|
@ -99,16 +99,17 @@ def create_scaling_policy(connection, module):
|
|
|
|
policy = scalingPolicies[0]
|
|
|
|
policy = scalingPolicies[0]
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
|
|
|
|
#min_adjustment_step attribute is only relevant if the adjustment_type
|
|
|
|
# min_adjustment_step attribute is only relevant if the adjustment_type
|
|
|
|
#is set to percentage change in capacity, so it is a special case
|
|
|
|
# is set to percentage change in capacity, so it is a special case
|
|
|
|
if getattr(policy, 'adjustment_type') == 'PercentChangeInCapacity':
|
|
|
|
if getattr(policy, 'adjustment_type') == 'PercentChangeInCapacity':
|
|
|
|
if getattr(policy, 'min_adjustment_step') != module.params.get('min_adjustment_step'):
|
|
|
|
if getattr(policy, 'min_adjustment_step') != module.params.get('min_adjustment_step'):
|
|
|
|
changed = True
|
|
|
|
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'))
|
|
|
|
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'):
|
|
|
|
for attr in ('adjustment_type','scaling_adjustment','cooldown'):
|
|
|
|
if getattr(policy, attr) != module.params.get(attr):
|
|
|
|
if getattr(policy, attr) != module.params.get(attr):
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
@ -118,8 +119,6 @@ def create_scaling_policy(connection, module):
|
|
|
|
if changed:
|
|
|
|
if changed:
|
|
|
|
connection.create_scaling_policy(policy)
|
|
|
|
connection.create_scaling_policy(policy)
|
|
|
|
policy = connection.get_all_policies(policy_names=[sp_name])[0]
|
|
|
|
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)
|
|
|
|
|
|
|
|
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, 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:
|
|
|
|
except BotoServerError, e:
|
|
|
|
module.fail_json(msg=str(e))
|
|
|
|
module.fail_json(msg=str(e))
|
|
|
@ -176,9 +175,3 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|