diff --git a/changelogs/fragments/1440-cloudwatch_metric_alarm-fix-change-detection.yml b/changelogs/fragments/1440-cloudwatch_metric_alarm-fix-change-detection.yml new file mode 100644 index 00000000000..0cbde555d32 --- /dev/null +++ b/changelogs/fragments/1440-cloudwatch_metric_alarm-fix-change-detection.yml @@ -0,0 +1,2 @@ +bugfixes: +- cloudwatch_metric_alarm - Don't consider ``StateTransitionedTimestamp`` in change detection. (https://github.com/ansible-collections/amazon.aws/pull/1440). diff --git a/plugins/modules/cloudwatch_metric_alarm.py b/plugins/modules/cloudwatch_metric_alarm.py index 714330ce43e..418d5ea93c0 100644 --- a/plugins/modules/cloudwatch_metric_alarm.py +++ b/plugins/modules/cloudwatch_metric_alarm.py @@ -333,8 +333,10 @@ def create_metric_alarm(connection, module, params): if 'TreatMissingData' not in alarm.keys(): alarm['TreatMissingData'] = 'missing' + # Exclude certain props from change detection for key in ['ActionsEnabled', 'StateValue', 'StateReason', 'StateReasonData', 'StateUpdatedTimestamp', + 'StateTransitionedTimestamp', 'AlarmArn', 'AlarmConfigurationUpdatedTimestamp', 'Metrics']: alarm.pop(key, None) if alarm != params: