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 8015936 commit 9cf0e20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/1164-ec2_metric_alarm-deprecation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
removed_features:
- ec2_metric_alarm - support for using the ``<=``, ``<``, ``>`` and ``>=`` operators for comparison has been dropped.
Please use ``LessThanOrEqualToThreshold``, ``LessThanThreshold``, ``GreaterThanThreshold`` or
``GreaterThanOrEqualToThreshold`` instead (https://github.com/ansible-collections/amazon.aws/pull/1164).
19 changes: 2 additions & 17 deletions plugins/modules/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
14 changes: 7 additions & 7 deletions tests/integration/targets/ec2_metric_alarm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
namespace: "AWS/EC2"
treat_missing_data: missing
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 300
evaluation_periods: 3
Expand Down Expand Up @@ -90,7 +90,7 @@
namespace: "AWS/EC2"
treat_missing_data: missing
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 300
evaluation_periods: 3
Expand Down Expand Up @@ -138,7 +138,7 @@
namespace: "AWS/EC2"
treat_missing_data: missing
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 300
evaluation_periods: 3
Expand Down Expand Up @@ -193,7 +193,7 @@
namespace: "AWS/EC2"
treat_missing_data: missing
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 300
evaluation_periods: 3
Expand Down Expand Up @@ -246,7 +246,7 @@
metric: "CPUUtilization"
namespace: "AWS/EC2"
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 60
evaluation_periods: 3
Expand Down Expand Up @@ -286,7 +286,7 @@
metric: "CPUUtilization"
namespace: "AWS/EC2"
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 60
evaluation_periods: 3
Expand Down Expand Up @@ -385,7 +385,7 @@
namespace: "AWS/EC2"
treat_missing_data: missing
statistic: Average
comparison: "<="
comparison: "LessThanOrEqualToThreshold"
threshold: 5.0
period: 300
evaluation_periods: 3
Expand Down
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins/modules/aws_kms.py pylint:ansible-deprecated-no-version
plugins/modules/aws_kms_info.py pylint:ansible-deprecated-no-version
plugins/modules/ec2_metric_alarm.py pylint:ansible-deprecated-no-version
plugins/modules/iam_policy.py pylint:ansible-deprecated-no-version
plugins/modules/iam_role.py pylint:ansible-deprecated-no-version
plugins/modules/iam_user.py pylint:ansible-deprecated-no-version

0 comments on commit 9cf0e20

Please sign in to comment.