aws-deployment-framework icon indicating copy to clipboard operation
aws-deployment-framework copied to clipboard

Issue with paginator not being used in moved_to_root and direct access to key

Open rickardl opened this issue 5 years ago • 0 comments

Hi,

When moving one of our larger accounts back to the root OU we get the following error in one of the step functions (that invoked moved_to_root). Our SSM Parameters has empty Descriptions and it has over 100 entries and this becomes an issue with how the current implementation handles some edge cases.

[ERROR] KeyError: 'Description'
Traceback (most recent call last):
  File "/var/task/moved_to_root.py", line 93, in lambda_handler
    execute_move_action(action, account_id, parameter_store, event)
  File "/var/task/moved_to_root.py", line 76, in execute_move_action
    return remove_base(account_id, regions, role, event)
  File "/var/task/moved_to_root.py", line 65, in remove_base
    thread.join()
  File "/opt/python/thread.py", line 30, in join
    raise self.exc
  File "/opt/python/thread.py", line 22, in run
    **self._kwargs
  File "/var/task/moved_to_root.py", line 31, in worker_thread
    parameters = [param['Name'] for param in parameter_store.client.describe_parameters()['Parameters'] if 'Used by The AWS Deployment Framework' in param['Description']]
  File "/var/task/moved_to_root.py", line 31, in <listcomp>
    parameters = [param['Name'] for param in parameter_store.client.describe_parameters()['Parameters'] if 'Used by The AWS Deployment Framework' in param['Description']]

Digging into the deployment framework we can see that moved_to_root.py has the following issues in the worker_thread

  • it does not paginate the API response
  • it doesn't take into the consideration that the Description key for a parameter might be empty, therefore the list comprehension can fail with an error.

rickardl avatar Jun 08 '20 14:06 rickardl