Open Rainforest Machine Image - CLI tool for creating AWS AMIs
Project description
ORFMI - Open Rainforest Machine Image
A Python CLI tool for creating AWS AMIs from configuration files and setup scripts.
Installation
pip install orfmi
Usage
Using a Configuration File
orfmi --config-file config.yml --setup-file setup.sh
Using CLI Flags
orfmi --ami-name my-ami \
--region us-east-1 \
--source-ami "debian-12-*" \
--subnet-ids subnet-12345 subnet-67890 \
--instance-types t3.micro t3.small \
--setup-file setup.sh
Arguments
Required (one of)
Either use --config-file OR provide all individual flags:
--config-file FILE- Path to the YAML configuration file--ami-name NAME- Name for the created AMI--region REGION- AWS region--source-ami AMI_ID- Source AMI name pattern--subnet-ids SUBNET [SUBNET ...]- Subnet IDs for instance launch--instance-types TYPE [TYPE ...]- Instance types to try
Always Required
--setup-file FILE- Path to the setup script (bash or PowerShell)
Optional
--purchase-type TYPE- Purchase type:on-demandorspot--max-retries N- Maximum retries on capacity errors (default: 3)--extra-files FILE [FILE ...]- Additional files to upload-v, --verbose- Enable verbose output-q, --quiet- Suppress output except for errors and the final AMI ID
Configuration File
The configuration file is a YAML file with the following structure:
# Required fields
ami_name: my-custom-ami
region: us-east-1
source_ami: debian-12-* # AMI name pattern to search for
subnet_ids:
- subnet-12345abc
- subnet-67890def
instance_types:
- t3.micro
- t3.small
# Optional fields
ami_description: My custom AMI for production
iam_instance_profile: my-instance-profile
purchase_type: on-demand # on-demand or spot, default: on-demand
max_retries: 3 # default: 3 retries on capacity errors
ssh_username: admin # default: admin
ssh_timeout: 300 # default: 300 seconds
ssh_retries: 30 # default: 30 retries
platform: linux # linux or windows, default: linux
tags:
Name: my-ami
Environment: production
Required Fields
| Field | Description |
|---|---|
ami_name |
Name for the created AMI |
region |
AWS region |
source_ami |
Source AMI name pattern (supports wildcards) |
subnet_ids |
List of subnet IDs for launching the instance |
instance_types |
List of instance types to try (uses EC2 Fleet) |
Optional Fields
| Field | Default | Description |
|---|---|---|
ami_description |
"" |
Description for the AMI |
iam_instance_profile |
null |
IAM instance profile name |
purchase_type |
on-demand |
on-demand or spot |
max_retries |
3 |
Max retries on capacity errors |
ssh_username |
admin |
SSH username for connecting |
ssh_timeout |
300 |
SSH command timeout (seconds) |
ssh_retries |
30 |
Number of SSH connection tries |
platform |
linux |
linux or windows |
tags |
{} |
Tags to apply to resources |
Setup Script
The setup script runs on the instance to configure it before creating the AMI.
Linux (Bash)
#!/bin/bash
set -e
# Update packages
apt-get update
apt-get upgrade -y
# Install required software
apt-get install -y docker.io git
# Enable services
systemctl enable docker
# Clean up
apt-get clean
rm -rf /var/lib/apt/lists/*
Windows (PowerShell)
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force
$url = 'https://chocolatey.org/install.ps1'
iex ((New-Object System.Net.WebClient).DownloadString($url))
# Install software
choco install -y git docker-desktop
Exit Codes
| Code | Description |
|---|---|
| 0 | Success - AMI created |
| 1 | Build failure |
| 2 | Configuration or usage error |
Output
On success, the tool outputs the AMI ID in the format:
AMI_ID=ami-0123456789abcdef0
How It Works
- Parses the configuration file or CLI arguments
- Looks up the source AMI by name pattern
- Creates temporary resources (key pair, security group, launch template)
- Launches an EC2 instance using EC2 Fleet (on-demand or spot)
- Waits for the instance to be ready
- Connects via SSH and runs the setup script
- Creates an AMI from the configured instance
- Cleans up all temporary resources
- Outputs the AMI ID
Retry Logic
The tool automatically retries on capacity errors (e.g., insufficient
capacity, instance limit exceeded) and spot instance interruptions.
Use --max-retries to configure the maximum number of retry attempts.
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orfmi-20260115000944.tar.gz.
File metadata
- Download URL: orfmi-20260115000944.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e39504975feb4bb1b42ba97124cedf1bfba513061d776b79473908fc0f11ae6
|
|
| MD5 |
970824f9374c41069108f134e56b4103
|
|
| BLAKE2b-256 |
6731dea3c88937c7399d5b0116185ff4fb8688180f166eee881e0162dc5f480c
|
Provenance
The following attestation bundles were made for orfmi-20260115000944.tar.gz:
Publisher:
release.yml on 10U-Labs-LLC/orfmi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orfmi-20260115000944.tar.gz -
Subject digest:
5e39504975feb4bb1b42ba97124cedf1bfba513061d776b79473908fc0f11ae6 - Sigstore transparency entry: 825013221
- Sigstore integration time:
-
Permalink:
10U-Labs-LLC/orfmi@19fbc0587341d06c7b25543de01df6789d0ce428 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/10U-Labs-LLC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19fbc0587341d06c7b25543de01df6789d0ce428 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file orfmi-20260115000944-py3-none-any.whl.
File metadata
- Download URL: orfmi-20260115000944-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a582b3bcc002c3356f4fe9f439413d25ab0034ba835c3587d69aa43bce9aa710
|
|
| MD5 |
6b0399a2f16c2104a46bf4679b5ad154
|
|
| BLAKE2b-256 |
1c448478b5edbbfce2aa2aae3b2ca801ec0aa33dbb543608f8e685cb59ee6dd7
|
Provenance
The following attestation bundles were made for orfmi-20260115000944-py3-none-any.whl:
Publisher:
release.yml on 10U-Labs-LLC/orfmi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
orfmi-20260115000944-py3-none-any.whl -
Subject digest:
a582b3bcc002c3356f4fe9f439413d25ab0034ba835c3587d69aa43bce9aa710 - Sigstore transparency entry: 825013278
- Sigstore integration time:
-
Permalink:
10U-Labs-LLC/orfmi@19fbc0587341d06c7b25543de01df6789d0ce428 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/10U-Labs-LLC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@19fbc0587341d06c7b25543de01df6789d0ce428 -
Trigger Event:
workflow_run
-
Statement type: