SlideShare a Scribd company logo
1 of 11
Download to read offline
Step-by-step process to load the log data into DynamoDB from AWS S3 – AWS Serverless
Architecture
Architecture Diagram:
Steps to implement the solution:
1. Create the appropriate role
2. Create the S3 bucket
3. Log files (Jason format)
4. Create the Lambda function with S3 trigger
5. Create the Dynamodb table
6. Create the in-line policy with the DynamoDB ARN
7. Load data/ files into S3
8. Test the flow
Create the appropriate role (mm-lambda-s3):
Create the S3 bucket (mmload-logdata-to-dynamodb):
Sample Log files (Json format):
[
{
"id": "AIDAIS3D5PJFEDMLRVSFG1",
"type": "IAMUser",
"eventTime": "2022-06-11T23:54:55Z",
"eventSource": "ec2.amazonaws.com",
"eventName": "DescribeInstances",
"awsRegion": "us-west-1",
"requestID": "db14c600-332d-4ef9-b68a-bbe4749110bd",
"eventID": "4284e768-20c0-4b02-b2a0-af08da75ccfa"
},
{
"id": "AIDAIS3D5PJFEDMLRVSFG2",
"type": "IAMUser",
"eventTime": "2022-06-11T23:55:32Z",
"eventSource": "ec2.amazonaws.com",
"eventName": "DescribeSecurityGroups",
"awsRegion": "us-west-1",
"requestID": "b862c4da-e427-4a24-8faf-6e748a4dddf0",
"eventID": "9282b6a6-14a8-4e79-b09b-5ecb7580dc5b"
}
]
Create the Lambda function with S3 trigger:
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const documentClient = new AWS.DynamoDB.DocumentClient();
exports.handler = async (event) => {
let statusCode = 0;
let responseBody = '';
const { name } = event.Records[0].s3.bucket;
const { key } = event.Records[0].s3.object;
const getObjectParams = {
Bucket: name,
Key: key
};
try {
const s3Data = await s3.getObject(getObjectParams).promise();
const usersStr = s3Data.Body.toString();
const usersJSON = JSON.parse(usersStr);
console.log(`Users ::: ${usersStr}`);
await Promise.all(usersJSON.map(async user => {
const { id, type, eventTime, eventSource, eventName, awsRegion, requestID, eventID } = user;
const putParams = {
TableName: "mm-logdata-from-s3",
Item: {
id: id,
type: type,
eventTime: eventTime,
eventSource: eventSource,
eventName: eventName,
awsRegion: awsRegion,
requestID: requestID,
eventID: eventID
}
};
await documentClient.put(putParams).promise();
}));
responseBody = 'Succeeded adding users';
statusCode = 201;
} catch(err) {
responseBody = 'Error adding users';
statusCode = 403;
}
const response = {
statusCode: statusCode,
body: responseBody
};
return response;
};
Create the Dynamodb table:
Create the in-line policy with the DynamoDB ARN:
Upload data/ files into S3 and check the entries into DynamoDB table:
Load Log Data into DynamoDB

More Related Content

Similar to Load Log Data into DynamoDB

Building a Serverless Pipeline
Building a Serverless PipelineBuilding a Serverless Pipeline
Building a Serverless PipelineJulien SIMON
 
Building Your First Big Data Application on AWS
Building Your First Big Data Application on AWSBuilding Your First Big Data Application on AWS
Building Your First Big Data Application on AWSAmazon Web Services
 
AWS APAC Webinar Week - Launching Your First Big Data Project on AWS
AWS APAC Webinar Week - Launching Your First Big Data Project on AWSAWS APAC Webinar Week - Launching Your First Big Data Project on AWS
AWS APAC Webinar Week - Launching Your First Big Data Project on AWSAmazon Web Services
 
AWS September Webinar Series - Building Your First Big Data Application on AWS
AWS September Webinar Series - Building Your First Big Data Application on AWS AWS September Webinar Series - Building Your First Big Data Application on AWS
AWS September Webinar Series - Building Your First Big Data Application on AWS Amazon Web Services
 
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoTAmazon Web Services
 
(BDT205) Your First Big Data Application On AWS
(BDT205) Your First Big Data Application On AWS(BDT205) Your First Big Data Application On AWS
(BDT205) Your First Big Data Application On AWSAmazon Web Services
 
AWS Lambda - A quick introduction #advancedaws
AWS Lambda - A quick introduction #advancedawsAWS Lambda - A quick introduction #advancedaws
AWS Lambda - A quick introduction #advancedawsChris Richardson
 
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...Amazon Web Services
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016Amazon Web Services Korea
 
Serverless architecture with AWS Lambda (June 2016)
Serverless architecture with AWS Lambda (June 2016)Serverless architecture with AWS Lambda (June 2016)
Serverless architecture with AWS Lambda (June 2016)Julien SIMON
 
(SEC318) AWS CloudTrail Deep Dive
(SEC318) AWS CloudTrail Deep Dive(SEC318) AWS CloudTrail Deep Dive
(SEC318) AWS CloudTrail Deep DiveAmazon Web Services
 
AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings Adam Book
 
Create a serverless architecture for data collection with Python and AWS
Create a serverless architecture for data collection with Python and AWSCreate a serverless architecture for data collection with Python and AWS
Create a serverless architecture for data collection with Python and AWSDavid Santucci
 
Living on the edge at Netflix - Adrian Cole
Living on the edge at Netflix - Adrian ColeLiving on the edge at Netflix - Adrian Cole
Living on the edge at Netflix - Adrian Colejaxconf
 
AWS DYNAMODB TWO CASE STUDIES.pdf
AWS DYNAMODB TWO CASE STUDIES.pdfAWS DYNAMODB TWO CASE STUDIES.pdf
AWS DYNAMODB TWO CASE STUDIES.pdfhayhadiabbas
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaAmazon Web Services
 

Similar to Load Log Data into DynamoDB (20)

Building a Serverless Pipeline
Building a Serverless PipelineBuilding a Serverless Pipeline
Building a Serverless Pipeline
 
TIAD 2016 : Building a Serverless Pipeline
TIAD 2016 : Building a Serverless PipelineTIAD 2016 : Building a Serverless Pipeline
TIAD 2016 : Building a Serverless Pipeline
 
Building Your First Big Data Application on AWS
Building Your First Big Data Application on AWSBuilding Your First Big Data Application on AWS
Building Your First Big Data Application on AWS
 
AWS APAC Webinar Week - Launching Your First Big Data Project on AWS
AWS APAC Webinar Week - Launching Your First Big Data Project on AWSAWS APAC Webinar Week - Launching Your First Big Data Project on AWS
AWS APAC Webinar Week - Launching Your First Big Data Project on AWS
 
Amazon Rekognition Workshop
Amazon Rekognition WorkshopAmazon Rekognition Workshop
Amazon Rekognition Workshop
 
AWS September Webinar Series - Building Your First Big Data Application on AWS
AWS September Webinar Series - Building Your First Big Data Application on AWS AWS September Webinar Series - Building Your First Big Data Application on AWS
AWS September Webinar Series - Building Your First Big Data Application on AWS
 
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
(MBL305) You Have Data from the Devices, Now What?: Getting the Value of the IoT
 
(BDT205) Your First Big Data Application On AWS
(BDT205) Your First Big Data Application On AWS(BDT205) Your First Big Data Application On AWS
(BDT205) Your First Big Data Application On AWS
 
AWS Lambda - A quick introduction #advancedaws
AWS Lambda - A quick introduction #advancedawsAWS Lambda - A quick introduction #advancedaws
AWS Lambda - A quick introduction #advancedaws
 
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...
Scalable, Automated Anomaly Detection with GuardDuty, CloudTrail, & Amazon Sa...
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
Serverless architecture with AWS Lambda (June 2016)
Serverless architecture with AWS Lambda (June 2016)Serverless architecture with AWS Lambda (June 2016)
Serverless architecture with AWS Lambda (June 2016)
 
(SEC318) AWS CloudTrail Deep Dive
(SEC318) AWS CloudTrail Deep Dive(SEC318) AWS CloudTrail Deep Dive
(SEC318) AWS CloudTrail Deep Dive
 
AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings
 
Create a serverless architecture for data collection with Python and AWS
Create a serverless architecture for data collection with Python and AWSCreate a serverless architecture for data collection with Python and AWS
Create a serverless architecture for data collection with Python and AWS
 
Living on the edge at Netflix - Adrian Cole
Living on the edge at Netflix - Adrian ColeLiving on the edge at Netflix - Adrian Cole
Living on the edge at Netflix - Adrian Cole
 
AWS DYNAMODB TWO CASE STUDIES.pdf
AWS DYNAMODB TWO CASE STUDIES.pdfAWS DYNAMODB TWO CASE STUDIES.pdf
AWS DYNAMODB TWO CASE STUDIES.pdf
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS Lambda
 
AWS CloudFormation Macros
AWS CloudFormation MacrosAWS CloudFormation Macros
AWS CloudFormation Macros
 
Introduction to MXNet & Lambda
Introduction to MXNet & LambdaIntroduction to MXNet & Lambda
Introduction to MXNet & Lambda
 

More from Manas Mondal

Medium Documents - List of my Medium Documents
Medium Documents - List of my Medium DocumentsMedium Documents - List of my Medium Documents
Medium Documents - List of my Medium DocumentsManas Mondal
 
Amazon DataZone.pdf
Amazon DataZone.pdfAmazon DataZone.pdf
Amazon DataZone.pdfManas Mondal
 
EnterpriseLogManagement.pdf
EnterpriseLogManagement.pdfEnterpriseLogManagement.pdf
EnterpriseLogManagement.pdfManas Mondal
 
AWS TransferFamily
AWS TransferFamilyAWS TransferFamily
AWS TransferFamilyManas Mondal
 
OracleEBS Data Load
OracleEBS Data LoadOracleEBS Data Load
OracleEBS Data LoadManas Mondal
 
AWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideAWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideManas Mondal
 

More from Manas Mondal (8)

Medium Documents - List of my Medium Documents
Medium Documents - List of my Medium DocumentsMedium Documents - List of my Medium Documents
Medium Documents - List of my Medium Documents
 
Amazon DataZone.pdf
Amazon DataZone.pdfAmazon DataZone.pdf
Amazon DataZone.pdf
 
EnterpriseLogManagement.pdf
EnterpriseLogManagement.pdfEnterpriseLogManagement.pdf
EnterpriseLogManagement.pdf
 
AWS TransferFamily
AWS TransferFamilyAWS TransferFamily
AWS TransferFamily
 
AWS AppFlow
AWS AppFlowAWS AppFlow
AWS AppFlow
 
OracleEBS Data Load
OracleEBS Data LoadOracleEBS Data Load
OracleEBS Data Load
 
AWS DataSync.pdf
AWS DataSync.pdfAWS DataSync.pdf
AWS DataSync.pdf
 
AWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On GuideAWS Application Migration Service-Hands-On Guide
AWS Application Migration Service-Hands-On Guide
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistandanishmna97
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 

Recently uploaded (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 

Load Log Data into DynamoDB

  • 1. Step-by-step process to load the log data into DynamoDB from AWS S3 – AWS Serverless Architecture Architecture Diagram: Steps to implement the solution: 1. Create the appropriate role 2. Create the S3 bucket 3. Log files (Jason format) 4. Create the Lambda function with S3 trigger 5. Create the Dynamodb table 6. Create the in-line policy with the DynamoDB ARN 7. Load data/ files into S3 8. Test the flow Create the appropriate role (mm-lambda-s3):
  • 2. Create the S3 bucket (mmload-logdata-to-dynamodb): Sample Log files (Json format): [ { "id": "AIDAIS3D5PJFEDMLRVSFG1", "type": "IAMUser", "eventTime": "2022-06-11T23:54:55Z", "eventSource": "ec2.amazonaws.com", "eventName": "DescribeInstances", "awsRegion": "us-west-1", "requestID": "db14c600-332d-4ef9-b68a-bbe4749110bd",
  • 3. "eventID": "4284e768-20c0-4b02-b2a0-af08da75ccfa" }, { "id": "AIDAIS3D5PJFEDMLRVSFG2", "type": "IAMUser", "eventTime": "2022-06-11T23:55:32Z", "eventSource": "ec2.amazonaws.com", "eventName": "DescribeSecurityGroups", "awsRegion": "us-west-1", "requestID": "b862c4da-e427-4a24-8faf-6e748a4dddf0", "eventID": "9282b6a6-14a8-4e79-b09b-5ecb7580dc5b" } ] Create the Lambda function with S3 trigger:
  • 4. const AWS = require('aws-sdk'); const s3 = new AWS.S3(); const documentClient = new AWS.DynamoDB.DocumentClient(); exports.handler = async (event) => { let statusCode = 0; let responseBody = ''; const { name } = event.Records[0].s3.bucket; const { key } = event.Records[0].s3.object; const getObjectParams = {
  • 5. Bucket: name, Key: key }; try { const s3Data = await s3.getObject(getObjectParams).promise(); const usersStr = s3Data.Body.toString(); const usersJSON = JSON.parse(usersStr); console.log(`Users ::: ${usersStr}`); await Promise.all(usersJSON.map(async user => { const { id, type, eventTime, eventSource, eventName, awsRegion, requestID, eventID } = user; const putParams = { TableName: "mm-logdata-from-s3", Item: { id: id, type: type, eventTime: eventTime, eventSource: eventSource, eventName: eventName, awsRegion: awsRegion, requestID: requestID, eventID: eventID } }; await documentClient.put(putParams).promise();
  • 6. })); responseBody = 'Succeeded adding users'; statusCode = 201; } catch(err) { responseBody = 'Error adding users'; statusCode = 403; } const response = { statusCode: statusCode, body: responseBody }; return response; };
  • 8. Create the in-line policy with the DynamoDB ARN:
  • 9.
  • 10. Upload data/ files into S3 and check the entries into DynamoDB table: