Skip to content

Instantly share code, notes, and snippets.

import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
import json
import requests
from pyspark import sql
from uuid import UUID
@kangks
kangks / S3-Lambda-Kinesis.yaml
Created June 9, 2017 04:22
Stack for S3 event -> Lambda transform from csv to json -> kinesis stream -> downstream Lambda for each row processing. These are the purpose of the demo: - Retry of downstream Lambda when failed. The record in Kinesis Stream will not be removed until success Runtime - With large CSV, the Lambda will parallel according to number of shards of Kin…
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
Comment: "Stack for S3 event -> Lambda transform from csv to json -> kinesis stream -> downstream Lambda for each row processing.
These are the purpose of the demo:
- Retry of downstream Lambda when failed. The record in Kinesis Stream will not be removed until success Runtime
- With large CSV, the Lambda will parallel according to number of shards of Kinesis Stream"
Resources:
IAMRole:
Type: "AWS::IAM::Role"
Properties:
@kangks
kangks / aws_emr.template.json
Created May 24, 2017 23:27
AWS CloudFormation template to create EMR-5.1.0 cluster
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Create AMR Cluster",
"Parameters": {
"ProductParam": {
"Description": "The EMR Product tag",
"Type": "String",
"Default": "aProductParam",
"MinLength": "3",
"MaxLength": "50",
@kangks
kangks / postgres96Ec2.json
Last active January 17, 2019 09:25
AWS Cloudformation for Ec2 with Postgres 96
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Create Linux EC2 with postgresql96",
"Metadata": {
"Comment": "Postgres 9.6 on a r3.8xlarge + 20G EBS in a privateSubnet, and pgbench in publicSubnet"
},
"Parameters": {
"Ec2KeyNameParam": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
@kangks
kangks / ec2TagCheck.py
Created May 19, 2017 21:01
Lambda function triggered by CloudTrail events to check for tagging, and notify the owner through SES if tagging not found
import boto3
required_keys = [ "key01", "key02", "key03", "key04" ]
ses_source = 'source@maildomain.com'
ses_destination = ['somebody@domain.com']
def lambda_handler(event, context):
if 'detail' in event and 'instance-id' in event['detail']:
ec2_instance_id = event['detail']['instance-id']