如何将新创建的 EC2 安全组与实例相关联
how to associate a newly created EC2 security group with an instance
如何将 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=False)
modify_attribute
更改此实例的属性。使用属性 groupSet - 安全组或 ID 集
i.modify_attribute('groupSet','sg-xxxx5678')
如何将 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=False)
modify_attribute
更改此实例的属性。使用属性 groupSet - 安全组或 ID 集
i.modify_attribute('groupSet','sg-xxxx5678')