Skip to content

Instantly share code, notes, and snippets.

@yannhowe
yannhowe / gist:d77e7cee67415ba1a9ee17663a9f1f2f
Created February 29, 2024 04:33
Count ECS Fargate Tasks in Account for default region
#!/bin/bash
clusters=$(aws ecs list-clusters --query 'clusterArns' --output text)
total_tasks=0
for cluster in $clusters; do
task_count=$(aws ecs list-tasks --cluster $cluster --query 'length(taskArns[])')
total_tasks=$((total_tasks + task_count))
done
echo "Total ECS tasks in all clusters in the account, region: $total_tasks"
@yannhowe
yannhowe / qualys-totalcloud-custom-policy.json
Created August 25, 2023 02:45
qualys-totalcloud-custom-policy - 20230825
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "QualysCustomPolicyPermissions",
"Effect": "Allow",
"Action": [
"states:DescribeStateMachine",
"elasticfilesystem:DescribeFileSystemPolicy",
"qldb:ListLedgers",
@yannhowe
yannhowe / qualys-totalcloud-fargate-profile.json
Last active August 25, 2023 02:43
Qualys TotalCloud EKS Fargate Profile - 20230825
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "InventoryPermissions",
"Effect": "Allow",
"Action": [
"eks:ListFargateProfiles",
"eks:DescribeFargateProfile"
],
@yannhowe
yannhowe / get-running-task-patch-status.sh
Created January 26, 2023 09:04
Get a list of running task definitions and their patch status
#!/bin/bash
aws ecs list-clusters | jq --raw-output 'map(.[])| .[]' | while read -r CLUSTER; do
aws ecs list-tasks --cluster "$CLUSTER" --desired-status RUNNING --launch-type FARGATE --no-paginate | jq --raw-output 'map(.[])| .[]' | while read -r TASK; do
aws ecs describe-tasks --cluster "$CLUSTER" --tasks "$TASK" | jq ".tasks | .[] | .taskDefinitionArn" | awk -F "/" '{print $NF}' | tr -d '"' | while read -r RUNNINGTASKDEFINITION; do
echo "cluster, taskDefinitionArn, patchStatus"
echo -n "$CLUSTER, $RUNNINGTASKDEFINITION, "
# 'Checking for string "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh" in entrypoint'
if aws ecs describe-task-definition --task-definition "$RUNNINGTASKDEFINITION" | grep -q "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh"
then
echo patched
@yannhowe
yannhowe / get-task-patch-status.sh
Last active January 26, 2023 08:17
Find out patch status of ECS tasks
#!/bin/bash
# 'Checking for string "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh" in entrypoint'
echo "taskDefinitionArn, patchStatus"
aws ecs list-task-definitions | jq --raw-output 'map(.[])| .[]' | while read -r i; do
echo -n "$i, "
if aws ecs describe-task-definition --task-definition "$i" | grep -q "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh"
then
echo patched
else
echo not patched
@yannhowe
yannhowe / complete-demo.yaml
Created May 5, 2020 14:01
Sock Shop demo kube manifest fix for >1.16
apiVersion: app/v1
kind: Deployment
metadata:
name: carts-db
labels:
app: carts-db
namespace: sock-shop
spec:
replicas: 1
template:
@yannhowe
yannhowe / gist:1a7f3f174a0888b8acd30c31faab2b6d
Created December 9, 2019 06:43
Choco install dev environment
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install adobereader vlc git 7zip teamviewer mremoteng telegram whatsapp vmware-powercli-psmodule bosh-cli vmwarevsphereclient govc kubernetes-cli docker-compose docker-desktop vault kubernetes-helm vscode vscode-gitlens vscode-docker scode-gitignore vscode-icons vscode-ansible microsoft-windows-terminal terraform
@yannhowe
yannhowe / docker-images.list
Last active September 17, 2018 07:10
Get list of docker images, save, then load
nginx:1.15
registry:2
python:3.7-stretch
node:8.12-jessie
@yannhowe
yannhowe / satellite_setup.sh
Created May 16, 2018 14:40
Connects to RHN, sets up required repositories and installs Satellite
sudo subscription-manager register
sudo subscription-manager attach
sudo subscription-manager refresh
sudo subscription-manager repos --enable=rhel-7-server-satellite-6.3-rpms --enable=rhel-server-rhscl-7-rpms --enable=rhel-7-server-rpms
sudo yum clean all
sudo yum repolist enabled
sudo yum update
sudo yum upgrade
sudo yum install satellite
@yannhowe
yannhowe / anti_virus_downloader.ps1
Last active January 9, 2020 20:05
Powershell to download McAfee and ClamAV Patches
# Had to seperate downloading of each product files instead of providing URL list and finding all links due to laziness to handle relative and absolute linking. Perhaps one day I'll fix it.
$start_time = Get-Date
$download_folder = "D:\Anti-Virus Patches"
# Download URL list
$mcafee_page_url = "http://download.nai.com/products/DatFiles/4.x/NAI/"
$mcafee_file_path = "http://download.nai.com/products/DatFiles/4.x/NAI/"
$clamav_page_url = "https://www.clamav.net/downloads/"
$clamav_file_path = "http://database.clamav.net/"
$trendmicro_page_url = "http://downloadcenter.trendmicro.com/index.php?clk=tab_pattern&clkval=5&regs=NABU&lang_loc=1"