Skip to content

Instantly share code, notes, and snippets.

@GitSumito
Created April 4, 2018 07:48
Show Gist options
  • Save GitSumito/8572f1d06390386466758418498bc0ed to your computer and use it in GitHub Desktop.
Save GitSumito/8572f1d06390386466758418498bc0ed to your computer and use it in GitHub Desktop.
AWSセキュリティグループ設定をコマンド(aws-cli)でやる ref: https://qiita.com/S-T/items/3d4197bbed1022ccac43
VpcId="vpc-12345678"
NewGroup="application.stg.sg"
aws ec2 create-security-group --group-name ${NewGroup} --description "${NewGroup}" --vpc-id ${VpcId} --description "${NewGroup}" > create-security-group
# 人間が見やすいフォーマット
aws ec2 describe-security-groups --group-id ${GroupID} --output table
# json
aws ec2 describe-security-groups --group-id ${GroupID} --output json
aws ec2 authorize-security-group-ingress --group-id ${GroupID} --protocol tcp --port 8081-8082 --cidr 10.0.0.1/32
aws ec2 revoke-security-group-ingress --group-id ${GroupID} --ip-permissions '[{"IpProtocol": "tcp", "FromPort": 8081, "ToPort": 8082, "IpRanges": [{"CidrIp": "10.0.0.1/32"}]}]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment