AWS
Cloud Watch CLI
aws logs filter-log-events --log-group-name /aws/lambda/LogGroupName --output json --region ap-southeast-1 --start-time 1706918400000 --end-time 1707004800000 --query "events[?contains(message, 'some text')].{Timestamp:timestamp, Message:message}" > result.json
CloudWatch (Ignore case)
fields @timestamp, @message, @logStream, @log
| filter @message like /(?i)(something)/
| sort @timestamp desc
| limit 10000Update lambda code
sh
aws lambda update-function-code --region ap-southeast-1 --profile my-profile --function-name YourFunctionName --zip-file fileb://path/to/your/file.zip
aws lambda get-function-configuration --function-name YourFunctionName --region ap-southeast-1 --profile my-profile | jq ."Environment.Variables"
aws lambda update-function-configuration --region ap-southeast-1 --function-name my-lambda-function --environment "Variables={VAR1=new_value1,VAR2=new_value2}"
aws lambda update-function-configuration --region ap-southeast-1 --function-name function-name --environment "Variables={$(cat env.config | jq -r 'to_entries | map("\(.key)=\(.value | gsub(","; "\\,"))") | join(",")')}"Lambda starter kit
sh
pnpm add -D esbuild eslint typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @types/node @types/aws-lambda globals typescript-eslint @eslint/js
pnpm add @aws-sdk/client-lambdajson
{
"build": "rm -rf dist && esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=es2022 --outfile=dist/index.js",
}DynamoDB
@aws-sdk/lib-dynamodb - Marsal and Unmarsal @aws-sdk/client-dynamodb - Will return in raw format
EC2 starter kit
bash
sudo apt update
sudo apt upgrade -y
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt install btop fzf ncdu
sudo timedatectl set-timezone Asia/Kuala_Lumpur
sudo systemctl restart cron