Skip to content

Instantly share code, notes, and snippets.

View cfbarbero's full-sized avatar

Cris Barbero cfbarbero

View GitHub Profile
@cfbarbero
cfbarbero / lambda_handler.py
Created February 25, 2019 19:53
Python data structure for handling reuse of resources across aws lambda invocations.
import uuid
from .some_object import SomeObject
class some_lambda:
def __init__(self):
self.instance_id = uuid.uuid4()
self.someobject = SomeObject()

Multiline yaml sub

      DestinationPolicy: 
        Fn::Sub:
          - |
            {
                "Version" : "2012-10-17",
                "Statement" : [
                    {
                    "Sid" : "",
# List indexes
| REST /services/data/indexes | table title, totalEventCount, currentDBSizeMB

# Count events per index
| eventcount summarize=false index=* report_size=true

# Metadata about an index
| metadata index="main" type=hosts
@cfbarbero
cfbarbero / setuptools-tips.md
Last active October 30, 2018 19:19
SetupTools Tips
@cfbarbero
cfbarbero / aws cli queries.md
Last active July 20, 2022 03:56
AWS CLI query examples

search sns subscriptions by endpoint

aws sns list-subscriptions --query 'Subscriptions[?contains(Endpoint,`dev`) == \`true\` ][Endpoint, TopicArn]' --output table

search alarms by sns topic

aws cloudwatch describe-alarms --query 'MetricAlarms[?contains(AlarmActions, `something`) == `true`][AlarmName, AlarmActions]' --output table --max-items 10

Get stack outputs

aws cloudformation describe-stacks --query 'Stacks[0].Outputs' --output table --stack-name $stackname --profile $profile

Get stack outputs from multiple stacks

# Install
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install stress -y
# Run CPU
stress-ng --cpu 4 --timeout 10m --metrics-brief
list-stack-outputs = aws cloudformation describe-stacks --stack-name ${1} --query "Stacks[*][StackName,Outputs]"; f
# Next time you need to install something with python setup.py -- which should be never but things happen.
python setup.py install --record files.txt
# This will cause all the installed files to be printed to that directory.
# Then when you want to uninstall it simply run; be careful with the 'sudo'
cat files.txt | xargs sudo rm -rf