Skip to content

Instantly share code, notes, and snippets.

View slawekzachcial's full-sized avatar

Slawek Zachcial slawekzachcial

  • Grenoble, France
View GitHub Profile
terraform plan -no-color 2>&1 \
| sed -E -e 's/^([[:space:]]+)([-+#])/\2\1/g' -e 's/^([[:space:]]+)~/!\1/g'
@slawekzachcial
slawekzachcial / aws-sigv4-ssm-get-parameter.sh
Last active August 6, 2024 07:48
Using CURL to call AWS ReST API, signing request with v4 signature
#!/bin/bash
# Source: https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
[[ -n "${AWS_ACCESS_KEY_ID}" ]] || { echo "AWS_ACCESS_KEY_ID required" >&2; exit 1; }
[[ -n "${AWS_SECRET_ACCESS_KEY}" ]] || { echo "AWS_SECRET_ACCESS_KEY required" >&2; exit 1; }
readonly parameterName="SlawekTestParam"
readonly method="POST"
@slawekzachcial
slawekzachcial / self-signed-certificate-with-custom-ca-and-kms.md
Last active April 11, 2024 16:44
Self Signed Certificates with Custom Root CA and Root CA Key Encrypted with AWS KMS

This Gist is based on Self Signed Certificate with Custom Root CA gist.

It adds the use of AWS KMS to generate and decrypt the Root CA private key, so that this key does not need to be stored in plaintext. Instead, the key is stored encrypted, and is being decrypted using AWS KMS only when needed.

Create AWS KMS CMK - Done Once

Create symmetic CMK (customer-managed key) and give it an alias of alias/root-ca-encrypting-key that will be used later to reference to it:

@slawekzachcial
slawekzachcial / proxy_ws_by_path.js
Created June 25, 2019 20:42
http-proxy-middleware proxy by path, including websockets
const express = require('express')
const proxy = require('http-proxy-middleware')
const app = express()
app.use('/xxx', proxy('/xxx', {
target: 'http://localhost:8443',
changeOrigin: true,
ws: true,
pathRewrite: {
@slawekzachcial
slawekzachcial / GitHubAuthWithExpress.js
Created June 2, 2019 22:10
GitHub authentication in ExpressJS app.
const cookieSecret = process.env.COOKIE_SECRET || 'secret'
const cookieName = process.env.COOKIE_NAME || 'GitHubAuthenticated'
const githubHost = process.env.GHE_HOST || 'https://github.com'
const githubApiUrl = process.env.GHE_API_URL || 'https://api.github.com'
const clientId = process.env.CLIENT_ID
const clientSecret = process.env.CLIENT_SECRET
const userAgent = 'My-App'
const express = require('express')
const app = express()
// Explict call parameters
def containerBuildAndPublish1(image, tag, dockerRegistry, dockerRegistryCredsId) {
//IMPLEMENTATION USAGE EXAMPLE
println "Building ${image}:${tag} and publishing to ${dockerRegistry} using creds ${dockerRegistryCredsId}"
}
// PIPELINE USAGE EXAMPLE: Explict call parameters
containerBuildAndPublish1('myimage', 'latest', 'my.docker.registry:1234', 'jenkins-docker')
containerBuildAndPublish1 'myimage', 'latest', 'my.docker.registry:1234', 'jenkins-docker'
@slawekzachcial
slawekzachcial / svn_github_migration.sh
Last active June 15, 2018 12:38
Subversion to GitHub migration steps using GitHub-provided tools.
# SSH to GitHub appliance and go to your working directory where you do migrations
# Type your Subversion username + Enter
read SVN_USER
# type your Subversion password + Enter
read SVN_PASSWORD
# type your GitHub username + Enter
read GIT_USER
# type your GitHub **Personal Access Token** + Enter
read GIT_TOKEN
# We do it in a Docker container
docker run -it --name svn_build debian:jessie
# Set HTTP proxy if required
export http{,s}_proxy=http://proxy_host:proxy_port
# Install all the dependencies
apt-get update
apt-get install curl bzip2 gcc autoconf libtool make python
# Configuration based on
# http://www.andrews-corner.org/linux/abcde/index.html and
# http://www.andrews-corner.org/linux/abcde/getalbumart.html
LOWDISK=n
CDDBMETHOD=musicbrainz
ACTIONS=cddb,read,getalbumart,encode,tag,move,playlist,clean
OUTPUTTYPE="flac,mp3"
#!/bin/bash
PROMPT="\n$ "
DELAY_COMMENT_CHAR="0.1s"
DELAY_COMMENT="1s"
DELAY_RUN="3s"
GRAY="\033[1;30m"
LIGHT_GRAY="\033[0;37m"
CYAN="\033[0;36m"