-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawssech.sh
More file actions
executable file
·27 lines (22 loc) · 1.26 KB
/
Copy pathawssech.sh
File metadata and controls
executable file
·27 lines (22 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# AWS Security Group Updater
#
# Author: pseudokool <https://github.com/pseudokool>
# License: MIT
# https://github.com/pseudokool/aws-secgroup-helper
# Config
SEC_GRP="my-security-group-name"
DESCRIPTION="my-description-no-spaces"
AWS_PROFILE="my-aws-profile-name-usually-default"
# Fetch WAN IP
IPV4=$(wget ipv4.icanhazip.com -q -O -)
echo "Current IPv4: $IPV4"
# Setup ingress rule via AWS CLI (replicate this for multiple ports, SSH, MySQL etc.)
IP_PERMS="IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=$IPV4/32,Description=\"$DESCRIPTION\"}]"
aws ec2 authorize-security-group-ingress --group-name $SEC_GRP --ip-permissions $IP_PERMS --profile $AWS_PROFILE
# Setup ingress rule via AWS CLI (replicate this for multiple ports, SSH, MySQL etc.)
#IP_PERMS="IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=$IPV4/32,Description=\"$DESCRIPTION\"}]"
#aws ec2 authorize-security-group-ingress --group-name $SEC_GRP --ip-permissions $IP_PERMS --profile $AWS_PROFILE
# Setup ingress rule via AWS CLI (replicate this for multiple ports, SSH, MySQL etc.)
#IP_PERMS="IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=$IPV4/32,Description=\"$DESCRIPTION\"}]"
#aws ec2 authorize-security-group-ingress --group-name $SEC_GRP --ip-permissions $IP_PERMS --profile $AWS_PROFILE