# ⚡ Flashenv

> **The fastest way to spin up disposable Docker environments on AWS.**

[![Python 3.14+](https://img.shields.io/badge/python-3.14+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code Style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

**FlashEnv** is a CLI tool designed for developers who need a fresh, isolated Docker environment in seconds. It automates the boring stuff: creating EC2 instances, configuring Security Groups, managing SSH keys, and installing Docker.

Stop paying for idle staging servers. Spin it up, test your code, and **nuke it** when you're done.

---

## 🚀 Features

- **1-Command Deploy:** Launches an EC2 instance and auto-installs Docker.
- **💸 Spot Mode:** Use AWS Spot Instances to save up to **70%** on costs (`--spot`).
- **🔐 Zero-Config SSH:** Connect instantly with `flashenv env ssh <name>`. No key management required.
- **🐳 Docker Integration:** Auto-pulls your specified image and fetches logs remotely.
- **💰 FinOps:** Real-time cost estimation based on your region's pricing.
- **☢️ Nuke Protocol:** One command to tear down _everything_ (Instances, Keys, SGs) and stop billing immediately.

---

## 🛠️ Prerequisites

1.  **Python 3.10+** installed.
2.  **AWS Account** with an Access Key and Secret Key.
3.  **AWS CLI** configured (optional, but recommended):
    ```bash
    aws configure
    ```
    _(Or simply export `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in your terminal)._

---

## 📦 Installation

### Option 1: Via Pip

```bash
pip install flashenv
```

### Option 2: Via Poetry (Recommended for Devs)

```bash
git clone https://github.com/zoldik333/flashenv.git
cd src
poetry install
poetry shell
```

---

## ⚡ Quickstart

### 1. Initiatilize

Sets up the local database, generates a secure SSH key pair, and uploads it to AWS.

```bash
flashenv init
```

### 2. Launch an environment

Create a t2.micro instance running Nginx on a Spot Instance (cheap!).

```bash
flashenv env create web-test --image nginx --spot
```

### 3. Connect

SSH directly into the box.

```bash
flashenv env ssh web-test
```

### 4. Check logs

View the logs of your remote container to debug applications.

```bash
flashenv env logs web-test
```

### 5. Display costs

See how much you've spent so far (Real-time estimate).

```bash
flashenv cost
```

### 5. Destroy

Remove the environment when you are done.

```bash
flashenv env delete web-test
```

Remove everyting completely.

```bash
flashenv nuke
```

---

## 📦 Config structure

Configuration files and state are stored in your home directory.

```text
~/.flashenv/
├── id_rsa          # Private SSH key (Permissions 600)
├── id_rsa.pub      # Public SSH key (Uploaded to AWS)
└── state.json      # Local database of active environments
```

---

## 📄 License

This project is licensed under the [MIT License](LICENSE).
