Problem scenario
You want to be able to create EC-2 instances in AWS with a Python script. How do you do this?
Solution
Prerequisites
This assumes you have installed Boto3. If you do not know how, see this posting.
Procedures
As a reference, you may go here to learn more about Boto's features: http://boto3.readthedocs.io/en/latest/guide/migrationec2.html
Use this program:
""" Usage instructions
1. replace "aaa111" with the aws_access_key_id of your account
2. replace "bbb222" with the aws_secret_access_key of your account
If you are not sure how to find these credentials do the following:
To find the AWS Access Key ID and AWS Secret Access Key, in the AWS console, click on your name in the upper right hand corner.
Then click on "My Security Credentials." Click "Create New Access Key" Click "Show Access Key."
3. Replace us-west-1 with the region that you want to list Ec-2 instances for.
4. Change the "t2.micro" to be the flavor of server that you want to create.
5. Change the "3" in MaxCount to the number of servers you want to be created.
6. Change the "ami-0b1e356e" to the AMI you want. One way to browse is to manually log into the AWS console and click "Launch Instance". The first step will allow you to see IDs of AMIs.
7. To run it, call it test3.py and run it with a command like this: "python test3.py"
Warning: THIS WILL CREATE THREE SERVERS in AWS!
Warning: This could be more expensive than you are used to.
"""
import boto3
ec2 = boto3.resource('ec2', aws_access_key_id='aaa111', aws_secret_access_key='bbb222', region_name='us-west-1')
ec2.create_instances(ImageId='ami-0b1e356e', MinCount=1, MaxCount=3, InstanceType='t2.micro')