Skip to main content

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 \
      --security-group-id sg-12345abc \
      --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 SUBNETS - Comma-separated subnet IDs
  • --instance-types TYPES - Comma-separated instance types
  • --security-group-id SG_ID - Security group ID

Always Required

  • --setup-file FILE - Path to the setup script (bash or PowerShell)

Optional

  • --ami-description DESC - Description for the AMI
  • --iam-instance-profile PROFILE - IAM instance profile name
  • --purchase-type TYPE - Purchase type: on-demand or spot
  • --max-retries N - Maximum retries on capacity errors (default: 3)
  • --ssh-username USER - SSH username for connecting (default: admin)
  • --ssh-timeout SECONDS - SSH timeout in seconds (default: 300)
  • --ssh-retries N - SSH connection retries (default: 30)
  • --platform PLATFORM - Platform: linux or windows (default: linux)
  • --tags TAGS - Tags as key=value,key=value (e.g., Name=test,Env=prod)
  • -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
security_group_id: sg-12345abc

# 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 (EC2 Fleet)
security_group_id Security group ID with SSH/RDP access

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

  1. Parses the configuration file or CLI arguments
  2. Looks up the source AMI by name pattern
  3. Creates temporary resources (key pair, launch template)
  4. Launches an EC2 instance using EC2 Fleet (on-demand or spot)
  5. Waits for the instance to be ready
  6. Connects via SSH and runs the setup script
  7. Creates an AMI from the configured instance
  8. Cleans up temporary resources
  9. 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.

Metadata

Release files for orfmi 20260115011421

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

Source distribution (sdist)

Source distribution for orfmi 20260115011421
File Size Uploaded Provenance
orfmi-20260115011421.tar.gz 36.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for orfmi 20260115011421
File Interpreter ABI Platform
orfmi-20260115011421-py3-none-any.whl Python 3 none any Details

Total release size: 56.0 kB

Release files / orfmi-20260115011421.tar.gz

Download URL orfmi-20260115011421.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c1168f5a590fbc2ecfa6d38384fcf7ebc175e1f8a8191a4d947b9da110509720
BLAKE2b-256 checksum
How to use checksums
a5ac6701f36ebff63959401f9918c58c1f003431a85c4c0d93720fb51b3cab9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.

Transparency log

Release files / orfmi-20260115011421-py3-none-any.whl

Download URL orfmi-20260115011421-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e59a8917421ff61d03a9c23461daba97e5d7dae8434053ba7ea37d8b78131186
BLAKE2b-256 checksum
How to use checksums
4decb6306f03f2cdd1cb146fa304df316f358a8f4c71e5d3e6c37fe40f6381cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.

Transparency log

Security for orfmi 20260115011421

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for orfmi-20260115011421.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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