#!/usr/bin/env python
import boto3
ec2 = boto3.resource('ec2', region_name='us-east-1')
vpc = ec2.Vpc('vpc-xxxxx')
subnet = ec2.Subnet('subnet-xxxxx')
security_group = ec2.SecurityGroup('sg-xxxxx')
key_pair = ec2.KeyPair('xxxx')
instance = ec2.create_instances(
ImageId='ami-43a15f3e',
MinCount=1,
MaxCount=1,
InstanceType='t2.micro')
print (instance[0].id)
Только что попытался создать экземпляр, запустив приведенный выше скрипт boto3. Его сбой с ошибкой ниже. Любая помощь в этом.
Traceback (most recent call last):
File "boto2.py", line 12, in <module>
InstanceType='t2.micro')
File "C:\Program Files (x86)\Python36-32\lib\site-packages\boto3\resources\factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\boto3\resources\action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\botocore\client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\botocore\client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (VPCIdNotSpecified) when calling the RunInstances operation: No default VPC for this user