Skip to main content

# ec2.py

> Simple CLI / module to create/start/stop EC2 instances. > Originally created to spin up instances to compile Python extensions for AWS Lambda projects.

Pypi Link: https://pypi.python.org/pypi/ec2.py

Features:

  • Single command creation of security key and instance

  • Idempotent, repeated calls do not result in multiple instances

  • Waits for AWS tasks to complete and provides confirmation.

Supports:

  • AWS Profiles

  • Instance type specification

  • Key generation

  • Start/stop/terminate Instances

## Notes

By design, the application binds instance creation to a key file (custom name can be specified). This allows enhanced security around managing the life cycle of an instance, but requires creation of more than one keyfile for multiple instances.

## Installation

  • Install:
    • pip install ec2.py –upgrade

## Setup

## Usage

  • ec2 - Creates a new AWS instance of t2.nano, and a new Key ec2.py if either do not exist. If these already exist, will start the instance if stopped.

  • ec2 -s - Stop the instance. If one does not exist, will create a key and new instance.

  • ec2 -r - Remove the instance (terminates) and delete the key.

  • ec2 -i - Print the public dns name. Allows calling from another bash script.

  • ec2 -i -v - Print the instance type, ami image, public ip address, public dns name.

  • ec2 -p myProfile -k myKey -t t2.medium - Use a custom profile, key name and instance type.

  • ec2 -h - Help

## SSH to a created instance:

  • Make sure the pem key has chmod 0600, example: chmod 600 ec2.py.pem

  • Make sure the security group for the instance has port 22 connectivity allowed.

  • Get the Public DNS name for the instance: ec2 -i

  • Connect: ssh ec2-user@DNS_NAME -i ec2.py.pem

## Developer Setup

  • Install VirtualEnvWrapper
    • sudo pip install virtualenvwrapper –upgrade

    • echo “source /usr/local/bin/virtualenvwrapper.sh” >> ~/.bashrc”

  • Create / switch to Virtual Env
    • mkvirtualenv ec2 or workon ec2

  • Setup
    • make setup

## AMI Info

## Articles

## Links

Release files for ec2.py 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ec2.py 0.1.5
File Size Uploaded
ec2.py-0.1.5.tar.gz 4.8 kB Details

Release files / ec2.py-0.1.5.tar.gz

Download URL ec2.py-0.1.5.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
54c1b550009e1938d048bd171ac075f0dbfc88089fbf2687b1868783a3556580
BLAKE2b-256 checksum
How to use checksums
525e5923f5e335fe65d8d076f36ccdbaf495dc16f12fee9d2e1e0aa0a468c9a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page