Skip to content

Instantly share code, notes, and snippets.

View aerostitch's full-sized avatar

aerostitch aerostitch

View GitHub Profile
#!/usr/bin/env python3
'''
This script sets a retention on all the logGroups that don't have one set
'''
import boto3
import logging
# Retention it will be set to
RETENTION = 30
@aerostitch
aerostitch / kibana_import_from_json.go
Created June 3, 2017 00:20
Import kibana dashboards, searches and visualization definitions from a json file (one of those you can get from an export in Kibana) into a target Kibana (or should I say inside the corresponding elasticsearch cluster)
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/gobike/envflag"
"github.com/smartystreets/go-aws-auth"
"io/ioutil"
"log"
package main
import (
"flag"
"github.com/gobike/envflag"
"github.com/smartystreets/go-aws-auth"
"io/ioutil"
"log"
"net/http"
"net/url"
aws rds describe-db-instances --query 'DBInstances[].{ID:DBInstanceIdentifier,Class:DBInstanceClass,DB:DBName,User:MasterUsername,EP:Endpoint,Engine:Engine,ClusterID:DBClusterIdentifier,Created:InstanceCreateTime}'
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"net/url"
@aerostitch
aerostitch / aws_route53_dump_A_AAAA_CNAME.go
Last active May 6, 2017 00:03
Dumps the A, AAAA and CNAME records from the route53 zones of an account
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
@aerostitch
aerostitch / list_all_s3_buckets_websiste_policies.go
Last active May 5, 2017 21:54
Take all the buckets and list their website policy if any. Support multi-region and profile or static auth.
package main
import (
"context"
"encoding/json"
"flag"
"io/ioutil"
"log"
"time"
@aerostitch
aerostitch / fastly_generate_input_output.go
Last active May 4, 2017 00:03
Generates a json with the list of services and corresponding domains and origins/backends
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"github.com/gobike/envflag"
"github.com/sethvargo/go-fastly"
@aerostitch
aerostitch / lsof_repartition_per_user_and_pid.sh
Last active April 11, 2017 23:01
Repartition of the open file descriptors per login name and process id
sudo lsof -n -F 'Lp'| awk 'BEGIN{pid=0; user=""};{if(match($0, /^p([0-9]*)$/, d)){pid=d[1]} if(match($0, /^L(.*)$/,d)){user=d[1]} if(match($0, /^f(.*)$/)){a[sprintf("%s\tpid: %d",user, pid)]++}} END {for (i in a) print a[i], "\tuser: ", i}' | sort -n
package main
import (
"crypto/tls"
"fmt"
"gopkg.in/ldap.v2"
"log"
)
// Of course, this is to give an idea of what should be in those variables, but this should end up in environment variables or flags and should not be stored inside the script!