From f1464996a5bf00ac71b67921d15c12bc004a189e Mon Sep 17 00:00:00 2001 From: Kamil Turek Date: Wed, 1 Mar 2023 22:53:35 +0100 Subject: [PATCH] Prevent performing any changes if the parameter is not passed --- plugins/modules/ses_identity.py | 8 ++++++++ tests/integration/targets/ses_identity/tasks/main.yaml | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/modules/ses_identity.py b/plugins/modules/ses_identity.py index c3a4a3ed63e..45958d467ef 100644 --- a/plugins/modules/ses_identity.py +++ b/plugins/modules/ses_identity.py @@ -290,6 +290,10 @@ def get_identity_notifications(connection, module, identity, retries=0, retryDel return notification_attributes[identity] +def has_notification_configuration(module, notification_type): + return f'{notification_type.lower()}_notifications' in module.params + + def desired_topic(module, notification_type): arg_dict = module.params.get(notification_type.lower() + '_notifications') if arg_dict: @@ -299,6 +303,10 @@ def desired_topic(module, notification_type): def update_notification_topic(connection, module, identity, identity_notifications, notification_type): + # Not passing the parameter should not cause any changes. + if not has_notification_configuration(module, notification_type): + return False + topic_key = notification_type + 'Topic' if identity_notifications is None: # If there is no configuration for notifications cannot be being sent to topics diff --git a/tests/integration/targets/ses_identity/tasks/main.yaml b/tests/integration/targets/ses_identity/tasks/main.yaml index 0a31642cd17..9afe8603152 100644 --- a/tests/integration/targets/ses_identity/tasks/main.yaml +++ b/tests/integration/targets/ses_identity/tasks/main.yaml @@ -370,7 +370,7 @@ identity: "{{ email_identity }}" state: absent # ============================================================ - - name: test clear notification settings + - name: test clear notification configuration block: - name: test topic sns_topic: @@ -395,6 +395,9 @@ aws_ses_identity: identity: "{{ email_identity }}" state: present + bounce_notifications: {} + complaint_notifications: {} + delivery_notifications: {} register: result - name: assert notification settings assert: