Skip to content

Instantly share code, notes, and snippets.

@mlapida
mlapida / EBS-Orphaned-Report-Lambda.py
Last active April 29, 2022 08:10
Generate a report of orphaned EBS volumes and send an SNS. A full writeup can be found on my site http://mlapida.com/thoughts/lambda-tracking-orphaned-ebs-volumes
import boto3
import logging
from datetime import *
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
#define the connection
ec2 = boto3.resource('ec2', region_name="us-west-2")
@mlapida
mlapida / CloudWatchLogsKinesisFirehose-Lambda.py
Last active October 3, 2019 01:01
A short Lambda Function the can be sent CloudWatch Logs (in the case Flow Logs) and send them to Kinesis Firehose for storage in S3. A full writeup can be found on my site http://mlapida.com/thoughts/exporting-cloudwatch-logs-to-s3-lambda
import boto3
import logging
import json
import gzip
from StringIO import StringIO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
client = boto3.client('firehose')
@mlapida
mlapida / EC2-Tag-Assets-Lambda.py
Last active January 17, 2024 08:10
A lambda function that will copy EC2 tags to all related Volumes and Network Interfaces. A full writeup can be found on my site https://empty.coffee/tagging-and-snapshotting-with-lambda/ - Thank you to the community for keeping this updated!
from __future__ import print_function
import json
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
@kwilczynski
kwilczynski / disable-ipv6.sh
Last active December 22, 2025 00:41
Amazon Linux OS tweaks
#!/bin/bash
set -u
set -e
set -o pipefail
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cat <<'EOF' > /etc/modprobe.d/blacklist-ipv6.conf
{
"type": "record",
"name": "amazon-log",
"namespace": "com.streambright.avro",
"fields": [{
"name": "bucket_owner",
"type": "string",
"doc": "The canonical user ID of the owner of the source bucket."
}, {
"name": "bucket",
@innermond
innermond / s3up
Created February 9, 2016 08:46
Minify, compress and put to an s3 bucket. It depends on awscli
#!/bin/bash
root=~/Projects/printuridigital.ro
src=$root/src
dist=$root/dist
what=$1
options_s3=$2
if [ -z $1 ]; then echo need file argument; exit; fi
type=${1##*.}
file_src=$src/$type/$what
file_min=$dist/$type/$what
@ijin
ijin / lambda_git.py
Created February 18, 2016 03:01
use git from lambda
from __future__ import print_function
import os
import sys
import subprocess
import boto3
from botocore.client import Config
from dulwich.errors import (
SendPackError,
@albertmenglongli
albertmenglongli / combineS3Files.py
Created September 9, 2016 03:21 — forked from jasonrdsouza/combineS3Files.py
Python script to efficiently concatenate S3 files
'''
This script performs efficient concatenation of files stored in S3. Given a
folder, output location, and optional suffix, all files with the given suffix
will be concatenated into one file stored in the output location.
Concatenation is performed within S3 when possible, falling back to local
operations when necessary.
Run `python combineS3Files.py -h` for more info.
'''
@simplesteph
simplesteph / swagger.json
Created October 13, 2016 03:44
Apache NiFi 1.0.0 swagger.json
{
"swagger" : "2.0",
"info" : {
"description" : "The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and \n stop processors, monitor queues, query provenance data, and more. Each endpoint below includes a description,\n definitions of the expected input and output, potential response codes, and the authorizations required\n to invoke each service.",
"version" : "1.0.0",
"title" : "NiFi Rest Api",
"contact" : {
"url" : "https://nifi.apache.org",
"email" : "dev@nifi.apache.org"
},
@alopresto
alopresto / csr-to-keystore.txt
Created October 27, 2016 00:20
Steps and output for generating a public/private keypair, a CSR to get it signed by an external CA, and then importing the signed certificate and certificate chain into a JKS keystore for use in Apache NiFi.
hw12203:/Users/alopresto/Workspace/scratch/csr-demo (master) alopresto
🔓 3s @ 16:33:45 $ keytool -genkey -alias nifi -keyalg RSA -keysize 2048 -keystore keystore.jks
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: nifi.apache.org
What is the name of your organizational unit?
[Unknown]: NiFi
What is the name of your organization?
[Unknown]: Apache