Skip to content

Instantly share code, notes, and snippets.

@jpbarto
jpbarto / AWS-Tooling.md
Last active December 13, 2017 23:37
Catalog of open source tools for managing AWS resources

AWS Tooling Catalog

The following is a living catalog of tools that I have found for managing AWS resources.

AWS Account Management

  • AWS-Daleks - A tool for purging everything (almost) in an AWS account
  • Cloud Custodian - Account governance tool built by Capital One
  • AWS-Tailor - Collection of Lambda functions for configuring new AWS accounts

AWS Security

AWSTemplateFormatVersion: '2010-09-09'
Description: >
A sample ElasticBeanstalk cloudformation template that deploys a 2 (MinSize) cluster of PHP servers
behind an application load balancer listening on both port 80 and 8080. The ALB is placed (ideally)
into a set of public subnets with the PHP servers in private subnets.
Parameters:
ec2Subnets:
Type: List<AWS::EC2::Subnet::Id>
Description: Subnets for PHP servers
@jpbarto
jpbarto / region_network_stats.py
Last active March 26, 2018 23:42
Retrieve the ingress and egress network metrics for all EC2 instances in a given AWS account and region
#!/usr/bin/python
from datetime import datetime, timedelta
import boto3
# region to query and what AWS credentials profile to use
REGION = 'eu-west-2'
PROFILE = 'default'
MONTH_PERIOD = 3600 * 24 * 30 # ask CloudWatch to average over a 30 day
@jpbarto
jpbarto / readme.md
Last active July 17, 2018 09:21
Light speed on AWS

the following estimates the theoretical network latency for travelling roughly half way around the earth

circumference of earth = 40075 km

speed of light = 299792.458 km / s

( circumference of earth ) / 2 ) / ( speed of light ) = seconds to travel from one side of globe to another

(40075 / 2) / (299792.458) = 0.0668 seconds

67 ms ideal travel time from one side of globe to another

@jpbarto
jpbarto / process_cognito_users.py
Last active January 12, 2024 13:13
Simple script to read users in a Cognito user pool, check them for failed logins, and put those failed logins to CloudWatch logs
#!/usr/bin/env python3
"""
The following script demonstrates how to use the AWS Boto3 SDK to iterate through
all of the users in an AWS Cognito User Pool and examine the events associated
with each user.
If any failed authentication events are found the script formats them as messages
and logs them to CloudWatch logs.
This script could easily be modified to run periodically as a Lambda function
@jpbarto
jpbarto / websocket-nlb-test.tf
Created March 16, 2019 21:57
A Terraform template to create an AWS autoscaling group tied to a network load balancer, to test the ability to create a Socket.IO server that has no route to the Internet
##
## AMI created using
## curl -sL https://rpm.nodesource.com/setup_11.x | bash -
## yum install -y git nodejs
## git clone https://github.com/socketio/socket.io.git
##
## cd socket.io
## npm install
## cd examples/chat
## npm install
@jpbarto
jpbarto / video-game-sales.ipynb
Created March 26, 2019 16:17
Sample Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jpbarto
jpbarto / simple_sklearn_transformer.py
Created June 20, 2019 08:05
Simple SKLearn script to transform some inputs using the SKLearn Estimator on Amazon SageMaker
import pandas as pd
import numpy as np
import argparse
from sklearn import preprocessing
import pickle
import os
from io import StringIO
from sagemaker_containers.beta.framework import (
content_types, encoders, env, modules, transformer, worker)
@jpbarto
jpbarto / sagemaker_training_job.json
Created June 20, 2019 11:19
Sample Script Container Invoke
{
"TrainingJobName": "cli-t-job",
"HyperParameters": {
"sagemaker_submit_directory": "s3://sagemaker-eu-west-2-776347453069/sagemaker-scikit-learn-2019-06-19-13-21-02-471/source/sourcedir.tar.gz",
"sagemaker_program": "sklearn_abalone_featurizer.py",
"sagemaker_enable_cloudwatch_metrics": "false",
"sagemaker_container_log_level": "20",
"sagemaker_job_name": "sagemaker-scikit-learn-2019-06-19-13-21-02-471",
"sagemaker_region": "eu-west-2"
},
@jpbarto
jpbarto / private-eks-nodes.yaml
Created July 29, 2019 06:44
Private EKS Worker Nodes - CloudFormation
###
#
# CloudFormation Template to create EKS Worker Nodes without access to an IGW
#
# The following CloudFormation template is based upon the AWS-provided CloudFormation template for creating
# EKS worker nodes in your VPC. It differs in that it has user-data modified to configure a node to operate
# within a VPC that has no IGW.
#
# To use this template you will need a VPC with an EKS cluster already deployed and private access enabled.
# You will also need a web proxy configured to allow the worker nodes access to the AWS EKS service API. This