I'm very new to AWS and this question could very well be impossible in AWS. I'm looking to create a static webpage with S3 that will show how many records are in a csv file. The csv is some fake data about employee attrition, so every row corresponds to an employee. The csv is already in an S3 bucket, and I have already set up the bucket to show a simple static webpage (see below).
Is it possible to use Lambda or anything else to display this record count on the webpage? Seems simple enough, yet I am struggling.
Below is my current webpage, and ideally I would like the record count to be where the big red "X" is.
Here is my lambda function so far:
import json
import os
import boto3
import csv
def lambda_handler(event, context):
for record in event['Records']:
bucket = record['s3']['bucket']['fakeemployee']
file_key = record['s3']['object']['Employee Attrition Data.xlsx']
s3 = boto3.client('s3')
csvfile = s3.get_object(Bucket=bucket, Key=file_key)
Here is my test configuration in AWS so far:
{
"Records": [
{
"s3": {
"bucket": {
"name": "fakeemployee",
"arn": "arn:aws:s3:::fakeemployee"
},
"object": {
"key": "Employee Attrition Data.xlsx",
"size": 242.1,
"eTag": "3df14b4d8bda007b946b9f176b89c9b5",
"sequencer": "0A1B2C3D4E5F678901"
}
}
}
]
}
Any advice?
EDIT: I have tried to create a API HTTP Gateway but have run into a "message not found" error when invoking. I used this tutorial to create the API gateway.
