当我使用boto 2文档中的设置时出现错误
错误是抛出的异常说:
"此用户没有默认的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 :(得分:0)
您没有默认的VPC。如果您认为自己拥有默认VPC,那么您使用的AWS凭证可以用于其他帐户,或者您在不具有默认VPC的其他区域中创建。
你有什么选择?