Skip to content

Instantly share code, notes, and snippets.

@sysboss
sysboss / query_athena.py
Created May 21, 2018
SQL Query Amazon Athena using Python
View query_athena.py
#!/usr/bin/env python3
#
# Query AWS Athena using SQL
# Copyright (c) Alexey Baikov <sysboss[at]mail.ru>
#
# This snippet is a basic example to query Athen and load the results
# to a variable.
#
# Requirements:
# > pip3 install boto3 botocore retrying
@sysboss
sysboss / ec2_tags_as_bash_variables.sh
Created Aug 21, 2017
Get all EC2 tags and set them as Bash variables
View ec2_tags_as_bash_variables.sh
#!/bin/bash
#
# EC2 tags to variables
# Copyright (c) Alexey Baikov <sysboss[at]mail.ru>
#
# Description:
# Gets all EC2 tags and converts them to Bash variables
# Based on 'jq' (https://stedolan.github.io/jq/)
INSTANCE_REGION="$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | tr -d ' ' | cut -f2 -d: | tr -d '"' | tr -d ',')"
@gene1wood
gene1wood / role_arn_to_session.py
Created Dec 29, 2016
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
View role_arn_to_session.py
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@eladnava
eladnava / mongodb-s3-backup.sh
Last active Aug 21, 2021
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
View mongodb-s3-backup.sh
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
View modify-docker-image.md

Modifying an Existing Docker Image

To install a custom package or modify an existing docker image we need to

  1. run a docker a container from the image we wish to modify
  2. modify the docker container
  3. commit the changes to the container as a docker image
  4. test changes made to image

1.) Running a docker container from an image