Skip to content

Commit

Permalink
ec2_metric_alarm - drop deprecated support for symbolic operators (an…
Browse files Browse the repository at this point in the history
…sible-collections#1164)

ec2_metric_alarm - drop deprecated support for symbolic operators

SUMMARY
With the migration to boto3 symbolic operators were deprecated.  Remove it.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_metric_alarm
ADDITIONAL INFORMATION
See also: ansible/ansible#62669

Reviewed-by: Markus Bergholz <git@osuv.de>
  • Loading branch information
tremble authored May 26, 2022
1 parent d1ca7fc commit 537fa82
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions ec2_metric_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,13 @@
comparison:
description:
- Determines how the threshold value is compared
- Symbolic comparison operators have been deprecated, and will be removed after 2022-06-22.
required: false
type: str
choices:
- 'GreaterThanOrEqualToThreshold'
- 'GreaterThanThreshold'
- 'LessThanThreshold'
- 'LessThanOrEqualToThreshold'
- '<='
- '<'
- '>='
- '>'
threshold:
description:
- Sets the min/max bound for triggering the alarm.
Expand Down Expand Up @@ -192,7 +187,7 @@
metric: "StatusCheckFailed_System"
namespace: "AWS/EC2"
statistic: "Minimum"
comparison: ">="
comparison: "GreaterThanOrEqualToThreshold"
threshold: 1.0
period: 60
evaluation_periods: 2
Expand All @@ -214,16 +209,6 @@
def create_metric_alarm(connection, module, params):
alarms = connection.describe_alarms(AlarmNames=[params['AlarmName']])

comparisons = {'<=': 'LessThanOrEqualToThreshold',
'<': 'LessThanThreshold',
'>=': 'GreaterThanOrEqualToThreshold',
'>': 'GreaterThanThreshold'}
if params['ComparisonOperator'] in ('<=', '<', '>', '>='):
module.deprecate('Using the <=, <, > and >= operators for comparison has been deprecated. Please use LessThanOrEqualToThreshold, '
'LessThanThreshold, GreaterThanThreshold or GreaterThanOrEqualToThreshold instead.',
date='2022-06-01', collection_name='community.aws')
params['ComparisonOperator'] = comparisons[params['ComparisonOperator']]

if not isinstance(params['Dimensions'], list):
fixed_dimensions = []
for key, value in params['Dimensions'].items():
Expand Down Expand Up @@ -314,7 +299,7 @@ def main():
namespace=dict(type='str'),
statistic=dict(type='str', choices=['SampleCount', 'Average', 'Sum', 'Minimum', 'Maximum']),
comparison=dict(type='str', choices=['LessThanOrEqualToThreshold', 'LessThanThreshold', 'GreaterThanThreshold',
'GreaterThanOrEqualToThreshold', '<=', '<', '>', '>=']),
'GreaterThanOrEqualToThreshold']),
threshold=dict(type='float'),
period=dict(type='int'),
unit=dict(type='str', choices=['Seconds', 'Microseconds', 'Milliseconds', 'Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes',
Expand Down

0 comments on commit 537fa82

Please sign in to comment.