The script asks for a list of regions and then iterates through them.
The following occurs if you don't have all regions enabled:
$ python clear_lambda_storage.py
Scanning ap-east-1 region
Traceback (most recent call last):
File "clear_lambda_storage.py", line 191, in <module>
remove_old_lambda_versions(PARSER.parse_args())
File "clear_lambda_storage.py", line 115, in remove_old_lambda_versions
for lambda_function in function_generator:
File "clear_lambda_storage.py", line 54, in lambda_function_generator
response = lambda_client.list_functions()
File "~/.local/share/virtualenvs/kata-review-bot-h17npMBk/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "~/.local/share/virtualenvs/kata-review-bot-h17npMBk/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the ListFunctions operation: The security token included in the request is invalid.
When I run:
aws s3 ls
I see output that indicates my security token is fine.
When I check ap-east-1 in the AWS Management Console, it says I need to enable it.
If I hardcode the script to use a specific region I know is enabled (us-east-1), the script runs and deletes old lambdas just fine.
The script asks for a list of regions and then iterates through them.
The following occurs if you don't have all regions enabled:
When I run:
aws s3 ls
I see output that indicates my security token is fine.
When I check ap-east-1 in the AWS Management Console, it says I need to enable it.
If I hardcode the script to use a specific region I know is enabled (us-east-1), the script runs and deletes old lambdas just fine.