Automated Employee Data Upload Playbook with AWS Lambda & S3
Last updated
Was this helpful?
Last updated
Was this helpful?
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 .
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 .
Requests a pre-signed upload URL from .
Uploads the employee data CSV to BalkanID.
Logs the process and handles errors.
This ensures seamless integration and real-time entitlement updates without manual intervention.
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.
If you do not have an S3 bucket, create one using the AWS CLI or AWS Console.
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.
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.
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.
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.
In AWS Lambda Console, navigate to:
Configuration → Environment variables → Edit → Add variables:
BALKANID_API_KEY_ID
Your API Key ID
BALKANID_API_KEY_SECRET
Your API Key Secret
Upload a File to S3
Run this command to manually upload a test employee CSV file:
This should automatically trigger the Lambda function, processing the file and uploading it to BalkanID.
Check CloudWatch Logs
If debugging is required, view logs in AWS CloudWatch:
Go to AWS CloudWatch Console.
Select Logs → Lambda → Find your Lambda function logs.
Check for any errors or confirmation messages.