Skip to content

Commit 552d65a

Browse files
committed
Version 1.0.17
Fixes an issue where BatchGrantPermissions was not present, causing all back-permission grants from mesh to producer to fail and resulting in a None table reference.
1 parent 489153d commit 552d65a

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = aws-data-mesh-utils
3-
version = 1.0.16
3+
version = 1.0.17
44
author = Ian Meyers
55
author_email = [email protected]
66
license = Apache 2.0

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from setuptools import find_packages, setup
44

55
setup(
6-
install_requires=['boto3~=1.20.51',
6+
install_requires=['boto3~=1.26.121',
77
'pystache~=0.6.0',
8-
'setuptools~=60.8.1',
9-
'shortuuid~=1.0.8',
10-
'botocore~=1.23.51'],
8+
'setuptools~=67.7.2',
9+
'shortuuid~=1.0.11',
10+
'botocore~=1.29.121'],
1111
include_package_data=True
1212
)

src/data_mesh_util/DataMeshProducer.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _create_mesh_table(self, table_def: dict, data_mesh_glue_client, source_data
8989
data_mesh_database_name: str,
9090
producer_account_id: str,
9191
data_mesh_account_id: str, create_public_metadata: bool = True,
92-
expose_table_references_with_suffix: str = "_link", use_original_table_name: bool = False):
92+
expose_table_references_with_suffix: str = "_link", use_original_table_name: bool = False) -> tuple:
9393
'''
9494
API to create a table as a data product in the data mesh
9595
:param table_def:
@@ -162,28 +162,27 @@ def _create_mesh_table(self, table_def: dict, data_mesh_glue_client, source_data
162162
self._logger.info(f"Granted Describe on {table_name} to {DATA_MESH_READONLY_ROLENAME}")
163163

164164
# in the producer account, accept the RAM share after 1 second - seems to be an async delay
165-
if permissions_granted > 0:
166-
time.sleep(1)
167-
self._producer_automator.accept_pending_lf_resource_shares(
168-
sender_account=data_mesh_account_id
169-
)
165+
time.sleep(1)
166+
self._producer_automator.accept_pending_lf_resource_shares(
167+
sender_account=data_mesh_account_id
168+
)
170169

171-
# create a resource link for the data mesh table in producer account
172-
if use_original_table_name is True:
173-
link_table_name = table_name
174-
else:
175-
link_table_name = f"{table_name}_link"
176-
if expose_table_references_with_suffix is not None:
177-
link_table_name = f"{table_name}{expose_table_references_with_suffix}"
170+
# create a resource link for the data mesh table in producer account
171+
if use_original_table_name is True:
172+
link_table_name = table_name
173+
else:
174+
link_table_name = f"{table_name}_link"
175+
if expose_table_references_with_suffix is not None:
176+
link_table_name = f"{table_name}{expose_table_references_with_suffix}"
178177

179-
self._producer_automator.create_remote_table(
180-
data_mesh_account_id=self._data_mesh_account_id,
181-
database_name=data_mesh_database_name,
182-
local_table_name=link_table_name,
183-
remote_table_name=table_name
184-
)
178+
self._producer_automator.create_remote_table(
179+
data_mesh_account_id=self._data_mesh_account_id,
180+
database_name=data_mesh_database_name,
181+
local_table_name=link_table_name,
182+
remote_table_name=table_name
183+
)
185184

186-
return table_name, link_table_name
185+
return table_name, link_table_name
187186

188187
def _make_database_name(self, database_name: str):
189188
return "%s-%s" % (database_name, self._data_producer_identity.get('Account'))

src/data_mesh_util/lib/ApiAutomator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ def lf_batch_grant_permissions(self,
927927
if 'Failures' in response:
928928
perms_added -= len(response.get('Failures'))
929929

930-
return perms_added
930+
if perms_added == 0:
931+
self._logger.error(response.get('Failures'))
932+
raise Exception(f"Failed to grant permissions on Account {data_mesh_account_id}")
933+
else:
934+
return perms_added
931935

932936
def lf_grant_permissions(self, data_mesh_account_id: str, principal: str, database_name: str,
933937
table_name: str = None,

src/data_mesh_util/resource/producer_account_policy.pystache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"Sid": "ProducerAccess4",
4242
"Effect": "Allow",
4343
"Action": [
44+
"lakeformation:BatchGrantPermissions",
4445
"lakeformation:GrantPermissions",
4546
"lakeformation:GetResourceLFTags",
4647
"lakeformation:GetLFTag"

0 commit comments

Comments
 (0)