in migration/bring-your-own-role/byor.py [0:0]
def _update_s3_lakeformation_registration(lakeformation, old_role_arn, new_role_arn, execute_flag):
print(f"Updating lakeformation resource registered with role: `{old_role_arn}` to role `{new_role_arn}`...\n")
resources_list = []
response = lakeformation.list_resources(
FilterConditionList=[
{
'Field': 'ROLE_ARN',
'ComparisonOperator': 'EQ',
'StringValueList': [
old_role_arn,
]
},
]
)
for resource in response['ResourceInfoList']:
resources_list.append(resource)
while response.get('NextToken'):
response = lakeformation.list_resources(
FilterConditionList=[
{
'Field': 'ROLE_ARN',
'ComparisonOperator': 'EQ',
'StringValueList': [
old_role_arn,
]
},
]
)
for resource in response['ResourceInfoList']:
resources_list.append(resource)
for resource in resources_list:
if execute_flag:
lakeformation.update_resource(
RoleArn=new_role_arn,
ResourceArn=resource['ResourceArn']
)
print(f"Successfully updated LakeFormation Resource: `{resource['ResourceArn']}` by updating RoleArn to `{new_role_arn}` successfully\n")
else:
print(f"Skipping updating LakeFormation Resource: `{resource['ResourceArn']}` by updating RoleArn to `{new_role_arn}`, set --execute flag to True to do the actual update.\n")