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>
现在可以到[创建使用AWS反对新的默认VPC ole或CLI](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/default-vpc.html)。 –
谢谢@JohnRotenstein。我不知道这件事。 – helloV
@helloV如何将启动配置与具有子网ID的非默认VPC相关联。你的意思是VPC ID或Ipv4 CIDR? –