Skip to content

Instantly share code, notes, and snippets.

View riccardomc's full-sized avatar
🐢
I am a turtle

Riccardo M. Cefala riccardomc

🐢
I am a turtle
View GitHub Profile
@riccardomc
riccardomc / checkecr.sh
Created May 31, 2018 13:07
Quick and dirty script to check the number of images in ECR repositories and if there is an associated lifecycle policy
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
REPOS=$(aws ecr describe-repositories --query 'repositories[*].repositoryName' | jq -r '.[]')
for r in $REPOS ; do
printf $r
@riccardomc
riccardomc / checkecr2.sh
Created November 29, 2018 10:11
Delete older images in AWS ECR
#!/bin/bash
#
# Go through every repository and delete N older images where N > $LIMIT
#
# i.e. LIMIT=700 ./checkecr2.sh
#
set -e
# Limit
@riccardomc
riccardomc / dns.go
Created November 29, 2018 10:14
Minimal DNS proxy in golang. Reply NXDOMAIN for AAAA queries.
package main
import (
"log"
"net"
"os"
"strconv"
"github.com/miekg/dns"
)
@riccardomc
riccardomc / sqsfifo.sh
Created November 29, 2018 10:28
Use AWS SQS as a FIFO queue
#!/bin/bash
#
# SQS Fifo
#
#aws sqs create-queue --queue-name q.fifo --attributes FifoQueue=true
queue=https://eu-west-1.queue.amazonaws.com/12345678910/q.fifo
pop() {
message=$(aws sqs receive-message --queue-url $queue --query 'Messages[0]')
@riccardomc
riccardomc / oidc-thumbprint.sh
Created November 28, 2019 10:52
Extract OIDC provider thumbprint given an AWS EKS cluster name
#!/bin/bash
set -e
if [ ! -z "$DEBUG" ] ; then
set -x
fi
CLUSTER_NAME=$1
@riccardomc
riccardomc / oidc-thumbprint-regions.sh
Created November 28, 2019 11:19
Extract OIDC provider thumbprint for all AWS Region with EKS support
#!/bin/bash
set -e
if [ ! -z "$DEBUG" ] ; then
set -x
fi
REGIONS="us-east-2
us-east-1
@riccardomc
riccardomc / argo.sh
Created July 7, 2020 08:44
do things in argo without browser
# FIXME: argocd-server default password is the podname, should we use proper secrets?
ARGOCD_PASSWORD=$(kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2)
# How many seconds to wait for cluster services to be up before giving up. 600s = 10mins.
ARGOCD_TIMEOUT=600
# login to argocd server using port forward
argocd login \
--insecure \
--port-forward \
--port-forward-namespace argocd \
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCdbG4o5IR8c+8n+z9y+TVRSEqylBsQumEsDZ7DUprCv8ZS5XcKbOvLMb7It8STg8zHzFQbbvkpQeSwstJ9q6fbbp2RdG/gbXxRscTYvnZ3f2shN9v0u1yry+wZIZTYeygZ1H0BgwHGO9/tEKloudzlxMUqaJXlpPIOCSDTDTC1qG967c3/uwlVSbord48PQYQ9WPfVq8ludX6+W7r64GMTRVVXtKeJNUBMPc29Tixlo+OjRWxb9F6SEEH0RIo44ZrYAlQJ6xTZk7PNyCyfgcJF0wxDk4UDw51YjmYSMzrjDr4lWs3Yk0oQxFOXpgdDxduMInZQcL674kxBSxkSe4oX [email protected]