I’m a Senior Software Engineer living in Berlin. Shifting limits based on quality and robustness. Cutting-edge software development. Defining durable and flexible interfaces. Creating rich and intuitive user experiences.

Useful Snippets

AWS CLI

List pending maintenance actions for a given AWS region

This Bash script retrieves all pending RDS maintenance actions for a specific AWS region (defaulting to us-east-1 if not set). It categorizes the maintenance actions (like CA certificate rotations or system updates) using jq for clearer visibility. The JSON output is temporarily saved and then deleted to maintain cleanliness.

#!/bin/bash
AWS_REGION="${AWS_REGION:-us-east-1}"
aws rds describe-pending-maintenance-actions \
--region $AWS_REGION \
--no-paginate > /tmp/pending-actions.json
cat /tmp/pending-actions.json | \
jq -r '{
"ca-certificate-rotation": [
.PendingMaintenanceActions[] |
select(.PendingMaintenanceActionDetails[].Action == "ca-certificate-rotation") |
.ResourceIdentifier
],
"db-upgrade": [
.PendingMaintenanceActions[] |
select(.PendingMaintenanceActionDetails[].Action == "db-upgrade") |
.ResourceIdentifier
],
"hardware-maintenance": [
.PendingMaintenanceActions[] |
select(.PendingMaintenanceActionDetails[].Action == "hardware-maintenance") |
.ResourceIdentifier
],
"system-update": [
.PendingMaintenanceActions[] |
select(.PendingMaintenanceActionDetails[].Action == "system-update") |
.ResourceIdentifier
]
}'
rm /tmp/pending-actions.json

List available IP addresses of AWS subnets

This AWS CLI command fetches details of subnets tagged with "Name=some-name", displaying only essential fields: available IP address count, subnet ARN, and CIDR block. It’s useful for checking subnet utilization at a glance.

aws ec2 describe-subnets \
--filters "Name=tag:Name,Values=some-name" \
| jq '.Subnets[] | with_entries(select(.key == ("AvailableIpAddressCount","SubnetArn","CidrBlock")))'

Kubernetes

Get all errored pods in a cluster

This kubectl command lists all pods across namespaces and filters for those with error states. It extracts pod names and their container error reasons, helping operators quickly pinpoint which pods are failing and why.

kubectl get pods -A \
-o custom-columns="POD:metadata.name,STATE:status.containerStatuses[*].state.waiting.reason" \
| grep -v "<none>"

Follow JSON logs and parse them on the fly

By combining kubectl logs with jq, this command streams logs from a Kubernetes pod and attempts to parse each line as JSON. This is especially helpful when dealing with structured logs in real time.

kubectl logs pods/my-pod -f \
| jq -R 'fromjson?'

Shell

Run command and split result into batches

This snippet takes a long list of items and uses awk to insert blank lines every 20 lines, effectively splitting the content into manageable batches. Ideal for paginating long output or for batch processing in scripts.

cat long-list \
| awk -v n=20 '1; NR % n == 0 {print ""}' > long-list-batches

Grep with colors

This command uses grep with color highlighting to visually emphasize matches for a search term in a file. Piping to less -r preserves the color formatting while enabling interactive scrolling.

grep --color=always -E "search-term|$" ./some.yaml \
| less -r

Grep with line numbers and X lines after

This grep command highlights lines matching a pattern and shows three lines of context after each match. It also includes line numbers, making it easier to locate and analyze relevant sections in larger files.

cat ./some.yaml | grep -A 3 -n search-term

Closing Thoughts

Whether you’re managing cloud resources, debugging applications, or manipulating files in the terminal, these small but powerful commands can save you time and reduce repetitive work. Keep them handy as part of your daily toolkit—they’re simple, flexible, and highly adaptable to many real-world scenarios.