automated-deployment/consumption-account/template.yaml [298:337]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              logger.info('Revoking Lakeformation Permissions ....')
              try:
                  resource = {}
                  if table_json:
                      resource['Table'] = table_json
                  elif tableWithColumns_json:
                      resource['TableWithColumns'] = tableWithColumns_json
                  client = boto3.client('lakeformation', config=Config(connect_timeout=5, read_timeout=60, retries={'max_attempts': 20}))
                  response= client.revoke_permissions(Principal=principal_json,
                                          Resource=resource,
                                          Permissions=perm_json['Permissions'])
                  logger.info('Revoke permissions API response: {}'.format(response))
                  return response
              except Exception as e:
                  logger.info("Revoke permissions Method failed with exception {}".format(e))
                  raise e

          def lambda_handler(event, context):
              try:
                  logger.info('Received {} messages'.format(len(event['Records'])))
                  logger.info('messages {}'.format(event))
                  for record in event['Records']:
                      event_body = json.loads(json.loads(record['body'])['Message'])['perms_to_set']
                      logger.info('Processing Permissions for: {}'.format(event_body))
                      principal_json, table_json, tableWithColumns_json, perm_json = buildjson(event_body)
                  logger.info('created permissions JSONs - principal json : {},table_json {},tableWithColumns_json {}, perm_json {} '
                    .format(principal_json, table_json, tableWithColumns_json, perm_json))

                  if event_body['AccessType'].lower() == 'grant':
                      logger.info('Calling Grant permissions for {} on resource {} or {} permissions {}'.format(principal_json, table_json, tableWithColumns_json, perm_json))
                      response = grant_lf_permissions(principal_json, table_json, tableWithColumns_json, perm_json)
                  elif event_body['AccessType'].lower() == 'revoke':
                      logger.info('Calling Grant permissions for {} on resource {} or {} permissions {}'.format(principal_json, table_json, tableWithColumns_json, perm_json))
                      response = revoke_lf_permissions(principal_json, table_json, tableWithColumns_json, perm_json)
                  else:
                      raise LFAttributeError
              except Exception as e:
                  logger.error("Fatal error", exc_info=True)
                  raise e
              return
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/lakeformation_permissions/consumption/lambda_function.py [253:292]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    logger.info('Revoking Lakeformation Permissions ....')
    try:
        resource = {}
        if table_json:
            resource['Table'] = table_json
        elif tableWithColumns_json:
            resource['TableWithColumns'] = tableWithColumns_json
        client = boto3.client('lakeformation', config=Config(connect_timeout=5, read_timeout=60, retries={'max_attempts': 20}))
        response= client.revoke_permissions(Principal=principal_json,
                                Resource=resource,
                                Permissions=perm_json['Permissions'])
        logger.info('Revoke permissions API response: {}'.format(response))
        return response
    except Exception as e:
        logger.info("Revoke permissions Method failed with exception {}".format(e))    
        raise e

def lambda_handler(event, context):
    try:
        logger.info('Received {} messages'.format(len(event['Records'])))
        logger.info('messages {}'.format(event))
        for record in event['Records']:
            event_body = json.loads(json.loads(record['body'])['Message'])['perms_to_set']
            logger.info('Processing Permissions for: {}'.format(event_body))
            principal_json, table_json, tableWithColumns_json, perm_json = buildjson(event_body)
        logger.info('created permissions JSONs - principal json : {},table_json {},tableWithColumns_json {}, perm_json {} '
          .format(principal_json, table_json, tableWithColumns_json, perm_json))
        
        if event_body['AccessType'].lower() == 'grant':
            logger.info('Calling Grant permissions for {} on resource {} or {} permissions {}'.format(principal_json, table_json, tableWithColumns_json, perm_json))
            response = grant_lf_permissions(principal_json, table_json, tableWithColumns_json, perm_json)
        elif event_body['AccessType'].lower() == 'revoke':
            logger.info('Calling Grant permissions for {} on resource {} or {} permissions {}'.format(principal_json, table_json, tableWithColumns_json, perm_json))
            response = revoke_lf_permissions(principal_json, table_json, tableWithColumns_json, perm_json)
        else:
            raise LFAttributeError
    except Exception as e:
        logger.error("Fatal error", exc_info=True)
        raise e
    return
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



