小编use*_*094的帖子

Python Boto:如何指定子网ID和安全组?

我正在尝试使用boto来实现一个实例.该实例需要在我的VPC中的特定子网上以及我的vpc中的特定安全组中启动.

以下代码在我的VPC中成功启动了正确子网上的实例:

conn.run_instances(
        image_id=base_ami,
        key_name=bakery_key,
        subnet_id=bakery_subnet)
Run Code Online (Sandbox Code Playgroud)

以下代码给出了以下错误:

reservation = conn.run_instances(
        image_id=base_ami,
        key_name=bakery_key,
        security_groups=['TheNameOfMySecurityGroup'],
        subnet_id=bakery_subnet)
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误.当我指定使用子网ID而不是子网的实际名称时,我得到相同的错误:

Traceback (most recent call last):
File "./botobakery.py", line 24, in <module>
subnet_id=bakery_subnet)
  File "/usr/lib/python2.6/site-packages/boto/ec2/connection.py", line 935, in run_instances
verb='POST')
File "/usr/lib/python2.6/site-packages/boto/connection.py", line 1177, in get_object
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>The parameter groupName cannot be used with the parameter subnet</Message></Error></Errors>     <RequestID>c8a6b824-4ab3-41d2-9633-9830c167d2d6</RequestID></Response>
Run Code Online (Sandbox Code Playgroud)

如果有人知道如何将我的实例启动到我的特定子网并进入我的特定安全组,我会非常感激和感激

python amazon-ec2 boto amazon-web-services

8
推荐指数
1
解决办法
5400
查看次数

标签 统计

amazon-ec2 ×1

amazon-web-services ×1

boto ×1

python ×1