in migration/bring-your-own-gdc-assets/bring_your_own_gdc_assets.py [0:0]
def _check_and_register_location(tables, role_arn, lf_client):
s3_registered_locations = _get_S3_registered_locations(lf_client)
for table in tables:
# Remove trailing '/' if present
s3_location = table['StorageDescriptor']['Location'].rstrip('/')
s3_subpaths = _get_s3_subpaths(s3_location)
s3_registration = False
for s3_path in s3_subpaths:
if s3_path in s3_registered_locations:
print(f"S3 location: {s3_location} is already registered in Lake Formation, either directly or through its subpaths.")
s3_registration = True
break
if not s3_registration:
_register_s3_location(s3_location, role_arn, lf_client)
s3_registered_locations.append(s3_location)