Skip to content

Instantly share code, notes, and snippets.

View basimhennawi's full-sized avatar

Basim Hennawi basimhennawi

View GitHub Profile
@basimhennawi
basimhennawi / graphicsmagick.txt
Last active May 24, 2022 19:20
Graphicsmagick and Imagemagick static binaries for AWS Lambda
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime
# As of Dec 6, 2018, this is Amazon Linux AMI – amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
# Check latest from here: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
# SSH to Amazon Linux AMI instance, that you just created:
ssh -i ${EC2_KEY} ${EC2_USERNAME}@${EC2_IP}
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel gcc
# GraphicsMagick download latest stable as of Dec 6, 2018, this is 1.3.31 (latest stable)
curl -O https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.31/GraphicsMagick-1.3.31.tar.gz
@basimhennawi
basimhennawi / aws-update-ip.sh
Created August 30, 2021 11:16
Bash Script to update an Existing AWS Security Group with my New Public IP Address using AWS CLI
#!/bin/bash
group_id="sg-12345678";
port="27017";
# Get existing IP rules for group matching port
ips=$(aws ec2 describe-security-groups --filters Name=ip-permission.to-port,Values=$port Name=ip-permission.from-port,Values=$port Name=ip-permission.protocol,Values=tcp --group-ids $group_id --output text --query 'SecurityGroups[*].{IP:IpPermissions[?ToPort==`'$port'`].IpRanges}' | sed 's/IP //g');
# Loop through IPs
for ip in $ips