Skip to content

A Python script that requests a spot EC2 instance

Notifications You must be signed in to change notification settings

saurabhbikram/autoaws

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoAWS

A Python script that requests a spot EC2 instance. Use InstanceId to control the instance.

Prerequisites

Setup

Boto 3 Install

$ pip install boto3

AWS CLI Configure

  • Create Access Key for Your AWS Account. Instructions can be found at https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html

  • Configure AWS CLI using AWS Access Key ID and AWS Secret Access Key

    • $ aws configure
    • AWS Access Key ID [None]: 'ACCESS_KEY_ID'
      AWS Secret Access Key [None]: 'SECRET_ACCESS_KEY'
      Default region name [None]:'Region'
      Default output format [None]: ENTER
  • To use multiple profiles set the system environment AWSACC with the name of the profile in .aws/config

Configuration File

List of a configure fields

*Refer to example-config.cfg file.

You can add user data by creating a userdata.txt file.

Request EC2 Spot Instance

from ec2 import AutoEC2
ec2 = AutoEC2()

# show instances
ec2.instances 

# create a new instance based on config file
inst = ec2.create("config.cfg")

# destroy the instance
ec2.destroy(inst["InstanceId"])

About

A Python script that requests a spot EC2 instance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.4%
  • Shell 0.6%