Skip to content

Instantly share code, notes, and snippets.

Avatar
💥
Power wheels, power wheels, pow-pow-power wheels!

Ben Francom bfrancom

💥
Power wheels, power wheels, pow-pow-power wheels!
View GitHub Profile
@bfrancom
bfrancom / get-k8s-vars-urls.sh
Last active April 27, 2023 14:08
Get all environment variables with URI's in Kubernetes to find 3rd party services used
View get-k8s-vars-urls.sh
#should get all uri's (including url's) for things like s3, postgres, ftp, etc.
kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{.spec.containers[*].env[*].value}{"\n"}{end}' |grep -io "[[:alnum:]]*://[^ ]*" |sort |uniq
@bfrancom
bfrancom / get-ms-graph-groups.sh
Last active March 21, 2023 20:25
Microsoft Graph search groups by name
View get-ms-graph-groups.sh
https://graph.microsoft.com/v1.0/groups?$search="displayName:YourMom"&$select=id,displayName
#need to add a request header ConsistencyLevel:eventual
@bfrancom
bfrancom / Dockerfile
Last active March 7, 2023 15:34
Dockerfile for building java app in GitHub actions and deploying to AWS ECS/Fargate
View Dockerfile
#See https://gist.github.com/bfrancom/6ebebbf899912cd3c76c7f2978be0961 for deploying this docker container on ECS Fargate
FROM openjdk:8-jdk-slim as builder
#WORKDIR build
EXPOSE 8080
RUN mkdir target
ARG JAR_FILE=./target/*.jar
COPY ${JAR_FILE} target/app.jar
#You probably don't want to do this in production, and should tune memory, gc, etc.
ENTRYPOINT ["java","-jar","/target/app.jar"]
@bfrancom
bfrancom / build-jar-deploy-ecs-fargate.yml
Last active March 7, 2023 15:35
GitHub actions build Java jar and deploy to AWS ECS Fargate
View build-jar-deploy-ecs-fargate.yml
#See https://gist.github.com/bfrancom/d2ca0f7c767092a924c99545298b557d for Dockerfile used
#Author: Ben Francom
name: Build
#on: workflow_dispatch
on:
push:
branches:
- "main"
View ldap_search_filter_cheatsheet.md
@bfrancom
bfrancom / get-direct-reports.sh
Last active March 7, 2023 18:12
Get direct reports of manager from Microsoft Graph API filtered by name and email.
View get-direct-reports.sh
#Get users under a manager using MS graph query. Uses select filter for displayName and email address
#Use this query in https://developer.microsoft.com/en-us/graph/graph-explorer
https://graph.microsoft.com/v1.0/me/directReports?$select=displayName,mail
@bfrancom
bfrancom / get-aws-iam-users.sh
Last active February 24, 2023 22:15
Quick one liner to get AWS users in an account
View get-aws-iam-users.sh
aws iam list-users --query 'Users[*].UserName'
@bfrancom
bfrancom / pipelinestack.ts
Created February 16, 2023 15:55
CDK Pipeline with GitHub, Artifactory, and Tests
View pipelinestack.ts
import * as cdk from 'aws-cdk-lib';
//import * as codecommit from 'aws-cdk-lib/aws-codecommit';
import { Construct } from 'constructs';
import { BenzPipelineStage } from './pipeline-stage';
import { CodeBuildStep, CodePipeline, CodePipelineSource } from 'aws-cdk-lib/pipelines';
import { aws_codebuild as codebuild } from 'aws-cdk-lib';
export class BenzPipelineStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
@bfrancom
bfrancom / get-ec2-info.sh
Created May 30, 2022 22:03
AWS CLI Get EC2 Info and Export to CSV
View get-ec2-info.sh
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType'] |jq -r '.[][] | @csv' >>/tmp/ec2.csv
@bfrancom
bfrancom / get-opensearch-info.sh
Last active May 26, 2022 19:46
aws cli iterate through opensearch domains, get info, export to CSV
View get-opensearch-info.sh
#!/bin/bash
#export AWS_PAGER="";
# for i in $(aws opensearch list-domain-names |jq -r '.DomainNames[].DomainName')
# do
# aws opensearch describe-domains --domain-name $i --query 'DomainStatusList[*].[EngineVersion,ClusterConfig.InstanceType,ClusterConfig.InstanceCount,EBSOptions.VolumeType,EBSOptions.VolumeSize]'
# done
export AWS_PAGER=""