boto3 : AttributeError: 'EC2' object has no attribute 'create_instances'

25,320

Have you tried using run_instances https://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.run_instances

Share:
25,320
ranjeetcao
Author by

ranjeetcao

Computer science graduate from IIT-BHU, have 5 years of experience in complete software development life cycle, with overall responsibility for the day-to-day operations of the project, Reporting periodically to all the stakeholders, Sprint Planning and Tracking, Risk analysis. Good Interpersonal skills, outstanding problem solving and decision making skills. Expertise in JAVA, JMX, Smart GWT, Python, Esper, rrd, flot, JFree Charting API, Application Monitoring development. I consider myself hardworking, self motivated, self starter and result oriented.

Updated on July 09, 2022

Comments

  • ranjeetcao
    ranjeetcao almost 2 years
    client = boto3.client('ec2', 
            aws_access_key_id=key,
            aws_secret_access_key=secret,
            region_name='ap-southeast-1')
    
    
        response = client.create_instances(
            DryRun=True,
            ImageId=ami1,
            MinCount=1,
            MaxCount=1,
            KeyName='my-key',
            SecurityGroupIds=[sg1, sg2],
            InstanceType='m3.medium',
            Placement={
                'AvailabilityZone': 'ap-southeast-1a'
            },
            SubnetId=sb1,
            NetworkInterfaces=[
                {
                    'NetworkInterfaceId': vpc1,
                    'SubnetId': sb1,
                    'Description': 'Description'
                }
            ]
        )
        print response 
    

    getting error while making api call to create instance, I have verified other operation like describe_images is working fine so keys are proper.

    am I missing something ?