Skip to content

Instantly share code, notes, and snippets.

View akmalharith's full-sized avatar
🏠
Working from home

Akmal Harith akmalharith

🏠
Working from home
View GitHub Profile
@akmalharith
akmalharith / bws-secret-get.sh
Last active February 21, 2024 17:57
Wrapper to get Bitwarden Secrets Manager's secret by the secret's name.
#!/bin/bash
# Usage: ./bws-secret-get.sh <SECRET_NAME>
set -eo pipefail
if [ -z $BWS_ACCESS_TOKEN ]; then
>&2 echo "Missing access token. Please set your access token. Eg: export BWS_ACCESS_TOKEN=REPLACEME"
exit 1
fi
@akmalharith
akmalharith / custom_bash_prompt
Last active November 20, 2023 02:45
Bash prompt with Git branch name
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@akmalharith
akmalharith / build_layer_node.sh
Last active February 24, 2023 13:10
Install requirements and build a Lambda layer compatible zip
#!/bin/sh
if [[ ! -f package.json ]] ; then
echo "File package.json doesn't exist. Run npm init and npm install first."
exit
fi
npm ci
mkdir -p dist/lambda_layer/nodejs/node_modules
cp -r node_modules dist/lambda_layer/nodejs/
cd dist/lambda_layer && zip -r lambda_layer.zip nodejs
@akmalharith
akmalharith / bitbucket-pipelines.yml
Created February 17, 2023 02:44
Bitbucket pipelines to run Terraform, with YAML anchors as DRY practice
options:
docker: true
definitions:
commonItems:
- &getOidcToken export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token && echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token
- &terraformInit set -x && terraform -chdir=$TF_WORKDIR init
-backend-config="bucket=$TFSTATE_BUCKET"
-backend-config="key=$TFSTATE_KEY"
-backend-config="region=$TFSTATE_REGION" &&