I am getting this error while trying to create an Instance on EC2 using Python boto3.
Here is the code I am using and I am getting this error:
AttributeError: 'ec2.ServiceResource' object has no attribute 'create_instance'
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.create_instance(
ImageId = 'ami-009d6802948d06e52',
MinCount = 1,
MaxCount = 1,
InstanceType = 't2.micro',
KeyName = 'nitesh',
SubnetId = 'subnet-026hy78976jo77')
print (instance[0].id)
Thank you in Advance.