【问题标题】:Updating security group in another VPC throws error of InvalidPermission.NotFound在另一个 VPC 中更新安全组会引发 InvalidPermission.NotFound 错误
【发布时间】: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


    【解决方案1】:

    错误是不言自明的 此安全组中不存在指定的规则。 请检查规则是否存在。

    【讨论】:

    • 如果您能正确阅读我的问题,则存在规则我说过该功能在默认 vpc 上运行良好,但问题出现在另一个 vpc sg 中。
    • 如果 4 条规则(如控制台所示)作为一个具有多个 IP 范围的规则返回,如何仅删除其中一个 IP 范围的规则? (我取了我获取的规则,只保留了我要删除的规则的范围,然后仍然出现这个错误)
    猜你喜欢
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 2019-02-05
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 2019-05-27
    • 2021-01-10
    相关资源
    最近更新 更多