我在lambda中使用python boto3脚本来创建一个Ec2实例。但它说VPC是必要的。Boto3文档从未说明VPC是创建ec2实例的强制要求。
import json
import boto3
import pprint
def lambda_handler(event, context):
aws_mgmt_console = boto3.session.Session()
ec2_console_resource = aws_mgmt_console.resource('ec2')
ec2_console_client = aws_mgmt_console.client('ec2')
ec2_console_resource.create_instances(
ImageId="ami-018d291ca9ffc002f",
MinCount=1,
MaxCount=1,
InstanceType="t2.micro")
错误为:“errorMessage”:“调用RunInstances操作时出现错误(VPCIdNotSpecified):该用户没有默认的VPC,GroupName只支持EC2 Classic和默认的VPC.”,
“errorType”:“ClientError”,
“requestId”:“c8ca209b-223a-478b-8130-41b72daa0483”,