awslaunch.py

Idempotent EC2 launcher by Name tag. Reuses an existing non-terminated instance when possible and otherwise creates a new one.

Usage

awslaunch.py <name> [instance_type] [--ami AMI_ID] [--region REGION] [--profile PROFILE] [--spot]

Behavior

Ensures a per-host keypair exists in AWS and under ~/.ssh/<name>.pem.

Looks up an existing instance by Name tag in pending, running, stopping, or stopped state. If found, it starts the instance when needed and waits for a public IP.

If no instance exists, it launches a new one with the configured AMI, instance type, root volume settings, and optional one-time spot market options.

Prints a Hosts: line containing IP, host names, and instance id. Other tooling and playbooks parse that line to update inventory and hosts state.

version 1  ·  created 2026-05-12  ·  updated 2026-05-12  ·  tags ['aws', 'ec2', 'launch']