【发布时间】:2020-07-30 07:11:25
【问题描述】:
我想使用 revoke_ingress 方法 boto3 从另一个安全组 sg-ZZ 的入站规则中删除特定的安全 sg-yy 组
来源:sg-ZZ 目标:sg-yy
我试过了:
response = security_group_source.revoke_ingress(
FromPort=FromPort,
GroupName=groupName_source,
IpPermissions=[
{'ToPort': ToPort,
'UserIdGroupPairs': [
{
'Description': description_target,
'GroupId': group_id_target,
'GroupName': groupName_target,
'VpcId': VpcId_target,
},
]
},
],
SourceSecurityGroupName=groupName_source,
SourceSecurityGroupOwnerId=owner_id_source,
ToPort=ToPort,
DryRun=True
)
print( response )
但我收到错误:调用 RevokeSecurityGroupIngress 操作时发生错误 (InvalidGroup.NotFound):默认 VPC 'vpc-1111' 中不存在安全组 'sg_group_name'
我不能使用:
security_group.revoke_ingress(
IpPermissions = IpPermissions,
)
因为我需要删除特定的安全组
有人可以帮我吗?
【问题讨论】:
-
您确定您所有的 SG 都在默认 vpc 中吗?
-
@Marcin 不,它们不在默认 VPC 中,我提到的是它所在的 VPC,即
VpcId': VpcId_target。另外,安全组 sg-yy 和 sg-ZZ 在同一个 VPC 中 -
错误提示“在默认默认值中不存在”,因此它在默认 vpc 中搜索它们。也不知道你为什么同时使用
GroupId和GroupName?应该使用其中之一。对于非devaulf vpc,应根据文档仅使用GroupId:For a security group in a nondefault VPC, use the security group ID. -
@Marcin 即使我只使用
group ID,我也会遇到同样的错误,它在默认VPC中寻找的潜在原因是什么,而不是我提到的VpcId_target? -
必须检查文档。我看到
GroupName和SourceSecurityGroupName也仅适用于[EC2-Classic, default VPC]。那么必须指定其他参数,还是删除它们?现在不确定我的头顶。
标签: python amazon-web-services boto3 aws-security-group