2017-10-18 57 views
0

我得到一個錯誤,當我使用設置從博託2文檔如何設置使用boto 2 lauch配置?

的錯誤是,被拋出話說異常:

「沒有默認VPC此用戶」

從最初的研究,它看起來像我需要使用子網,但我有一個默認的VPC與我的帳戶關聯。如何在沒有默認VPC的情況下以編程方式設置啓動配置? 對於開始,我做了以下內容:

 #=================AMI to launch====================================================== 
     as_ami = { 
     'id': 'ami-5648a**', #The AMI ID of the instance your Auto Scaling group will launch 
     'VpcId' : 'vpc-0c805***', 
     'access_key': 'keyFile.pem', #The key the EC2 instance will be configured with 
     'security_groups': 'sg-1d83b***', #The security group(s) your instances will belong to 
     'instance_type': 't2.micro', #The size of instance that will be launched 
     'instance_monitoring': True #Indicated whether the instances will be launched with detailed monitoring enabled. Needed to enable CloudWatch 
     } 



    autoscaling_group = { 
    'name': 'myAG', #descriptive name for your auto scaling group 
    'min_size': 1 , #Minimum number of instances that should be running at all times 
    'max_size': 1 #Maximum number of instances that should be running at all times 
    } 

    lc_name = 'myLG' #Descriptive name for your launch configuration 

    conn_as = AutoScaleConnection(AWS_ACCESS_KEY,AWS_SECRET_KEY) 


    lc = LaunchConfiguration(name = lc_name, 
           image_id = as_ami['id'], 
           key_name = as_ami['access_key'], 
           security_groups = as_ami['security_groups'], 
           instance_type = as_ami['instance_type'], 
           user_data = user_data, 
           associate_public_ip_address=True, 
           instance_monitoring=as_ami['instance_monitoring']) 

    conn_as.create_launch_configuration(lc) 

的錯誤是因爲遵循

Traceback (most recent call last): 
    File "createResource.py", line 156, in <module> 
    main() 
    File "createResource.py", line 122, in main 
    conn_as.create_launch_configuration(lc) 
    File "C:\Python27\lib\site-packages\boto\ec2\autoscale\__init__.py", line 291, in create_launch_configuration 
    Request, verb='POST') 
    File "C:\Python27\lib\site-packages\boto\connection.py", line 1208, in get_object 
    raise self.ResponseError(response.status, response.reason, body) 
boto.exception.BotoServerError: BotoServerError: 400 Bad Request 
<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/"> 
    <Error> 
    <Type>Sender</Type> 
    <Code>ValidationError</Code> 
    <Message>No default VPC for this user</Message> 
    </Error> 
    <RequestId>fac3b7a6-b39c-11e7-b881-75dd83913ada</RequestId> 
</ErrorResponse> 

回答

0

您沒有默認VPC。如果您認爲自己擁有默認VPC,那麼您使用的AWS憑證可能適用於其他帳戶,或者您在不具有默認VPC的其他區域中創建。

你有什麼選擇?

  • 檢查區域,並確保你在正確的區域創建
  • 檢查您所指定的寶途的AWS憑據是正確的帳戶
  • 如果沒有默認VPC,調用AWS和恢復舊的默認VPC(或)約翰Rotenstein提到,create a new default VPC
  • 指定要創建實例的VPC的子網ID
+0

現在可以到[創建使用AWS反對新的默認VPC ole或CLI](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/default-vpc.html)。 –

+0

謝謝@JohnRotenstein。我不知道這件事。 – helloV

+0

@helloV如何將啓動配置與具有子網ID的非默認VPC相關聯。你的意思是VPC ID或Ipv4 CIDR? –