Skip to content

Instantly share code, notes, and snippets.

@Nicolas-Richard
Nicolas-Richard / set_env_var_to_all_services_in_env.py
Last active April 9, 2024 15:19
This script is used to set or remove environment variables in all services in a given environment.
"""
This script is used to set or remove environment variables in all services in a given environment.
Usage: python set_env_var_to_all_services_in_env.py <mode> <env> <var_name> <var_value>
"""
import glob
import os
import sys
from ruamel.yaml import YAML
import pexpect
services = [
"service-foo",
"service-bar",
]
def send_cmd_wait_and_catch_timeout(child, cmd, timeout=30):
try:
@Nicolas-Richard
Nicolas-Richard / update_node_group_launch_template.sh
Last active July 14, 2023 15:15
This script updates the Amazon EKS node groups associated with a given EKS cluster to use the latest version of the launch template.
#!/bin/bash
# ----------------------------------------------
# This script updates the Amazon EKS node groups
# associated with a given EKS cluster to use the
# latest version of the launch template.
#
# Usage:
# ./update_node_group_launch_template.sh <AWS_PROFILE> <AWS_REGION> <CLUSTER_NAME>
#
@Nicolas-Richard
Nicolas-Richard / fetch_logs_plot_errors.sh
Last active June 27, 2023 23:51
This script fetches logs from an AWS EKS cluster log group, filters for "error" messages, counts the events, and appends the timestamp and events count to a data file for a specified time range.
#!/bin/bash
: '
This script fetches logs from an AWS EKS cluster log group, filters for "error" messages, counts the events, and appends the timestamp and events count to a data file for a specified time range.
The time range is defined by the start_time and end_time variables, and the script iterates over each minute in this range.
The output data file is used to plot a graph using gnuplot, with time on the x-axis and events count on the y-axis.
This script requires that `awscli`, `jq` and `gnuplot` be installed in your environment.
It also requires that you have access to the specified AWS EKS cluster log group.
'
@Nicolas-Richard
Nicolas-Richard / setDefaultAppToOpenFile.sh
Created June 13, 2023 22:36
Make all text files and code files open with Sublime on MacOS (using Duti)
#!/bin/bash
# You need https://github.com/moretension/duti (installable via `brew`)
# and of course Sublime
# Set the bundle identifier for Sublime Text
sublime_bundle_identifier="com.sublimetext.4"
# List of file extensions
file_extensions=(
@Nicolas-Richard
Nicolas-Richard / create_prs.sh
Last active March 19, 2024 17:29
Script to create pull requests with batches of modified files in the current git branch
#!/bin/bash
: '
This script automates the process of creating pull requests for batches of modified files in a Git repository.
Each batch contains a specified number of files, and each batch is committed to a new branch with a pull request created for it.
The script supports optional arguments for specifying a prefix for branch names, creating draft pull requests, and setting the batch size.
Usage:
./create_prs.sh [-p <PREFIX>] [-d] [-b <BATCH_SIZE>] <JIRA_TICKET>
@Nicolas-Richard
Nicolas-Richard / asg_refresh.sh
Created March 21, 2023 23:29
This script triggers and monitors an ASG refresh.
#!/bin/bash
ASG_NAME=$1
region=$2
profile=$3
export AWS_DEFAULT_REGION=$region
export AWS_PROFILE=$profile
@Nicolas-Richard
Nicolas-Richard / asg_view.sh
Created March 21, 2023 17:54
This script lists the Auto Scaling groups in an AWS account that have the "eks:cluster-name" tag matching the specified value, along with the number of instances in each group and the oldest launch time of those instances.
#!/bin/bash
# Filename: asg_view.sh
#
# Description: This script lists the Auto Scaling groups in an AWS account that have the "eks:cluster-name" tag
# matching the specified value, along with the number of instances in each group and the oldest
# launch time of those instances. It uses the AWS CLI to query the necessary information.
#
# Usage: ./asg_view.sh <cluster_name> <region> <profile>
#
@Nicolas-Richard
Nicolas-Richard / tags_review.sh
Created January 25, 2023 16:57
Utility script to identify AWS resources missing tags by parsing the TF state file.
# Utility script to identify AWS resources missing tags by parsing the TF state file.
# vision for this tool :
# produce a report of missing tags per workspace
# Invoke like this to display the untagged resources :
# tags_review.sh