我有以下代码来启动新实例:
conn = boto.ec2.connect_to_region("us-east-1", security_token = "xx", aws_access_key_id= "xx", aws_secret_access_key= "xx")
security_groups = conn.get_all_security_groups()
for security_group in security_groups:
if str(security_group)[14:] == "xx":
conn.run_instances(
'ami-da2cd5b2',
key_name='fornax_keypair',
instance_type='c1.xlarge',
security_groups=security_group)
else:
continue
它找到安全组,然后给出错误:
TypeError: 'SecurityGroup' object is not iterable
如果我将其更改为 str(security_group),则会出现错误:
<Response><Errors><Error><Code>InvalidGroup.NotFound</Code><Message>The security groups 'f', 'g', 'd', 'e', 'c', 'n', 'o', 'j', '.', 'i', 'v', 'u', 't', 's', 'r', 'p', '
:', 'y' do not exist</Message></Error></Errors><RequestID>c96afd3c-de3f-4441-be65-c6a85fbe7868</RequestID></Response>
另外,如何将连接附加到已建立的 vpc 连接和子网?