Skip to content

Instantly share code, notes, and snippets.

@eechukwu
eechukwu / aws_lambda_cloudwatch_logs_exporter.md
Created February 10, 2022 23:46 — forked from doi-t/aws_lambda_cloudwatch_logs_exporter.md
Export logs from CloudWatch Logs to S3 with AWS Lambda

event example

TASK_NAME=${1:-'export_logs'}
FROM=${2:-'2017-12-24 12:00'}
TO=${3:-'2017-12-24 12:05'}
cat <<-EOF > event.json
{
    "taskName": "$TASK_NAME",
    "fromTime": `gdate --date="$FROM" +%s%3N`,
 "toTime": `gdate --date="$TO" +%s%3N`
import boto3
import os
import datetime
"""
This portion will obtain the Environment variables from AWS Lambda.
"""
GROUP_NAME = os.environ['GROUP_NAME']
@eechukwu
eechukwu / ec2-apache.sh
Created July 25, 2020 19:37 — forked from herrera-ignacio/ec2-apache.sh
EC2 User data: install Apache web server for Amazon Linux 2 Image
#!/bin/bash
########################################
##### USE THIS WITH AMAZON LINUX 2 #####
########################################
# get admin privileges
sudo su
# install httpd (Linux 2 version)