Skip to content

Instantly share code, notes, and snippets.

View thomashartm's full-sized avatar

Thomas Hartmann thomashartm

  • Netcentric
  • Germany
View GitHub Profile
@thomashartm
thomashartm / create-env.sh
Last active June 20, 2024 12:55
Output environment variables based on AWS SSM params and write .env files. This might be helpful when relying on centrally managed environments variables for local development or CICD
#!/bin/bash
set -e
# Enable -x only for debug purposes
#set -x
# Retrieves a JSON parameter from SSM and output them as key/values
# ./create-env.sh -p <system manager param name>
# Write the output to .env.local
# ./create-env.sh -p <system manager param name> > .env.local
@thomashartm
thomashartm / remove-terragrunt-state.sh
Last active June 19, 2024 08:47
Removes a terragrunt state for a group of resources that contain the provided argument
#!/bin/bash
# usage:
# ./remove-terragrunt-state module.s3_bucket ../../../
TOKEN=$1
SOURCE=$2
terragrunt state rm $(terragrunt state list --terragrunt-source ../../../ | grep $TOKEN) --terragrunt-source $SOURCE
@thomashartm
thomashartm / test-with-false-jwt-claims.py
Last active January 12, 2023 14:04
Testing script for sending manipulated parameters to an OpenIdConnect Endpoint.
import requests
import json
# Konfiguration
client_id = "your_client_id"
client_secret = "your_client_secret"
issuer = "https://your_issuer.com"
redirect_uri = "https://your_redirect_uri.com"
# Anmelde-Anfrage
@thomashartm
thomashartm / aws-sam-colima.md
Last active October 15, 2024 11:28
Enable AWS SAM local to run without Docker Desktop but Colima + Docker Daemon on MacOs

AWS SAM local commands without Docker Desktop

AWS SAM local commands check for the existance of DOCKER_HOST. If the variable is not present, it will fail with the following error message

Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?

Replace it with Colima

Point DOCKER_HOST to unix socket of the Docker Daemon.

@thomashartm
thomashartm / set-aws-env.sh
Created August 19, 2021 13:30
Manage different AWS settings and export them if necessary
#!/bin/bash
####################################
# Prepares dev environment settings
# call:
# set-aws-env <environment>
# or for help:
# set-aws-env
#
# How to use and expected file system structure:
@thomashartm
thomashartm / set-aws-env.sh
Last active June 7, 2021 10:08
Switch between different AWS credentials which are isolated in separate folders e.g. to support isolated credentials files for different customers or projects.
#!/bin/bash
####################################
# Prepares dev environment settings
# call:
# set-dev-env <environment>
# or for help:
# set-dev-env
#
# How to use and expected file system structure:
@thomashartm
thomashartm / awsprofile.sh
Last active May 26, 2023 02:51
Easy AWS profile switch via bash script.
#!/bin/bash
#
# 1. Place this script somewhere in your path:
# touch /Users/username/path-to-your-scripts-directory/awsprofile.sh
# 2. Save this script and make it executable
# chmod +x /Users/username/path-to-your-scripts-directory/awsprofile.sh
# 3. Add the directory to your bash profile
# export PATH="/path-to-your-scripts-directory:$PATH"
# 4. Source your bash profile
# awsprofile.sh
@thomashartm
thomashartm / Kali_Golang_Python_Dockerfile
Last active May 9, 2023 08:38
Dockerfile providing golang and python 3 inside a kali linux container
FROM kalilinux/kali-rolling
########
# The purpose of the this container is quickly hacking some security testing scripts and tools.
# Put the file into your local dev project, add the required tools, build the image and run it.
# Mount your local folder for development.
# Howto:
#
# docker build --no-cache -t <image-name> .
#
@thomashartm
thomashartm / gist:3ce003b75d29a2af50c723ce3112e60e
Created March 24, 2020 10:07
DynamoDB AWS CLI cheatsheet
# query by id
aws dynamodb query \
--table-name <tablename> \
--key-condition-expression "id = :name" \
--expression-attribute-values '{
":name": { "S": "<namevalues>" }
}'
# delete item by ID
aws dynamodb delete-item \
@thomashartm
thomashartm / registered-aem-servlets.groovy
Last active November 1, 2019 12:41
Prints out a list of servlets which are registered as OSGi components. The purpose is to find servlets which are listening to fixed paths or the default resource type
import org.osgi.service.cm.Configuration
import org.osgi.service.component.runtime.ServiceComponentRuntime
def scr = getService(ServiceComponentRuntime.class)
def descs = scr.getComponentDescriptionDTOs()
def i = 0