Metadata-Version: 2.4
Name: orfmi
Version: 20260114231306
Summary: Open Rainforest Machine Image - CLI tool for creating AWS AMIs
Author-email: 10U Labs <dev@10ulabs.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/10U-Labs-LLC/orfmi
Project-URL: Issues, https://github.com/10U-Labs-LLC/orfmi/issues
Project-URL: Repository, https://github.com/10U-Labs-LLC/orfmi
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: boto3>=1.34.0
Requires-Dist: paramiko>=3.4.0
Requires-Dist: pyyaml>=6.0
Dynamic: license-file

# ORFMI - Open Rainforest Machine Image

A Python CLI tool for creating AWS AMIs from configuration files and
setup scripts.

## Installation

```bash
pip install orfmi
```

## Usage

```bash
orfmi --config-file config.yml --setup-file setup.sh
```

### Required Arguments

- `--config-file FILE` - Path to the YAML configuration file
- `--setup-file FILE` - Path to the setup script (bash or PowerShell)

### Optional Arguments

- `--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:

```yaml
# 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
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          |
| `ssh_username`         | `admin`   | SSH username for connecting        |
| `ssh_timeout`          | `300`     | SSH command timeout in seconds     |
| `ssh_retries`          | `30`      | Number of SSH connection retries   |
| `platform`             | `linux`   | Platform type (`linux`/`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)

```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)

```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:

```text
AMI_ID=ami-0123456789abcdef0
```

## How It Works

1. Parses the configuration file
2. Looks up the source AMI by name pattern
3. Creates temporary resources (key pair, security group, launch template)
4. Launches an EC2 spot instance using EC2 Fleet
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 all temporary resources
9. Outputs the AMI ID

## License

Apache License 2.0
