授权安全组入口不向安全组添加规则
authorize-security-group-ingress not adding rule to security group
创建了一个 AWS 安全组:
aws ec2 create-security-group --group-name test-sg --description "test"
显示输出为:
{
"GroupId": "sg-79e9441d"
}
为其添加了一条新规则:
aws ec2 authorize-security-group-ingress --group-name test-sg --port 8091 --protocol tcp
将群组描述为:
aws ec2 describe-security-groups --group-name test-sg
输出不显示安全组中的规则:
{
"SecurityGroups": [
{
"IpPermissionsEgress": [
{
"IpProtocol": "-1",
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"UserIdGroupPairs": [],
"PrefixListIds": []
}
],
"Description": "test",
"IpPermissions": [],
"GroupName": "test-sg",
"VpcId": "vpc-c561f9a0",
"OwnerId": "598307997273",
"GroupId": "sg-79e9441d"
}
]
}
缺少什么?
您缺少 --cidr
选项,该选项表明您希望从哪个 IP 范围接受流量。
aws ec2 authorize-security-group-ingress --group-name test-sg --port 8091 --protocol tcp --cidr 0.0.0.0/0
创建了一个 AWS 安全组:
aws ec2 create-security-group --group-name test-sg --description "test"
显示输出为:
{
"GroupId": "sg-79e9441d"
}
为其添加了一条新规则:
aws ec2 authorize-security-group-ingress --group-name test-sg --port 8091 --protocol tcp
将群组描述为:
aws ec2 describe-security-groups --group-name test-sg
输出不显示安全组中的规则:
{
"SecurityGroups": [
{
"IpPermissionsEgress": [
{
"IpProtocol": "-1",
"IpRanges": [
{
"CidrIp": "0.0.0.0/0"
}
],
"UserIdGroupPairs": [],
"PrefixListIds": []
}
],
"Description": "test",
"IpPermissions": [],
"GroupName": "test-sg",
"VpcId": "vpc-c561f9a0",
"OwnerId": "598307997273",
"GroupId": "sg-79e9441d"
}
]
}
缺少什么?
您缺少 --cidr
选项,该选项表明您希望从哪个 IP 范围接受流量。
aws ec2 authorize-security-group-ingress --group-name test-sg --port 8091 --protocol tcp --cidr 0.0.0.0/0