【发布时间】:2017-06-17 00:41:09
【问题描述】:
所以我正在编写将删除0.0.0.0/0 and ::/0 上的端口22 的脚本,现在下面的脚本在默认vpc 上运行良好,但是当我更改vpc 时它给出了找不到无效权限错误。我无法理解为什么它在另一个 VPC 中给出 errrr 但在默认 VPC 中工作正常
def update_port(fromport, toport, groupid, vpcid):
response = client.revoke_security_group_ingress(
GroupId=groupid,
IpPermissions=[
{
'FromPort': fromport,
'IpProtocol': 'tcp',
'IpRanges': [
{
'CidrIp': '0.0.0.0/0'
},
],
'Ipv6Ranges': [
{
'CidrIpv6': '::/0'
},
],
'ToPort': toport,
'UserIdGroupPairs': [
{
'GroupId': groupid,
'VpcId': vpcid,
},
],
},
],
)
执行:
update_port(22,22,'sg-groupid','vpc-vpcid')
错误:
botocore.exceptions.ClientError: An error occurred (InvalidPermission.NotFound) when calling the RevokeSecurityGroupIngress operation: The specified rule does not exist in this security group.
【问题讨论】:
标签: python amazon-web-services amazon-ec2 boto boto3