Automated employee data upload playbook with AWS Lambda & S3
This provides a step-by-step guide to deploying an AWS Lambda function that automatically reads entitlement data from an S3 bucket and uploads it to BalkanID using our employee upload API.
Note: To get your tenant's BalkanID API key and Secret, please follow steps here.
Overview
When a CSV file is uploaded to a specified Amazon S3 bucket, the Lambda function is triggered automatically. The function:
Retrieves the uploaded file from S3.
Transforms the uploaded file to BalkanID employee CSV format specified in this page.
This ensures seamless integration and real-time entitlement updates without manual intervention.
Prerequisites
Before setting up the Lambda function, ensure you have:
• An AWS S3 bucket to store employee data.
• An IAM role with necessary permissions.
• BalkanID API credentials (X-Api-Key-ID, X-Api-Key-Secret).
• Basic knowledge of AWS Lambda, IAM, and S3.
Create an S3 Bucket
If you do not have an S3 bucket, create one using the AWS CLI or AWS Console.
Create an IAM Role for Lambda
Lambda needs permission to read files from S3 and write logs to CloudWatch.
Create an IAM Role
Go to AWS IAM Console → Roles → Create Role.
Select AWS Service → Lambda.
Attach the following policies:
AmazonS3ReadOnlyAccess (allows Lambda to read from S3)
AWSLambdaBasicExecutionRole (for logging to CloudWatch)
Click Create Role and copy the Role ARN.
Deploy the AWS Lambda Function
Create the Lambda Function
Go to AWS Lambda Console → Create Function.
Select Author from scratch.
Configure:
Function Name: s3-to-balkanid
Runtime: Python 3.x
Role: Select the IAM role you created earlier.
Click Create Function.
Add an S3 Trigger
Configure S3 Event Notification
Open your S3 bucket in the AWS Console.
Go to Properties → Event Notifications.
Click Create Event Notification:
Name: TriggerLambdaOnUpload
Event types: Select PUT
Prefix: (Optional - If you only want to trigger on specific files/folders)
Destination: Select Lambda Function
Choose your Lambda function (s3-to-balkanid)
Click Save.
Lambda Function Code
Replace this code in the Lambda Function Code section. Include any transformation necessary to transform your CSV format to BalkanID employee CSV format as part of the lambda_handler function.