2014-04-12 4 views
8

मैं बोटो का उपयोग कर एक उदाहरण लॉक करने की कोशिश कर रहा हूं। उदाहरण को मेरे वीपीसी के भीतर एक विशिष्ट सबनेट पर और मेरे वीपीसी के भीतर एक विशिष्ट सुरक्षा समूह में लॉन्च करने की आवश्यकता है। यहाँपायथन बोटो: आप एक सबनेट आईडी और सुरक्षा समूह कैसे निर्दिष्ट करते हैं?

reservation = conn.run_instances(
     image_id=base_ami, 
     key_name=bakery_key, 
     security_groups=['TheNameOfMySecurityGroup'], 
     subnet_id=bakery_subnet) 

त्रुटि मैं मिलता है:

निम्नलिखित कोड को सफलतापूर्वक एक उदाहरण मेरे VPC में सही सबनेट पर शुरूआत:

conn.run_instances(
     image_id=base_ami, 
     key_name=bakery_key, 
     subnet_id=bakery_subnet) 

निम्नलिखित कोड मुझे निम्न त्रुटि देता है। जब मैं सबनेट का वास्तविक नाम के बजाय सबनेट आईडी का उपयोग निर्दिष्ट मैं एक ही त्रुटि मिलती है:

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> 

किसी को भी जानता है कि मेरा विशिष्ट सबनेट में और मेरे उदाहरण लांच करने के लिए कैसे मैं बहुत आभारी और सराहना होगी मेरी विशिष्ट सुरक्षा समूह

उत्तर

10

क्योंकि आप वीपीसी में लॉन्च कर रहे हैं, तो आपको सुरक्षा समूह को उनके नाम के बजाय उनकी आईडी द्वारा निर्दिष्ट करना होगा। नाम केवल "क्लासिक" ईसी 2 में मान्य हैं। इसलिए, यदि सुरक्षा समूह में sg-12345678 की आईडी थी तो आप इस तरह के कमांड का उपयोग कर सकते हैं:

reservation = conn.run_instances(
    image_id=base_ami, 
    key_name=bakery_key, 
    security_group_ids=['sg-12345678'], 
    subnet_id=bakery_subnet) 
संबंधित मुद्दे