Skip to content

Instantly share code, notes, and snippets.

@mvasilenko
mvasilenko / gist:108f53fb6bf00c112869c8043a41e1f0
Created July 12, 2024 07:51
ecs_run_migration_task_and_wait.rb
# frozen_string_literal: true
# This script is used during the deployment process. It runs 2 threads in parallel:
#
# 1) Calls run-task to execute a migration task within a cluster, and then waits for it to exit with 0 code.
# Throws an exception in case of non-0 exit code;
#
# 2) Waits for all the service to become stable after the deployment.
#
# Both have actually 10 minutes timeout, but if any of them fails before with an exception - the whole process dies immediatelly.
@mvasilenko
mvasilenko / aws_eks_configmap_auth_sso_admin
Created May 1, 2024 07:52
aws eks configmap auth sso admin
apiVersion: v1
data:
mapRoles: |
- rolearn: arn:aws:iam::661556513509:role/eksctl-aws-eks-cluster-1-nodegrou-NodeInstanceRole-KSVSFUXWT7C2
username: system:node:{{EC2PrivateDNSName}}
groups:
- system:bootstrappers
- system:nodes
- eks-console-dashboard-full-access-group
- rolearn: arn:aws:iam::661556513509:role/AWSReservedSSO_AdministratorAccess_fb8ce9637ede3a97
@mvasilenko
mvasilenko / aws_ec2_list_names.sh
Created January 24, 2024 08:25
list AWS EC2 instances with names
aws ec2 describe-instances --query 'Reservations[].Instances[].[PrivateIpAddress,Tags[?Key==`Name`].Value[]]' --output text | sed '$!N;s/\n/ /'
@mvasilenko
mvasilenko / gist:8e71ba8884e06c22087080a42dd0c6df
Last active January 3, 2024 11:02
github-list-org-repos-with-active-dependabot-security-issue-critical-and-high.py
""" Fetches all repos under a git organization
and returns last committer to master, date of commit, count of open dependabot security issues with high and critical severity
Results sorted by commit date
Replace ORG_NAME, USERNAME, and GH_TOKEN variables
GH_TOKEN required for authentication
This will use Rate limit at a rate of 1 per repo """
import os
import json
@mvasilenko
mvasilenko / git-remove-submodule.sh
Created April 8, 2023 11:06
how to remove git submodule
# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule
# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule
@mvasilenko
mvasilenko / github_check_alerts_critical_high.py
Last active October 21, 2021 03:48
GitHub security - list open dependabot alerts with critical/high severities
import argparse
import requests
import os
import sys
import yaml
headers = {"Authorization": "token {}".format(
os.environ.get('GITHUB_ADMIN_ORG_READ_TOKEN', ''))}
import csv
import sys
csv.field_size_limit(sys.maxsize)
MULTILINE_DELIMITER = "2021-09-"
FILENAME="test.csv"
PROGRESS_EVERY_LINES=1000000
print("Reading RDS csvlog, removing multilines")

Keybase proof

I hereby claim:

  • I am mvasilenko on github.
  • I am mvasilenko (https://keybase.io/mvasilenko) on keybase.
  • I have a public key ASASSXmI8z0EAqmbnrGYI04yWDdRLrffy8uXpNl6aXd55wo

To claim this, I am signing this object:

# for importing cloudflare hosted dns zones into terraform
# list zones
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/?per_page=100" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json"| jq -r '.result[] | "\(.id) \(.name)"'
# list records at the zone 1234567890
curl -X GET "https://api.cloudflare.com/client/v4/zones/1234567890/dns_records?per_page=100" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json"| jq -r '.result[] | "\(.id) \(.name)
@mvasilenko
mvasilenko / terraform_cloudflare_import.sh
Created November 11, 2020 15:15
import Cloudflare DNS record into terraform state
# set your CloudFlare key & email
export auth_email=$CLOUDFLARE_EMAIL
export auth_key=$CLOUDFLARE_TOKEN
# list your DNS zones hosted at CloudFlare
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/?per_page=100" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json"| jq -r '.result[] | "\(.id) \(.name)"'
# expected output:
# a3c9c7d3861e52cf23c835102c258d63 example1.com
# f47d1debb65621ca89039b9fbfeb726a example2.com