Last active
August 29, 2015 14:17
-
-
Save onigra/060877faa60e29f2c07f to your computer and use it in GitHub Desktop.
特定のセキュリティグループのInboundの追加と削除のみができるIAM policy
This file contains hidden or 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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:AuthorizeSecurityGroupIngress", | |
"ec2:RevokeSecurityGroupIngress" | |
], | |
"Resource": [ | |
"arn:aws:ec2:ap-northeast-1:12345:security-group/sg-example" | |
] | |
} | |
] | |
} |
This file contains hidden or 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 | |
global_ip=$(curl -s inet-ip.info) | |
# IP制限追加 | |
aws ec2 authorize-security-group-ingress --group-id $SG_GROUP_ID --protocol tcp --port 80 --cidr "$global_ip/32" | |
aws ec2 authorize-security-group-ingress --group-id $SG_GROUP_ID --protocol tcp --port 443 --cidr "$global_ip/32" | |
# IP制限削除 | |
aws ec2 revoke-security-group-ingress --group-id $SG_GROUP_ID --protocol tcp --port 80 --cidr "$global_ip/32" | |
aws ec2 revoke-security-group-ingress --group-id $SG_GROUP_ID --protocol tcp --port 443 --cidr "$global_ip/32" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment