Skip to content

Instantly share code, notes, and snippets.

@acdha
acdha / get-vpc-resources-blocking-encryption-enforcement.py
Created December 2, 2025 19:38
Report AWS VPC resources which are blocking enforcement of VPC Encryption Controls (https://docs.aws.amazon.com/vpc/latest/userguide/vpc-encryption-controls.html)
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "boto3",
# ]
# ///
"""
Report non-compliant resources blocking VPC Encryption Control enforcement
#!/usr/bin/env -S uv run
# /// script
# dependencies = [
# "boto3",
# ]
# ///
"""
Report marketplace AMIs across all of the accounts in an Organization
Assumes AWS credentials for an account which has permission to query a Config
@acdha
acdha / chupalambda
Created October 18, 2024 00:25
AWS Lambda sucker - handy for introspecting your Lambda packages
#!/bin/bash
set -e -u -o pipefail
LAMBDA="$1"
if [ -z "$LAMBDA" ]; then
echo "Usage: $0 lambda-function-name" > /dev/stderr; exit 1
fi
@acdha
acdha / newsblur.opml
Created May 15, 2023 14:08
Tech-related NewsBlur subscriptions
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.1">
<!--Generated by NewsBlur - newsblur.com-->
<head>
<title>NewsBlur Feeds</title>
<dateCreated>2023-05-15 14:04:44.095425</dateCreated>
<dateModified>2023-05-15 14:04:44.095425</dateModified>
</head>
<body>
<outline text="Web" title="Web">
@acdha
acdha / filter_nones.py
Last active January 21, 2023 01:33
Example of how to exclude Nones from JSON-encoded output, optionally destructively
#!/usr/bin/env python3
"""
Example of how to non-destructively remove None values from an object before
JSON serialization
"""
import json
def filter_nones(obj):
@acdha
acdha / Podman as a Docker Desktop replacement.md
Last active July 13, 2024 06:05
Instructions for using Podman as a Docker.app replacement on MacOS

Podman as a Docker Desktop alternative

Prerequisites

  1. Install Homebrew from https://brew.sh

Install Podman

$ brew install podman
@acdha
acdha / eternal-march.py
Created January 9, 2021 22:17
eternal-march.py
from datetime import date
ordinal = lambda n: "%d%s" % (n, "tsnrhtdd" [(n // 10 % 10 != 1) * (n % 10 < 4) * n % 10::4])
dom = date.today() - date(year=2020, month=3, day=1)
print(f"Today is March {ordinal(dom.days)}, 2020")
#!/usr/bin/env python3
"""
Bulk register AWS Accounts with Qualys AssetView
Given a list of account IDs, registers them and prints CSV output of the Account
ID and External ID in the format expected by the account setup Terraform code.
A list of accounts to register can be obtained like this::
$ grep -vf <(csvgrep --invert-match --columns 'External ID' --regex '^$' account-setup/qualys-assetview-accounts.csv | csvcut -c 'Account ID' | sed 1d) \
[defaults]
interpreter_python = auto_silent
vault_password_file=get_vault_password_from_keyring
[ssh_connection]
# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
@acdha
acdha / development.aws_ec2.yaml
Created August 10, 2020 22:50
Ansible dynamic inventory using EC2 tags
---
plugin: aws_ec2
regions:
- us-east-1
filters:
instance-state-name: running
tag:Project: MyProject
tag:Environment: Development
hostnames:
- instance-id