I am using Python3 to read AWS bucket names and specifically exit from the loop if the bucket name matches partially with any of the names defined in the bucket_exclusion_list array.
I created a bucket validation function as follows:
def valid_bucket(bucket_name):
bucket_exclusion_list = ['do-not-delete', 'aws-config', 'elasticbeanstalk']
for exclusion_items in bucket_exclusion_list:
if bool(re.match(exclusion_items, bucket_name)) == True:
return False
else:
continue
return True
In my main function, I am calling the valid_bucket function and based on the boolean value, continuing further in the code.
if valid_bucket(bucket_name):
bucket_info["bucketName"] = bucket_name
bucket_info["bucketSize"] = ''
...
The code doesn't seem to be working as expected. I have to move on to the next bucket name if the current bucket name matches with the items in the exclusion list. Can someone help me understand the problem with the code?