Skip to content

Instantly share code, notes, and snippets.

@cloudfiles-me
cloudfiles-me / RDS-Aurora-CloudFormation-Example.yaml
Created July 24, 2018 23:32 — forked from yyolk/RDS-Aurora-CloudFormation-Example.yaml
A basic CloudFormation template for an RDS Aurora cluster.
---
AWSTemplateFormatVersion: 2010-09-09
Description: A basic CloudFormation template for an RDS Aurora cluster.
Parameters:
DatabaseInstanceType:
Default: db.r3.large
AllowedValues:
- db.r3.large
- db.r3.xlarge
- db.r3.2xlarge
@cloudfiles-me
cloudfiles-me / vmware-ec2.md
Created July 10, 2018 17:16 — forked from RJ/vmware-ec2.md
Exporting VMWare images (OVA) from EC2

How to provision VMWare compatible .ova images on EC2

EC2 only lets you export instances as VMWare-compatible OVA files if you originally imported that instance from an OVA. Presumably it preserves the metadata and XML gubbins for the instance, and just wraps it up again using that metadata on export.

In order to provision arbitrary VMs in an OVA-exportable way, we abuse the volume snapshots on one VM.

Prep work:

  • Make a fresh install of ubuntu server or whatever your base distro is, in VMWare, export as OVA file. (single disk only!)
  • Untar the OVA and import the VMDK file into ec2 using ec2-instance-import onto an HVM instance type (ie, no xen kernel needed)
@cloudfiles-me
cloudfiles-me / parse_cloudfront_logs_bash.txt
Created July 10, 2018 03:59
Parsing CloudFront Logs in Bash
git clone https://github.com/tims/parse-extended-log-file.git
cd parse-extended-log-file
npm install
# After that we can use a simple script like this:
#!/bin/bash
for file in $(find . -iname "$1*"); do
cat $file | node parse-extended-log-file.js | jq '.'
@cloudfiles-me
cloudfiles-me / snsread.py
Created June 27, 2018 21:18 — forked from iMilnb/snsread.py
Basic Flask snippet to handle AWS SNS messages and subscription
from flask import Flask, request
import requests
import json
app = Flask(__name__)
def msg_process(msg, tstamp):
js = json.loads(msg)
msg = 'Region: {0} / Alarm: {1}'.format(
js['Region'], js['AlarmName']
@cloudfiles-me
cloudfiles-me / ssm_parameter_store.txt
Created June 19, 2018 23:06
Get parameter from SSM
import boto3
ssm = boto3.client('ssm')
parameter = ssm.get_parameter(Name='param_name', WithDecryption=True)
print(parameter['Parameter']['Value'])
@cloudfiles-me
cloudfiles-me / ssm_parameter_store.py
Created June 19, 2018 22:45 — forked from nqbao/ssm_parameter_store.py
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
import boto3
from botocore.exceptions import ClientError
import datetime
class SSMParameterStore(object):
"""
Provide a dictionary-like interface to access AWS SSM Parameter Store
"""
def __init__(self, prefix=None, ssm_client=None, ttl=None):
self._prefix = (prefix or "").rstrip("/") + "/"
@cloudfiles-me
cloudfiles-me / aws_global_ip.txt
Created June 19, 2018 20:25
AWS IP Range and some filtering example
wget https://ip-ranges.amazonaws.com/ip-ranges.json
Filter looking for GLOBAL Services (Cloudfront, Route53, etc.)
cat ip-ranges.json | jq '.prefixes[] | select(.region == "GLOBAL") | .ip_prefix'
openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in private_key.pem -out public_key.pem
@cloudfiles-me
cloudfiles-me / python-mysqlclient-amazon-linux.txt
Last active June 14, 2018 15:53
Install requeriments for python mysqlclient
Install in the instance:
yum install gcc mysql57-devel python36 python36-devel
@cloudfiles-me
cloudfiles-me / fix-python-mysqlclient-osx.txt
Last active June 15, 2018 02:00
Fix mysqlclient in differents OS
#OSX
brew install mariadb-connector-c
cd /usr/local/bin/
ln -s ../Cellar/mariadb-connector-c/version_installed/bin/mariadb_config mysql_config
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient
Ubuntu:
libmysqlclient-dev