Skip to content

Commit

Permalink
Prevent performing any changes if the parameter is not passed
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilturek committed Mar 1, 2023
1 parent 7c0af2d commit f146499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions plugins/modules/ses_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/targets/ses_identity/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit f146499

Please sign in to comment.