Skip to content

Instantly share code, notes, and snippets.

View eugenestarchenko's full-sized avatar
:octocat:

Eugene S eugenestarchenko

:octocat:
View GitHub Profile
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.
@eugenestarchenko
eugenestarchenko / Update-branch.md
Created March 2, 2020 13:15 — forked from santisbon/Update-branch.md
Bring your feature branch up to date with master. Deploying from Git branches adds flexibility. Bring your branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master

Clone botocore and run `git rev-list --all > commit_list.txt` to get a chrological list of the hashes.
Then I manually installed https://github.com/nok/git-walk but had to modify it to use my list instead of generating it's own each time because it was going into a loop.
So `read_commit_ids` looks like this:
```
def read_commit_ids():
#cmd = 'git rev-list --all'
#log = subp.check_output(cmd.split()).strip()
#log = [line.strip() for line in log.split('\n')]
with open("commit_list.txt") as f:
@eugenestarchenko
eugenestarchenko / 9 cUrl tips
Created November 27, 2019 08:52 — forked from arielallon/9 cUrl tips
9 cUrl tips
Working with HTTP from the command-line is a valuable skill for HTTP architects and API designers to have. The cURL library and curl command give you the ability to design a Request, put it on the pipe, and explore the Response. The downside to the power of curl is ho https://httpkit.com/resources/HTTP-from-the-Command-Line/ w much breadth its options cover. Running curl --help spits out 150 different flags and options. This article demonstrates nine basic, real-world applications of curl .
In this tutorial we’ll use the httpkit echo service as our end point. The echo server’s Response is a JSON representation of the HTTP request it receives.
Make a Request
Let’s start with the simplest curl command possible.
@eugenestarchenko
eugenestarchenko / lambda_function-ECS-cloudwatch-slack.py
Created November 4, 2019 12:25 — forked from mskutin/lambda_function-ECS-cloudwatch-slack.py
Lambda function that takes ECS Cloudwatch events and sends a notification to Slack
# Written by Dane Fetterman on 12/1/2016
# https://aws.amazon.com/blogs/compute/monitor-cluster-state-with-amazon-ecs-event-stream/
# Where they use a cloud watch event from ECS to notify a SNS topic. We're
# sending a notification directly to slack instead
import requests
import json
from boto3 import session, client
@eugenestarchenko
eugenestarchenko / ubuntu_14.04.sh
Created October 29, 2019 12:36 — forked from VJftw/ubuntu_14.04.sh
Jenkins AWS EC2 Slave Plugin Init Script
# AMI: ami-f95ef58a (Standard Ubuntu 14.04)
# - Remote user: ubuntu
# - Remote FS root: /var/jenkins
# - Spot instance: true
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates
echo "--> Setting up Docker repository"
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee -a /etc/apt/sources.list.d/docker.list

What is DNS?

  • DNS is used to convert human-friendly domain names (abantej.github.io) into an internet protocol (185.199.108.153) address
  • IP addresses are used by computers to identify each other on the network. IP addresses commonly come in 2 different forms, IPv4 and IPv6

IPv4

  • 32 bit field with over 4 billion different addresses (4,294,967,296)

IPv6

  • 128 bit field with 340 undecillion addresses (340,282,366,920,938,463,463,374,607,431,768,211,456)
@eugenestarchenko
eugenestarchenko / dynamodb_purge_table.py
Created September 18, 2019 11:51 — forked from brettfreer/dynamodb_purge_table.py
Purge all items from an AWS dynamodb table with an exponential timing back-off
#!/usr/bin/env python3
""" Purge all items from an AWS dynamodb table with an exponential timing back-off
"""
import logging
from time import sleep
import boto3
from botocore.exceptions import ClientError
@eugenestarchenko
eugenestarchenko / create-aws-console-user.sh
Created August 12, 2019 18:25 — forked from res0nat0r/create-aws-console-user.sh
Create AWS console user from the awscli
#!/bin/bash
# USAGE: ./create-aws-console-user.sh $GROUPNAME $USERNAME $PASSWORD
# http://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_cliwpsapi
# Create administrator group
aws iam create-group --group-name $1
@eugenestarchenko
eugenestarchenko / awsEc2MetadataShortcuts.sh
Created July 2, 2019 18:27 — forked from mambroziak/awsEc2MetadataShortcuts.sh
AWS EC2 Instance Metadata to BASH Script Variables
#!/bin/bash
# JQ is required to more easily parse json.
AWS_IAM_ROLE=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/`
AWS_ACCESS_KEY_ID=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.AccessKeyId'`
AWS_SECRET_ACCESS_KEY=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.SecretAccessKey'`
AWS_TOKEN=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.Token'`
AWS_AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
AWS_DEFAULT_REGION="`echo \"$AWS_AZ\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
LOCAL_IP=`curl -sL http://169.254.169.254/latest/meta-data/local-ipv4`
PUBLIC_IP=`curl -sL http://169.254.169.254/latest/meta-data/public-ipv4`