aws-samples / aws-iam-access-key-auto-rotation

This set of CloudFormation templates and Python scripts will set up an auto-rotation function that will automatically rotate your AWS IAM User Access Keys every 90 days.
MIT No Attribution
138 stars 130 forks source link

Fixed duplicate conditional statement in force_rotation_handler.py #31

Open Jarvis-BITS opened 7 months ago

Jarvis-BITS commented 7 months ago

Issue #29

Description of changes:

Fixed duplicate conditional statement at lines 30 & 35 in force_rotation_handler.py within access_key_auto_rotation.zip

old code:

      log.info(f'ForceRotate flag exists for [{force_rotate_user_name}].')
  elif "ForceRotate" not in event and not noUsers:
      force_rotate = False
      log.info(
          'ForceRotate flag does not exist and '
          'there are users in this account.')
  elif "ForceRotate" not in event and not noUsers:
      log.info(
          f'ForceRotate flag exists for [{force_rotate_user_name}]'
          f' but there are no users in this account.')

Both elif statements have the same conditional statement elif "ForceRotate" not in event and not noUsers:. The second elif statement (line 35) was changed to elif "ForceRotate" in event and noUsers:

updated code:

      log.info(f'ForceRotate flag exists for [{force_rotate_user_name}].')
  elif "ForceRotate" not in event and not noUsers:
      force_rotate = False
      log.info(
          'ForceRotate flag does not exist and '
          'there are users in this account.')
  elif "ForceRotate" in event and noUsers:
      log.info(

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.