How can I go about disassociating a particular security group from all EC2 instances and then associate it with a new EC2 instance, with BOTO3?
I'm trying something like:
ec2 = boto3.resource('ec2')
instances = ec2.instances.filter()
for instance in instances:
print(instance.id, instance.instance_type)
for sg in instance.security_groups:
if sg['GroupId'] == sg_id:
instance.modify_attribute ???
Thanks for any help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…