Skip to content

Instantly share code, notes, and snippets.

@pcolazurdo
pcolazurdo / list_all_resources.sh
Created Oct 5, 2021
CloudControl for the win
View list_all_resources.sh
# very basic but you can see the gist of it:
aws cloudformation list-types --type RESOURCE --visibility PUBLIC | \
jq '.TypeSummaries[].TypeName' | \
cut -d\" -f2 | \
while read a
do
aws cloudcontrol list-resources --type-name $a 2>/dev/null| \
jq '.ResourceDescriptions[].Identifier'
done
View main-instrumented.go
// This sample code triggers the problem if run against a large directory structure (+50K objects)
// I added some instrumention to check how many connections were being resued versus created new
// Please change the table name in line 283 and path in line 286
package main
import (
"context"
"crypto/md5"
"strings"
View README.md

Download the file from

wget https://status.aws.amazon.com/data.json

basic parsing

jq -r '(.archive[] | 
       (.date| tonumber | todate) as $D | 
       select($D | startswith("2021"))| 
       [.service_name, $D[0:10] ,.service,.summary])  | @csv ' \
@pcolazurdo
pcolazurdo / find_chome_dependency.sh
Created May 14, 2021
How to get list of libraries to fulfil dependency requirements
View find_chome_dependency.sh
ldd /var/task/node_modules/puppeteer/.local-chromium/linux-869685/chrome-linux/chrome | grep not | \
cut -d= -f1 | while read a
do
yum provides $a | head -2 | tail -1 | cut -d\ -f1
done
@pcolazurdo
pcolazurdo / Dockerfile.18.04
Last active Apr 19, 2021
Building ingraind in AL2
View Dockerfile.18.04
FROM ubuntu:18.04
ARG openssl_arch=linux-x86_64
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install curl wget lsb-release wget software-properties-common \
@pcolazurdo
pcolazurdo / cwagent-otel-collector.yaml
Last active Mar 28, 2021
OpenTelemetry Playground
View cwagent-otel-collector.yaml
# Config file to add a Prometheus receiver - not fully as I can't make it scrape another process yet
extensions:
health_check:
receivers:
prometheus:
config:
scrape_configs:
- job_name: "otel-collector"
scrape_interval: 5s
@pcolazurdo
pcolazurdo / readme.md
Last active Mar 26, 2021
Dotfiles setup recommendations
View readme.md

How to setup a git repo for your dotfiles

For general guidance follow this great write up: https://www.atlassian.com/git/tutorials/dotfiles

In summary:

On the main computer:

git init --bare $HOME/.cfg
alias dotfiles='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
@pcolazurdo
pcolazurdo / ssm-runscript.py
Created Mar 8, 2021
Sends a script to SSM Run Command
View ssm-runscript.py
import json
import boto3
import argparse
class Args(object):
import argparse
parser = argparse.ArgumentParser(
description='Allows user to execute a local script using SSM Run Commands')
@pcolazurdo
pcolazurdo / readme.md
Created Jan 22, 2021
JQ for botocore
View readme.md

This example helps to find a specific property into all the APIs that supports it

cat service-2.json | jq '[paths(.)] | .[] | flatten| select ( . | index("CopyTagsToSnapshot") ) '

To be more specific, this helps

cat service-2.json | jq '[paths(.)] | .[] | flatten| select ( . | index("CopyTagsToSnapshot") ) | .[1]'