Skip to content

Instantly share code, notes, and snippets.

View amcginlay's full-sized avatar

Alan McGinlay amcginlay

View GitHub Profile
@amcginlay
amcginlay / dockerize.sh
Last active October 13, 2022 08:46
dockerize.sh
# the following docker command mounts the current directory from a new alpine container
# on macos/linux
docker run -it --net host -v ${HOME}/.kube/:/root/.kube -v ${PWD}:/work -w /work alpine sh
# on windows
docker run -it --net host -v ${USERPROFILE}/.kube/:/root/.kube -v ${CD}:/work -w /work alpine sh
# TODO - Dockerfile
# FROM ubuntu:latest
@amcginlay
amcginlay / cdk-python-mvp.sh
Last active May 23, 2022 15:11
CDK Python MVP
#!/bin/bash
# --------------------------------
# from standard Cloud9 environment
# --------------------------------
which aws cdk
npm install --force -g aws-cdk # upgrade
python -m pip install aws-cdk-lib
cdk doctor # status check
mkdir ~/environment/cdk-app && cd $_
@amcginlay
amcginlay / kubectl-raw.sh
Last active April 21, 2022 13:33
kubectl-raw.sh
# when you pass the "--debug" flag to the AWS CLI you can see which endpoint is being invoked.
# you can do something similar with kubectl when you pass the "-v6" flag as follows.
# documentation here: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-output-verbosity-and-debugging
kubectl get nodes -v6
# the opening lines of the response reveal the endpoint
# strip out the hostname and pass what remains to kubectl as follows to see the original response which was previously prettified for you
kubectl get --raw /api/v1/nodes
# more examples as follows ...
@amcginlay
amcginlay / cert-manager-eks.sh
Last active March 20, 2022 10:14
cert-manager-eks.sh
#######################
# cert-manager/eks demo
#######################
# to start, complete everything up to and including:
# https://github.com/amcginlay/eks-demos/blob/main/doc/06-build-cluster/README.md
# create ROOT PCA
# set variables
@amcginlay
amcginlay / cert-manager-kind.sh
Last active March 19, 2022 11:26
cert-manager-kind.sh
####################################
# cert-manager/kind/letsencrypt demo
####################################
# cloudshell
# - Navigate to: https://us-west-2.console.aws.amazon.com/cloudshell
# - create SSM-enabled EC2 instance with ports 80/443 open
aws cloudformation create-stack \
--stack-name cert-manager-k8s \
--template-url https://amcginla-public.s3.amazonaws.com/cfn/cfn-ssm-jumpbox.yaml \
@amcginlay
amcginlay / cognito
Last active May 2, 2022 15:17
Demo steps for Cognito User Pools and Identity Pools
<Cognito User Pool Demo with Chalice>
PART 1
- Create a new user pool (e.g. apm-demo-user-pool), click Review Defaults and create pool
- Show User and groups -> (empty)
- Show Policies -> deselect all password checkboxes (keep things simple) and save changes
- Show General settings / App clients ->
--- Add
--- set App client name (e.g. apm-demo-app-client)
--- Disable Generate client secret (so later call to "aws cognito-idp initiate-auth" doesn't barf)
@amcginlay
amcginlay / cdk-java-mvp.sh
Last active February 2, 2022 14:27
CDK Java MVP
#!/bin/bash
# --------------------------------
# from standard Cloud9 environment
# --------------------------------
which aws cdk
pip install botocore boto3 # required to run python script for emptying versioned buckets (see later)
npm install --force -g aws-cdk # upgrade
cdk doctor # status check
# install maven
@amcginlay
amcginlay / secrets-manager.sh
Last active February 21, 2022 14:57
AWS Secrets Manager demo from the CLI
#!/bin/bash
unique_id=${RANDOM}
echo ${unique_id}
aws secretsmanager create-secret --name "/qa/dummy-key-${unique_id}" --secret-string "mY-5uP3R-53cr3t-v@lu3"
aws secretsmanager list-secrets
aws secretsmanager get-secret-value --secret-id "/qa/dummy-key-${unique_id}"
------------------------------------------------------------------------------
aws secretsmanager delete-secret --secret-id "/qa/dummy-key-${unique_id}" --recovery-window-in-days 7
@amcginlay
amcginlay / beanstalk.sh
Last active February 1, 2022 09:50
Deploying a simple PHP app in Elastic Beanstalk
#!/bin/bash
pip install awsebcli --upgrade --user
mkdir ebdemo && cd $_
git config --global init.defaultBranch main
git init
cat > ./index.php << EOF
<?php
echo gethostname() . "\n";
?>
EOF
@amcginlay
amcginlay / netcat-tcp-device.sh
Last active January 13, 2022 17:49
Demo shows how to send text across a network over TCP (/dev/tcp)
# inspired by https://www.youtube.com/watch?v=ZYr8Uc3PJJQ
sudo yum install -y nc
# 172-31-36-245:
sudo nc -l -p 8080
# 172-31-36-246:
echo "hello" > /dev/tcp/172.31.36.245/8080