This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |