Created
July 5, 2024 04:04
-
-
Save shuson/c34bcaeb324fd07d65a7a4e7196ff1d5 to your computer and use it in GitHub Desktop.
aws cloudshell batch add IP to security group
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
GROUP_ID="sg-xxx" | |
# Define your list of IP addresses | |
IP_LIST=("192.0.2.0/24" "198.51.100.0/24" "203.0.113.0/24") | |
# Define the list of ports | |
PORT_LIST=(22 80 443) | |
# Add each IP address to the security group for each port | |
for IP in "${IP_LIST[@]}"; do | |
for PORT in "${PORT_LIST[@]}"; do | |
aws ec2 authorize-security-group-ingress --group-id $GROUP_ID --protocol tcp --port $PORT --cidr $IP | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment