Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

Organization

AWSセキュリティグループ設定をコマンド(aws-cli)でやる

ブラウザでぽちぽちは面倒ってことで
aws cliで登録する。

セキュリティグループの作成

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

環境変数に設定

まぁ、いろいろ便利なので

GroupID=`cat create-security-group | jq -r .GroupId`

確認

# 人間が見やすいフォーマット
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

Port 8081~8082で10.0.0.1/32からのアクセスをallowする

削除

aws ec2 revoke-security-group-ingress --group-id ${GroupID} --ip-permissions '[{"IpProtocol": "tcp", "FromPort": 8081, "ToPort": 8082, "IpRanges": [{"CidrIp": "10.0.0.1/32"}]}]'

Port 8081~8082で10.0.0.1/32からのアクセスを削除する

知りたいこと

GUIの名前タグに相当するオプションが見つからない。なんかあるんでしょうかね。
https://docs.aws.amazon.com/cli/latest/reference/ec2/authorize-security-group-ingress.html

あとで追記すること

jsonフォーマットを読み込み

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
7
Help us understand the problem. What are the problem?