Skip to content

Instantly share code, notes, and snippets.

View prog893's full-sized avatar
🧨
best-effort deployments

Torgayev Tamirlan prog893

🧨
best-effort deployments
View GitHub Profile
@prog893
prog893 / README.md
Last active August 6, 2024 00:45
CloudFront Signed Cookie generator in Python

CloudFront Signed Cookie generator

For signed URLs, refer here

Usage

from cloudfront_signed_url import generate_cloudfront_signed_url

url = "https://your-cf-domain.com/path/to/file.txt"
cookie = generate_cloudfront_signed_cookie(url, 3600)
@prog893
prog893 / README.md
Last active April 10, 2018 07:08
ECS Container Instance scale-in protector
@prog893
prog893 / README.md
Last active October 22, 2024 11:57
S3 versioned bucket empty tool

S3 versioned bucket empty tool

For those times when you try to delete a versioned S3 bucket on AWS that has millions of objects/versions in it. (Should also work on non-versioned buckets as well)

Usage

The following options are available:

  • --bucket (required): name of the bucket to delete
  • --profile: profile name in ~/.aws/config to use when sending requests to AWS API (e.g. foo for [profile foo] in ~/.aws/config file). Default is default.
@prog893
prog893 / lambda-runtimes.sh
Created July 17, 2019 03:51
List all Lambda runtimes used in all regions
#!/bin/bash
# all regions (2019/07/17)
regions=("ap-northeast-1" "ap-northeast-2" "ap-northeast-3" "ap-south-1" "ap-southeast-1" "ap-southeast-2" "ca-central-1" "eu-central-1" "eu-north-1" "eu-west-1" "eu-west-2" "eu-west-3" "sa-east-1" "us-east-1" "us-east-2" "us-west-1" "us-west-2")
for region in "${regions[@]}"
do
echo "Lambda runtimes used in region ${region}"
aws lambda list-functions --region ${region} | jq '.Functions[].Runtime' | sort | uniq
done
@prog893
prog893 / pullreq.sh
Last active July 23, 2019 06:09
pullreq: Put this to your shell profile and create pull requests in seconds
function pullreq {
CURRENT_BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
REPO_ORIGIN=$(git remote get-url --push origin)
GHE_URL="your-github-enterprise.com"
if [[ ${CURRENT_BRANCH_NAME} == "master" ]] ;
then
echo "You are on master branch! Doing nothing"
return
fi
@prog893
prog893 / README.md
Last active April 11, 2024 15:29
CloudFront Signed URL generator in Python

CloudFront Signed URL generator in Python

For signed cookies, refer here

Usage

from cloudfront_signed_url import generate_cloudfront_signed_url

generate_cloudfront_signed_url("https://your-cf-domain.com/path/to/file.txt", 3600)
@prog893
prog893 / tf_state_extract.py
Created August 27, 2019 10:03
Filter tfstate resources with regex by resource path
#!/usr/local/bin/python3
import json
import argparse
import re
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Filter tfstate resources by resource path')
parser.add_argument('tfstate', type=str, help="tfstate file to parse")
@prog893
prog893 / user_data.sh
Last active September 26, 2019 05:11
AWS EC2 user_data OS detector pattern prototype
#!/bin/bash
set -euox pipefail
IFS=$'\n\t'
# https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-log-user-data
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
# Detect OS
if [ -e "/etc/os-release" ]; then
@prog893
prog893 / about_me.md
Last active January 24, 2020 08:15
About prog893 (JP)

プログラミングヤクザ (@prog893)

Twitter: @prog893

Instagram: @yakuzavisuals

経歴

  • 2014年4月 - 2018年4月 静岡大学 情報学部 情報科学科
@prog893
prog893 / sample_git_ssh.tf
Created December 2, 2019 09:03
Sample of Git+SSH module sourcing in Terraform
module "hoge" {
source = "git+ssh://[email protected]/baikonur-oss/terraform-aws-iam-nofile?ref=v1.0.2"
...
}