Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / crypto_currency_ingest_elasticsearch.py
Created June 27, 2017 07:06
Ingest Crypto Currency Data into Elasticsearch using the coinmarketcap API
## Resources:
# https://pypi.python.org/pypi/coinmarketcap/
# https://coinmarketcap.com/api/
import json
import requests
from coinmarketcap import Market
c = Market()
@ruanbekker
ruanbekker / alpine-python27_Dockerfile
Created July 18, 2017 14:41
Dockerfile for Python 2.7 on Alpine 3.6 (233MB)
FROM alpine:3.6
MAINTAINER Ruan Bekker
RUN apk update && \
apk add \
dumb-init \
musl \
linux-headers \
build-base \
@ruanbekker
ruanbekker / python_mailer_smtplib.py
Created July 26, 2017 15:25
Python SMTP Mailer using Amazon SES (smtplib)
import sys
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
name = "Ruan"
from_address = "no-reply@mydomain.com"
to_address = "ruan@mydomain.com"
subject = "Test"
@ruanbekker
ruanbekker / get_untagged_ec2.py
Last active February 12, 2019 01:29
AWS EC2: Get All Untagged EC2 Instances
import boto3
# setting region, profile from credential provider
session = boto3.Session(
region_name='eu-west-1',
profile_name='myprofile'
)
# declare ec2
ec2 = session.client('ec2')
@ruanbekker
ruanbekker / s3_get_bucket_acls_public.py
Last active August 1, 2017 19:19
Get All S3 Bucket Names that is Public Readable, and if so set to Private
import boto3
GROUPS_ALLUSERS = 'http://acs.amazonaws.com/groups/global/AllUsers'
GLOBAL_AUTHUSERS = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers'
s3 = boto3.client('s3')
list_buckets = s3.list_buckets()['Buckets']
available_buckets = []
@ruanbekker
ruanbekker / rocketchat_invoke_webhook_python.py
Created August 2, 2017 23:06
Invoke Rocketchat Incoming Webhook with Python
import requests
import json
uri = 'https://domain.com/hooks/1234AbcD'
data={}
data = {
"username": "Python Bot",
"icon_emoji": ":whale:",
"attachments": [
{
@ruanbekker
ruanbekker / cheatsheet-elasticsearch.md
Last active April 24, 2024 00:11
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@ruanbekker
ruanbekker / report-untagged-aws-resources.py
Created August 10, 2017 14:11
Report Untagged AWS Resources using CSV reader in Python (Per Service and Detailed)
# get the csv from:
# https://resources.console.aws.amazon.com/r/tags
import csv
from collections import Counter
with open('resources.csv', 'rb') as csvfile:
print("Missing Tags Per Service:")
print("=========================")
reader = csv.DictReader(csvfile)
@ruanbekker
ruanbekker / aws-boto3-set-profile-name.py
Last active July 30, 2019 19:13
Basic Boto3 Code for AWS to Set the Profile Name
import boto3
# setting region, profile from credential provider
session = boto3.Session(
region_name='eu-west-1',
profile_name='aws'
)
# declare ec2
ec2 = session.client('ec2')
@ruanbekker
ruanbekker / cheatsheet-aws-iam-s3.md
Last active August 14, 2017 06:32
AWS IAM S3 Policy Cheatsheet for S3

IAM Policies for S3

S3 Bucket Policy

IAM Policy:

List Bucket, Read Access to Objects in Path:

{