Skip to content

Instantly share code, notes, and snippets.

from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
from boto3 import Session
def assumed_session(role_arn, session_name, session=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
@miztiik
miztiik / repo-reset.md
Created December 3, 2018 22:27 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@miztiik
miztiik / reinvent.md
Created August 22, 2017 01:57 — forked from henrysher/reinvent.md
link for reinvent slides
@miztiik
miztiik / wordpress.json
Created July 24, 2017 07:19 — forked from geertj/wordpress.json
CloudFormation template for Wordpress
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Scalable Wordpress instance",
"Parameters": {
"InstanceType": {
"Type": "String",
"Description": "Instance type",
"Default": "t2.medium",
"AllowedValues": [ "t2.medium", "t2.large" ]
@miztiik
miztiik / aws_sg_recipe.py
Created February 28, 2017 15:46 — forked from steder/aws_sg_recipe.py
Create and update AWS security groups using Python and Boto.
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
@miztiik
miztiik / kubernetes-aws.sh
Created February 28, 2017 07:09 — forked from miguelfrde/kubernetes-aws.sh
Kubernetes AWS
sudo apt-get update
sudo apt-get install -y python-pip
sudo pip install awscli
aws configure # enter credentials for a user with full s3,ec2 access / admin access
export KUBERNETES_PROVIDER=aws
export KUBE_AWS_ZONE=us-west-2a
export KUBE_AWS_INSTANCE_PREFIX=k8s
export KUBE_MINION_IMAGE=ami-9abea4fb # Ubuntu server 14.04
@miztiik
miztiik / gist:551fe97118c23c265c698186f50f20dc
Last active January 6, 2017 10:46 — forked from Khoulaiz/gist:41b387883a208d6e914b
Checking ports without telnet

Here are several different ways to test a TCP port without telnet.

$ cat < /dev/tcp/127.0.0.1/22
SSH-2.0-OpenSSH_5.3
^C

$ cat &lt; /dev/tcp/127.0.0.1/23
@miztiik
miztiik / bash.generate.random.alphanumeric.string.sh
Last active August 29, 2015 14:27 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
function genStringPatterns() {
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@miztiik
miztiik / Notepad++_userDefineLang-for-Dockerfile.xml
Last active September 2, 2021 21:05 — forked from centic9/userDefineLang_Dockerfile.xml
notepad++ syntax highlighting for Dockerfiles
<NotepadPlus>
<UserLang name="Dockerfile" ext="Dockerfile" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03 04 00# 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>