# Clear any existing ENV credentials
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
# Assumed the specified role and export the required values
KEYS=$(aws sts assume-role --role-arn $AWS_ROLE_ARN \
--role-session-name testing --duration 900); \
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
# Below command can be replaced to the required CLI, including with custom JSON output, assuming the NextToken is in the same location. | |
AWS_CLI_COMMAND="aws elasticbeanstalk list-platform-versions --max-records 100 --query={NextToken:NextToken,PlatformARNs:PlatformSummaryList[*].PlatformArn}" | |
OUTPUT_FILE="./output-$(date +%s)" | |
function CLI_call() { | |
if [ ! -v NEXT_TOKEN ]; then | |
cli_output=$($AWS_CLI_COMMAND) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
CURL_COMMAND='curl -X POST https://api.github.com/graphql' | |
RAW_OUTPUT_FILE="$(tempfile -s ".query.output")" | |
MINIMUM_PLUS_1_COUNT=20 | |
function API_call() { | |
if [ ! -v NEXT_PAGE ]; then | |
api_output=$($CURL_COMMAND -H "Authorization:bearer $GITHUB_TOKEN" -d @query) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ec2 describe-instances --query 'Reservations[].Instances[].[PrivateIpAddress, MetadataOptions]' --instance-ids <ids> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE="ipsToConnectTo" | |
lineContents() { | |
# Checks if a line has a * pointer next to it to denote which is the next line that should be returned. | |
LN=$(grep --color=never -n \* $FILE | cut -f1 -d\:) | |
# If there is no * pointer it needs a manual reset to the right starting location. A precaution for how I used it but easily customisable. | |
if [ "${LN}" == "" ] ; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loops through all the .png images in the current folder and assigns their filename to an element of the array | |
counter=0 | |
for i in `ls -1 ./*.png` ; do | |
images[$counter]=$i; | |
let counter=counter+1; | |
done | |
# Loops through the images array, based on the ROWS and COLS spec, to determine how many items rows and columns there will be when merging. Plenty of improvements here | |
ROWS=2 | |
COLS=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# echo "## Each files last update, sorted from oldest to newest" | |
# cd .. && git ls-tree -r --name-only HEAD | while read filename; do echo "$(git log -1 --format="%aI" -- $filename) $filename"; done | sort -rk1 | |
function lastCommit { | |
git log -1 --format=%cI | |
} | |
function addNumber { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export DOCKER_REGISTRY_USERNAME="marjamis" | |
export REPOSITORY="test" | |
# Note: If using the base64 command doesn't work here you can run a docker login with your credentials and then copy the base64 value from the file: ~/.docker/config.json | |
export TOKEN=$(curl -H "Authorization: Basic <base64 of docker hub username:password>" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$DOCKER_REGISTRY_USERNAME/$REPOSITORY:pull,push" | jq .) | |
# Get the manifest of a specific image | |
curl -LH "Authorization: Bearer $TOKEN" https://index.docker.io/v2/$DOCKER_REGISTRY_USERNAME/$REPOSITORY/manifests/<tag or digest> | jq . | |
# Get a list of tags for images in this repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DEFAULT_GOAL := helper | |
BUILD_TIME ?= $(shell date '+%s') | |
# Useful for colour coding outputs | |
TEXT_RED = \033[0;31;1m | |
TEXT_BLUE = \033[0;34;1m | |
TEXT_GREEN = \033[0;32;1m | |
TEXT_PURPLE = \033[0;35;1m | |
TEXT_NOCOLOR = \033[0m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export CLUSTER="test" | |
PAYLOAD=$(aws eks describe-cluster --name $CLUSTER --query 'cluster.{CA: certificateAuthority.data,Endpoint: endpoint}') | |
echo $PAYLOAD | jq -rc .CA | base64 -D > /tmp/public_cert | |
ENDPOINT=$(echo $PAYLOAD | jq -rc .Endpoint) | |
curl -v --cacert /tmp/public_cert -H "Authorization: Bearer "$(aws eks get-token --cluster-name $CLUSTER | jq -rc .status.token) $ENDPOINT/api/v1/namespaces/default/pods/ | |
## Additional curl options | |
curl -X GET --cacert /var/lib/kubelet/pods/<podId>/volumes/kubernetes.io~secret/<kube-proxy token secret>/ca.crt -H "Authorization: Bearer $(cat token)" https://<endpoint IP>:443/api/v1/endpoints | |
kubectl -n kube-system create serviceaccount kube-dns |
OlderNewer