Skip to content

Instantly share code, notes, and snippets.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sqs-single-queue-fan-out
Sample SAM Template for a single SQS queue fan out using Event Bridge
Globals:
Function:
Timeout: 3
@miclip
miclip / custom_stack.md
Last active June 29, 2022 17:17
Custom TBS Stack example

Create a custom stack and add to TBS

  1. Create a docker file for image:
# Set a common base
FROM alpine as base

# Set required CNB information
ENV CNB_USER_ID=1000

Update the WebHostBuilder call to include .UseUrls(GetServerUrls(args))

var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls(GetServerUrls(args))
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();
@miclip
miclip / photon_static_ip.md
Last active August 2, 2021 17:16
Photon Static IP

Set static IP Photon

  1. List your networking interfaces networkctl. Take note of the device name, for example eth0, eth1
  2. Change directory to change to /etc/systemd/network and list files. You should see a file named 10-dhcp-en.network
  3. Remame file 10-dhcp-en.network.backup. This disables DHCP.
  4. Create a new file 10-static-en.network
    [Match]
    Name=eth0
 [Network]
@miclip
miclip / cancel_tasks.sh
Created July 15, 2020 20:42
bosh cancel all queued tasks
for row in $(bosh tasks --json | jq -r '.Tables[].Rows[] | select(.state=="queued").id'); do bosh cancel-task $row -n; done;
@miclip
miclip / bosh_health_checks.sh
Created July 15, 2020 14:26
BOSH Monit Health Checks
Monit Process Healthcheck for all vm’s in the foundation:
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --ps --json | jq '.Tables[].Rows[] | select(.process != "")' | jq -s -r 'group_by(.process_state)[] | .[0].process_state + ": " + (length | tostring)'; echo; bosh --tty -d $DEPLOYMENT instances --ps --json | jq -r '.Tables[].Rows[] | select((.process_state != "running") and .process_state != "") | "\(.instance) \(.process) \(.process_state)"'; echo ;done
Memory health check for all vm’s in the foundation:
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --vitals --json | jq -r '.Tables[].Rows[] | select(.memory_usage != "") | select((.memory_usage | split("%") | .[0] | tonumber) >= 70) | "Instance: " + .instance + ", Memory: " + .memory_usage'
@miclip
miclip / Dockerfile
Created June 3, 2020 14:54
automation tools image pivnet om and az cli
FROM ubuntu
ENV PIVNET_CLI_VERSION 1.0.3
ENV OM_CLI_VERSION 5.0.0
RUN apt-get update -y && \
apt-get install ca-certificates curl apt-transport-https lsb-release gnupg -y && \
curl -O https://github.com/pivotal-cf/pivnet-cli/releases/download/v${PIVNET_CLI_VERSION}/pivnet-linux-amd64-${PIVNET_CLI_VERSION} && \
mv pivnet-linux-amd64-${PIVNET_CLI_VERSION} /usr/local/bin/pivnet-cli && \
chmod +x /usr/local/bin/pivnet-cli && \
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \

Protect Service on PKS with UAA

Protect service on PKS with UAA using oauth-proxy. Assumes you've deployed the nginx ingress controller.

Create the UAA client:

 uaac client add --name kibana --scope openid email profile \
   --authorized_grant_types authorization_code --authorities uaa.resources 
   --redirect-uri kibana.haas-445.pez.pivotal.io/oauth2/callback --secret the-secret
#!/bin/bash
set -eu
if [ ! -d "concourse-docker" ] ; then
echo "clone docker concourse repo..."
git clone git@github.com:concourse/concourse-docker.git
fi
pushd ./concourse-docker > /dev/null