CPM may fail to add a new account or update an existing one with the Can not connect to AWS

CPM fails to add a new account or update an existing one with the "Failed getting account number for account 'XXXYYYZZZ' in ALL regions" and/or "Can not connect to AWS" errors

CPM may fail to add a new account or update an existing one with the "Failed getting account number for account 'XXXYYYZZZ' in ALL regions" and/or "Can not connect to AWS" errors.
There are 3 possible causes:

1. The errors in cpm_server.log look like this:
ERROR:  get_account_number_from_region(.\cpmserver\cpm\aws_utils.py:1090)  Can not connect to AWS, region Asia Pacific (Seoul). Exception: Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got 'ABCDEFGHI12345678XYZ '
ERROR:  get_account_number_from_region(.\cpmserver\cpm\aws_utils.py:1090)  Can not connect to AWS, region Asia Pacific (Singapore). Exception: Request has expired. Timestamp date is 2017-04-18T06:05:35Z
...
ERROR:  get_account_number(.\cpmserver\cpm\aws_utils.py:1075)  Failed getting account number for account'ABCDEFGHI12345678XYZ ' in ALL regions

One of the first 2 errors will be shown in GUI as well.
This problem is usually caused by an extra space being pasted into "Secret Access Key" and/or "Access Key ID" fields.
Please paste them into a text editor first and make sure that there is no extra space at the end of these strings.
In the example above you can see the extra space at the end of 'ABCDEFGHI12345678XYZ ' .

2. The errors in cpm_server.log look like this:
ERROR:  get_account_number_from_region(.\cpmserver\cpm\aws_utils.py:1074)  Can not connect to AWS, region Asia Pacific (Mumbai). Exception: AWS was not able to validate the provided access credentials
ERROR:  get_account_number_from_region(.\cpmserver\cpm\aws_utils.py:1074)  Can not connect to AWS, region South America (Sao Paulo). Exception: You are not authorized to perform this operation.
...
ERROR:  get_account_number(.\cpmserver\cpm\aws_utils.py:1059)  Failed getting account number for account'ABCDEFGHI12345678XYZ' in ALL regions

One of the first 2 errors will be shown in GUI as well.
This problem is usually caused by lack of permissions in this account.

3. The errors in cpm_server.log look like this:
ERROR:  get_assume_role_credentials(.\cpmserver\cpm\aws_utils.py:1076)  Could not assume role arn arn:aws:iam::012345678901:role/CPMRole from account root (user BackupAdmin), reason Signature expired: 20171031T101714Z is now earlier than 20171031T101735Z (20171031T103235Z - 15 min.)
ERROR:  edit_account_page(.\cpmserver\cpm\views.py:4658)  Failed assuming a role for new account. Reason: Signature expired: 20171031T101714Z is now earlier than 20171031T101735Z (20171031T103235Z - 15 min.)
ERROR:  get_account_number_from_region(.\cpmserver\cpm\aws_utils.py:1126)  Can not connect to AWS, region EU (Ireland). Exception: Request has expired. Timestamp date is 2017-10-31T10:19:14Z

This problem is caused by a time synchronization issue, please see the "Troubleshooting time synchronization" paragraph at  https://support.n2ws.com/portal/kb/articles/backup-start-starts-to-fail-because-of-clock-issues-specifically-to-frankfurt-region .
In fact, time synchronization can be the cause for any "Request has expired" exceptions, even if "Signature Expired" is not stated as the reason.