in src/lakeformation_automation/lambda_function.py [0:0]
def publish_sns(record):
""" Publishes the message to central perm SNS Topic
Arguments:
perm_record {dict} -- perm record to publish
Returns:
SNS Response {dict}
"""
sns_client = boto3.client('sns')
response_to_sns = {
"perms_to_set" : record
}
logger.info('record ---> {} '.format(record))
logger.info('sending event to sns ---> {} '.format(response_to_sns))
response = sns_client.publish(
TopicArn='arn:aws:sns:{}:{}:lakeformation-automation'.format(os.environ['REGION'],
os.environ['ACCOUNT_ID']),
Message= json.dumps(response_to_sns),
MessageStructure='string',
MessageAttributes={
'account_id': {
'DataType': 'String',
'StringValue': str(record['AccountID'])
}
}
)
logger.info('response from sns ---> {} '.format(response))
return response