Intentando otorgar permisos de lago a través de una función Lambda. (Python 3.8) Por lo que puedo ver, tengo mi código según la documentación. Sin embargo, se encuentra con un aluvión de errores sin sentido acerca de que los parámetros son incorrectos. ¿Será que solo necesito un óptico? ¿O es algún matiz o hacia dónde sopla hoy el viento amazónico?
import boto3 import json from botocore.exceptions import ClientError def main(event,context): client = boto3.client('lakeformation') response = client.grant_permissions( Principal={ 'DataLakePrincipalIdentifier': 'arn:aws:iam::123456789012:role/myRole' }, Resource={ 'Table': { 'DatabaseName': 'myDatabase', 'TableWildcard': {} }, }, Permissions=['ALL'], PermissionsWithGrantOption=['ALL'] )================================================== ====================================
[ERROR] ParamValidationError: la validación del parámetro falló: falta el parámetro requerido en Resource.Table: "Nombre" Parámetro desconocido en Resource.Table: "TableWildcard", debe ser uno de: DatabaseName, Name Traceback (la última llamada más reciente): Archivo "/ var/task/main.py", línea 10, en respuesta principal = client.grant_permissions( File "/var/runtime/botocore/client.py", línea 316, en _api_call return self._make_api_call(operation_name, kwargs) File " /var/runtime/botocore/client.py", línea 607, en _make_api_call request_dict = self._convert_to_request_dict( File "/var/runtime/botocore/client.py", línea 655, en _convert_to_request_dict request_dict = self._serializer.serialize_to_request( Archivo "/var/runtime/botocore/validate.py", línea 297, en serialize_to_request aumentar ParamValidationError(report=report.generate_report())
Investigué un poco el tema. Y el error se debe a que en lambda, la definición de TableResoures es (tenga en cuenta el TableWildcard que falta en lambda):
"TableResource":{ "type":"structure", "required":[ "DatabaseName", "Name" ], "members":{ "DatabaseName":{ "shape":"NameString", "documentation":"<p>The name of the database for the table. Unique to a Data Catalog. A database is a set of associated table definitions organized into a logical group. You can Grant and Revoke database privileges to a principal. </p>" }, "Name":{ "shape":"NameString", "documentation":"<p>The name of the table.</p>" } }, "documentation":"<p>A structure for the table object. A table is a metadata definition that represents your data. You can Grant and Revoke table privileges to a principal. </p>" }Por el contrario, la última versión en github tiene:
"TableResource":{ "type":"structure", "required":["DatabaseName"], "members":{ "CatalogId":{ "shape":"CatalogIdString", "documentation":"<p>The identifier for the Data Catalog. By default, it is the account ID of the caller.</p>" }, "DatabaseName":{ "shape":"NameString", "documentation":"<p>The name of the database for the table. Unique to a Data Catalog. A database is a set of associated table definitions organized into a logical group. You can Grant and Revoke database privileges to a principal. </p>" }, "Name":{ "shape":"NameString", "documentation":"<p>The name of the table.</p>" }, "TableWildcard":{ "shape":"TableWildcard", "documentation":"<p>A wildcard object representing every table under a database.</p> <p>At least one of <code>TableResource$Name</code> or <code>TableResource$TableWildcard</code> is required.</p>" } }Me parece que esto es un error.