Skip to content

Instantly share code, notes, and snippets.

@thedoc31
thedoc31 / aws-search-all-r53-zones.txt
Created August 13, 2024 20:59
Search all AWS zones in an account for a particular value
Need to obtain a list of all valid zone IDs for the account first. Can run from CLI or CloudShell
while read zone || [[ -n $zone ]]; do echo $zone && aws route53 list-resource-record-sets --hosted-zone-id $zone --query "ResourceRecordSets[?ResourceRecords[?Value == '<your_value>']"; done <your_zone_list.txt
@thedoc31
thedoc31 / aws-get-all-r53-zone-ids.txt
Last active August 13, 2024 20:55
Grab a list of all Route53 domain IDs for an account
Run from CLI or CloudShell
aws route53 list-hosted-zones | grep "Id" | grep -Eo 'Z[A-Z0-9]{8,32}'
@thedoc31
thedoc31 / httpd.service
Created April 26, 2024 17:12
Using official httpd apache container with systemd for Rundeck
[Unit]
Description=Apache httpd reverse proxy docker container for Rundeck SAML support
Documentation=https://httpd.apache.org/docs/2.4/
After=docker.service
After=rundeck.service
Requires=docker.service
[Service]
Restart=on-failure
TimeoutStartSec=0
@thedoc31
thedoc31 / gist:20efc33bf5507a08374c07e2fe6b745d
Created April 26, 2024 16:53
Rundeck + mod_auth_mellon httpd reverse proxy for SAML
Searches that helped me fix the config
Redirect loop: https://www.puppeteers.net/blog/solving-an-apache-mellon-redirect-loop-mystery/
400 Bad Response error: https://jdennis.fedorapeople.org/doc/mellon-user-guide/mellon_user_guide.html#invalid_destination
Okta app config notes
* SAML Recipient should be https://<server_url>/<MellonEndpointPath>/postResponse
* SAML Audience should be https://<server_url>/<MellonEndpointPath>
Apache config notes
* ServerName must match the SAML Recipient, including the HTTP/HTTPS
@thedoc31
thedoc31 / aem_querybuilder_oldpackages.txt
Created October 3, 2022 22:35
AEM QueryBuilder query to identify old packages stored below /etc/packages
# Query below will return packages not created, unwrapped, or unpacked by admin since the 'upperBound' date.
# Anything older than the upperBound date will be included. Anything newer is ignored.
# If Querybuilder returns blank results or stops processing because it traversed >100k nodes, you may want to consider
# adding the oak_index_ntFileLucene in one of my other gists. Otherwise, narrow the parameters such as using path=/etc/packages/my_packages.
path=/etc/packages
type=nt:file
p.limit=-1
p.hits=full
daterange.property=jcr:created
@thedoc31
thedoc31 / oak_index_ntFileLucene.json
Created October 3, 2022 22:28
AEM 6.x Package Index
# Below is an index definition you can add to AEM under /oak:index/ntFileLucene so you can efficiently search for old packages
# under the entire /etc/packages subtree if you're running up against the 100k node traversal limit. After adding this,
# you should have no issues searching/filtering on any of the properties listed. You can add other properties if you
# would rather search on those instead. Tested only on 6.5, but might be backward compatible to 6.3 or earlier.
#
# This index is NOT supported by Adobe Customer Care or Adobe AEM Engineering teams, it's just something I needed.
# Add at your own risk and as always, test thoroughly in lower environments before you put it in PROD.
{
"compatVersion": 2,
@thedoc31
thedoc31 / aws-instance-type-count
Last active March 18, 2022 16:56
Return count of instance types in use in current AWS region
aws ec2 describe-instances --filters Name=tag-key,Values=Name --query 'Reservations[*].Instances[*].{Instance:InstanceId,Instance:InstanceType}' --output text | sort | uniq -c
"""fix_s3_owner_permissions"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
# import sys
import logging
import botocore
import boto3
DOCUMENTATION = '''
---
@thedoc31
thedoc31 / grafana-dashboard-import.sh
Last active November 7, 2022 12:53
Bash script to batch Import dashboard JSON files into Grafana. Verified working on v6.3. This script is based on the Grafana dashboard export script originated on https://gist.github.com/crisidev/bd52bdcc7f029be2f295
#!/bin/bash
#
# add the "-x" option to the shebang line if you want a more verbose output
#
#
OPTSPEC=":hp:t:k:"
show_help() {
cat << EOF
Usage: $0 [-p PATH] [-t TARGET_HOST] [-k API_KEY]
@thedoc31
thedoc31 / CollapseLanguages.sh
Created August 3, 2018 22:22
Find and collapse multiple RewriteRules with multiple languages into a single one-liner of all languages that use it
grep "<thecommonURL>" <thefile> | awk '{print $2}' | cut -c 2- | cut -f2-3 -d"/" | sort | tr '\n' '|'