This Lambda function will allow you to search your existing log archives in s3 and send them to Mezmo Pipeline via S3/SQS Source.
- Navigate to Simple Queue Service in AWS
- Choose create queue. For type, choose
Standard
. - Leave all other settings as default and click Create Queue
- Add the S3 Source to your pipeline
- Enter your SQS Queue URL, Access Key ID, Secret Access Key and Region
- Click save
You may have noticed this setup is very similar to the setup for S3 Source. This is on purpose. The way this source works is by listening to New File events sent from S3 to SQS. This function aims to mimic that, but also you to choose which files to send.
- Create a new AWS Lambda function and select
Author from scratch
. - Click on the Lambda function to edit the details:
- Code entry type:
Upload a .ZIP file
- Upload the Mezmo Pipeline Restoration from S3 function .ZIP File.
- Handler:
index.handler
- Runtime:
Node.js.20.x
For Execution role, assign a role that has the following policies:
You can do this a number of ways. If you are doing this through the AWS Management Console, you can run create a test event. Do so with the following Event JSON:
bucket
(required): The bucket your archive files are locatedregion
(required): The region your archive files are locatedpath
(optional): If you have stored your files somewhere other than root, place your path here (eg:subpath/
)archivePrefix
(optional, defaults tomerged_
): This lambda function is looking for files patterned with this prefix then a unix time. Change this if you have a different prefixqueueUrl
(required): The URL of the SQS Queue you have setup in PipelinestartDate
(required): A Javascipt date time string*endDate
(required): A Javascipt date time string*
Please note that dates provided are inclusive in the search
Compatibility with Mezmo Pipeline S3 Destination
Please note that this project is set up to assist with restoiring files created by the Mezmo S3 destination. This destination has a feature to combine small archive files into larger ones and named merged_UNIXTIME.log
. The archive prefix is defaulted to merged_
because of this setup. *Additionally, the dates searched are the dates written into the filename and not the dates in the properties of the file.
Here is an example:
{
"bucket": "my-archive-bucket",
"region": "us-east-1",
"path": "somesubpath/",
"queueUrl": "https://sqs.us-east-1.amazonaws.com/000000000000/my-sqs-queue",
"startDate": "2024-01-17T00:00:00Z",
"endDate": "2024-01-17T23:59:59Z"
}