Skip to content
8 changes: 5 additions & 3 deletions src/lambda_codebase/moved_to_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from parameter_store import ParameterStore
from logger import configure_logger
from cloudformation import CloudFormation
from paginator import paginator

LOGGER = configure_logger(__name__)
REGION_DEFAULT = os.environ.get('AWS_REGION')
Expand All @@ -28,9 +29,10 @@ def worker_thread(sts, region, account_id, role, event):
'remove_base')

parameter_store = ParameterStore(region, role)
parameters = [param['Name'] for param in parameter_store.client.describe_parameters()['Parameters'] if 'Used by The AWS Deployment Framework' in param['Description']]
for parameter in parameters:
parameter_store.delete_parameter(parameter)
for page in paginator(parameter_store.client.describe_parameters):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change this to use the Boto3 paginator instead?
See the docs in boto3 here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/paginators.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, I'll update the PR next week!

for parameter in page['Parameters']:
if 'Used by The AWS Deployment Framework' in parameter.get('Description', ''):
parameter_store.delete_parameter(parameter.get('Name'))

cloudformation = CloudFormation(
region=region,
Expand Down