Python 如何将新创建的EC2安全组与实例关联
如何将EC2实例添加到新创建的安全组中?安全组是使用创建的Python 如何将新创建的EC2安全组与实例关联,python,amazon-web-services,amazon-ec2,boto3,Python,Amazon Web Services,Amazon Ec2,Boto3,如何将EC2实例添加到新创建的安全组中?安全组是使用创建的 client = session.client("ec2") group_id = client.create_security_group( DryRun=False, GroupName=group_name, VpcId=vpc_id, Description=description ) 您需要修改实例的属性: modify_attribute(attribute, value, dry_run=
client = session.client("ec2")
group_id = client.create_security_group(
DryRun=False,
GroupName=group_name,
VpcId=vpc_id,
Description=description
)
您需要修改实例的属性:
modify_attribute(attribute, value, dry_run=False)
modify_attribute
更改此实例的属性。使用属性groupSet-安全组或ID集
请参见这对我来说最有效,但我发现文档不正确,参数键为:
属性
,值
,干运行
。我还发现,尽管这个值被称为集合,但它实际上是一个字符串。
i.modify_attribute('groupSet','sg-xxxx5678')