<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryo Guritno on Medium]]></title>
        <description><![CDATA[Stories by Ryo Guritno on Medium]]></description>
        <link>https://medium.com/@kryukz?source=rss-945136394d8a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*swnSfRdGpJpIN_n06sxO8Q.png</url>
            <title>Stories by Ryo Guritno on Medium</title>
            <link>https://medium.com/@kryukz?source=rss-945136394d8a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 17:06:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kryukz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Garage Standalone: Your Lightweight S3-Compatible Object Storage Journey]]></title>
            <link>https://medium.com/@kryukz/garage-standalone-your-lightweight-s3-compatible-object-storage-journey-5073bd51b566?source=rss-945136394d8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5073bd51b566</guid>
            <dc:creator><![CDATA[Ryo Guritno]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 15:17:57 GMT</pubDate>
            <atom:updated>2025-12-22T15:17:57.620Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lerU-Fl-vDL1RFRp" /><figcaption>Photo by <a href="https://unsplash.com/@tanyabarrow?utm_source=medium&amp;utm_medium=referral">Tanya Barrow</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction: Why Another Object Storage Solution?</h3><p>If you’ve been exploring self-hosted object storage solutions, you’ve probably heard about MinIO. It’s powerful, feature-rich, and widely adopted. But what if you’re running a home lab, a small startup, or just need something Open Source project? Enter <strong>Garage</strong> — an S3-compatible object storage system that runs reliably on consumer hardware and even Raspberry Pi devices.</p><p>In this guide, we’ll explore Garage in standalone mode, perfect for single-node deployments where you need reliable storage without the complexity of distributed systems.</p><h3>What is Garage?</h3><p>Garage is an S3-compatible object storage solution designed to run reliably outside traditional datacenters, even on consumer-grade hardware and internet connections. Developed by Deuxfleurs, a French non-profit organization, Garage was built with a specific philosophy: storage systems should be simple, resilient, and work with the hardware you actually have.</p><h3>Key Philosophy</h3><p>Unlike traditional object storage systems that assume high-end datacenter infrastructure, Garage exploits knowledge of storage node capacity and physical location to design a storage plan that maximizes available capacity. This makes it ideal for:</p><ul><li><strong>Home labs and self-hosters</strong> running on spare hardware</li><li><strong>Small businesses</strong> without dedicated IT infrastructure</li><li><strong>Edge deployments</strong> across multiple locations</li><li><strong>Distributed teams</strong> needing shared storage without cloud dependencies</li></ul><h3>Core Features</h3><p><strong>Lightweight Resource Usage</strong><br> Garage is designed to run on modest hardware, making it perfect for home labs and small businesses, and can operate efficiently on ARM devices like Raspberry Pi. You can run it on machines that would struggle with other solutions.</p><p><strong>S3 API Compatibility</strong><br> Garage implements the Amazon S3 API and is compatible with many applications. This means you can use familiar tools like:</p><ul><li>AWS CLI</li><li>s3cmd</li><li>rclone</li><li>Restic for backups</li><li>Nextcloud, Mastodon, Peertube as backends</li></ul><p><strong>No Consensus Overhead</strong><br> Garage does not use RAFT or another consensus algorithm internally, meaning all requests can be handled independently instead of going through a central bottleneck. This results in faster request handling, especially valuable for standalone deployments.</p><p><strong>Built-in Deduplication and Compression</strong><br> All data stored in Garage is deduplicated, and optionally compressed using Zstd, helping you maximize storage efficiency without manual intervention.</p><h3>Garage vs MinIO: A Practical Comparison</h3><p>Let’s be honest — both are excellent tools, but they serve different audiences and use cases. Here’s what you need to know:</p><h3>Quick Comparison Table</h3><p>Feature Garage MinIO <strong>Resource Requirements</strong> Very low (runs on Raspberry Pi) Moderate to High <strong>Target Audience</strong> Self-hosters, small deployments Enterprise, large-scale AI/ML <strong>Minimum Setup</strong> 1 node, any hardware 4+ nodes recommended for production <strong>Network Requirements</strong> Works over consumer internet Prefers low-latency datacenter networks <strong>Operational Complexity</strong> Minimal (single binary) Moderate (requires planning) <strong>Admin UI</strong> Basic CLI-based Full-featured web console <strong>S3 Feature Coverage</strong> Core S3 operations Extensive S3 + enterprise features <strong>Erasure Coding</strong> Not yet implemented Full Reed-Solomon erasure coding <strong>Best For</strong> Home labs, distributed sites, edge AI workloads, large enterprises</p><h3>When to Choose Garage</h3><p><strong>Choose Garage if you:</strong></p><ul><li>Run a home lab or personal server on consumer hardware</li><li>Need geo-distributed storage across home/office/cloud</li><li>Want simple operations without dedicated storage expertise</li><li>Have limited resources (CPU, RAM, bandwidth)</li><li>Value simplicity over maximum performance</li><li>Need reliable storage that “just works” on mixed hardware</li></ul><p><strong>Example scenarios:</strong></p><ul><li>Personal backup solution across multiple locations</li><li>Media server storage for Jellyfin/Plex</li><li>Backend storage for self-hosted apps (Nextcloud, Mastodon)</li><li>Small team file sharing without cloud dependencies</li></ul><h3>When to Choose MinIO</h3><p><strong>Choose MinIO if you:</strong></p><ul><li>Run production workloads requiring maximum performance</li><li>Have dedicated, homogeneous hardware infrastructure</li><li>Need advanced features like object locking, versioning, lifecycle policies</li><li>Work with AI/ML workloads requiring GPU-speed storage</li><li>Require enterprise support and SLAs</li><li>Have a dedicated operations team</li></ul><p><strong>Example scenarios:</strong></p><ul><li>AI/ML training data lakes requiring high throughput</li><li>Large-scale analytics platforms</li><li>Multi-tenant production environments</li><li>Compliance-heavy industries needing advanced features</li></ul><h3>Pros and Cons: Making an Informed Decision</h3><h3>Garage Advantages ✅</h3><p><strong>Operational Simplicity</strong><br> Single binary deployment, minimal configuration, and straightforward troubleshooting. You can be up and running in minutes, not days.</p><p><strong>Hardware Flexibility</strong><br> Garage can operate efficiently on ARM devices like Raspberry Pi, consuming minimal CPU and RAM resources. Use whatever hardware you have available.</p><p><strong>Geographic Distribution</strong><br> Garage’s standout feature is its built-in support for geographic distribution, allowing you to deploy nodes across different locations even with consumer internet connections.</p><p><strong>Cost Efficiency</strong><br> Users report a 90% cost reduction compared to cloud storage, with one-time hardware investments replacing recurring cloud bills.</p><p><strong>Resilience Over Internet</strong><br> Garage works well even at home, using consumer-grade Internet connectivity such as FTTH, handling latency and temporary disconnections gracefully.</p><p><strong>Open Source &amp; Privacy</strong><br> Garage is fully open-source under the AGPL-3.0 license, giving you complete control over your data without vendor lock-in.</p><h3>Garage Limitations ⚠️</h3><p><strong>Limited S3 Feature Set</strong><br> Garage implements core S3 operations but lacks some advanced features like erasure coding, object locking, and full versioning support.</p><p><strong>Smaller Community</strong><br> Compared to MinIO, Garage has a smaller user base, which means fewer community resources, tutorials, and third-party integrations.</p><p><strong>Performance Ceiling</strong><br> While efficient, Garage is not optimized for extreme performance scenarios like AI/ML workloads that require saturating 100Gbit networks.</p><p><strong>Beta Status</strong><br> Some features are still evolving, and you may encounter edge cases in less common configurations.</p><h3>Prerequisites: What You’ll Need</h3><p>Before diving into the setup, make sure you have:</p><h3>System Requirements</h3><p><strong>Hardware (Minimum for Standalone)</strong></p><ul><li>CPU: Any x86_64 or ARM v7/v8 processor</li><li>RAM: 512MB minimum, 1GB recommended</li><li>Storage: Separate volumes for data and metadata (recommended)</li><li>Network: Consumer-grade internet connection is sufficient</li></ul><p><strong>Software</strong></p><ul><li>Docker 20.10 or later</li><li>Docker Compose 2.0 or later</li><li>Basic command-line familiarity</li><li>Text editor for configuration</li></ul><p><strong>Operating System</strong></p><ul><li>Linux (Ubuntu 20.04+, Debian 11+, etc.)</li><li>macOS with Docker Desktop</li><li>Windows with WSL2 and Docker Desktop</li></ul><h3>Knowledge Prerequisites</h3><p>You should be comfortable with:</p><ul><li>Basic Docker concepts (containers, volumes, networking)</li><li>Command-line operations (cd, ls, cat, etc.)</li><li>Editing text files</li><li>Basic networking concepts (ports, IP addresses)</li></ul><h3>Setting Up Garage Standalone</h3><p>Now let’s get hands-on! We’ll set up a single-node Garage instance using Docker Compose.</p><h3>Step 1: Clone the Repository</h3><pre># Clone the repository<br>git clone https://github.com/ryoguritno/garage-docker.git<br>cd garage-docker/garage-standalone-ready</pre><pre># Review the structure<br>ls -la</pre><p>You should see:</p><ul><li>docker-compose.yml - Orchestration configuration</li><li>garage.toml - Garage server configuration</li><li>scripts/ - Helper scripts for setup</li><li>.env.example - Environment variables template</li></ul><h3>Step 2: Configure Environment Variables</h3><pre># Copy the example environment file<br>cp .env.example .env</pre><pre># Edit with your preferred editor<br>nano .env</pre><p>Key variables to configure:</p><pre># Garage version<br>GARAGE_VERSION=v0.9.4</pre><pre># Network configuration<br>GARAGE_RPC_BIND_ADDR=0.0.0.0:3901<br>GARAGE_RPC_PUBLIC_ADDR=127.0.0.1:3901</pre><pre># Storage paths<br>GARAGE_DATA_DIR=./data<br>GARAGE_META_DIR=./meta</pre><pre># S3 API endpoint<br>GARAGE_S3_API_ADDR=0.0.0.0:3900</pre><p><strong>Important notes:</strong></p><ul><li>RPC_BIND_ADDR: Internal communication address (keep as 0.0.0.0)</li><li>RPC_PUBLIC_ADDR: How nodes find each other (use your server IP for remote access)</li><li>Keep data and metadata on separate volumes for best performance</li></ul><h3>Step 3: Review Garage Configuration</h3><p>Open garage.toml to understand the configuration:</p><pre>metadata_dir = &quot;/var/lib/garage/meta&quot;<br>data_dir = &quot;/var/lib/garage/data&quot;</pre><pre>db_engine = &quot;lmdb&quot;</pre><pre>replication_mode = &quot;none&quot;</pre><pre>compression_level = 1</pre><pre>rpc_bind_addr = &quot;[::]:3901&quot;<br>rpc_public_addr = &quot;127.0.0.1:3901&quot;<br>rpc_secret = &quot;your-secret-key-here&quot;</pre><pre>[s3_api]<br>s3_region = &quot;garage&quot;<br>api_bind_addr = &quot;[::]:3900&quot;<br>root_domain = &quot;.s3.garage.localhost&quot;</pre><pre>[s3_web]<br>bind_addr = &quot;[::]:3902&quot;<br>root_domain = &quot;.web.garage.localhost&quot;</pre><pre>[admin]<br>api_bind_addr = &quot;[::]:3903&quot;</pre><p><strong>Key configuration parameters:</strong></p><ul><li>db_engine = &quot;lmdb&quot;: Database for metadata (default, reliable)</li><li>replication_mode = &quot;none&quot;: No replication in standalone mode</li><li>compression_level = 1: Light compression (0=none, 1-6=increasing compression)</li><li>rpc_secret: Shared secret for node communication (generate a strong random string)</li></ul><h3>Step 4: Generate RPC Secret</h3><p>The RPC secret is crucial for security. Generate a strong one:</p><pre># Generate a random 32-character secret<br>openssl rand -base64 32</pre><pre># Or use this simpler method<br>cat /dev/urandom | tr -dc &#39;a-zA-Z0-9&#39; | fold -w 32 | head -n 1</pre><p>Replace your-secret-key-here in garage.toml with your generated secret.</p><h3>Step 5: Launch Garage</h3><pre># Start the container<br>docker compose up -d</pre><pre># Check the logs<br>docker compose logs -f garage</pre><pre># You should see output like:<br># [INFO] Garage starting...<br># [INFO] RPC server listening on [::]:3901<br># [INFO] S3 API listening on [::]:3900</pre><p><strong>Common startup issues:</strong></p><pre># Port already in use<br># Error: bind: address already in use<br># Solution: Change ports in docker-compose.yml</pre><pre># Permission denied<br># Error: Permission denied (os error 13)<br># Solution: Check directory permissions<br>sudo chown -R 1000:1000 ./data ./meta</pre><h3>Step 6: Initialize the Cluster</h3><p>Even in standalone mode, Garage requires cluster initialization:</p><pre># Get your node ID<br>docker compose exec garage garage status</pre><pre># Output will show something like:<br># ==== HEALTHY NODES ====<br># ID: 1234abcd5678...<br># Hostname: garage-standalone</pre><p>Now configure the layout:</p><pre># Assign capacity to your node (1G = 1 Gigabyte of capacity)<br>docker compose exec garage garage layout assign -z default -c 1G &lt;YOUR_NODE_ID&gt;</pre><pre># Example:<br># docker compose exec garage garage layout assign -z default -c 1G 1234abcd5678</pre><pre># Review the layout<br>docker compose exec garage garage layout show</pre><pre># Apply the configuration (version 1 for first setup)<br>docker compose exec garage garage layout apply --version 1</pre><pre># Verify cluster status<br>docker compose exec garage garage status</pre><p><strong>Understanding capacity allocation:</strong></p><ul><li>-z default: Zone name (use descriptive names like &quot;home&quot;, &quot;office&quot;)</li><li>-c 1G: Capacity in bytes, K, M, G, or T</li><li>Start conservative, you can increase later</li></ul><h3>Step 7: Create S3 Credentials</h3><pre># Create a new key for S3 access<br>docker compose exec garage garage key create my-access-key</pre><pre># Output shows:<br># Key created successfully<br># Access Key ID: GK123...<br># Secret Access Key: abc123...<br># Region: garage</pre><p><strong>Save these credentials securely!</strong> You’ll need them to access your storage.</p><h3>Step 8: Create Your First Bucket</h3><pre># Create a bucket<br>docker compose exec garage garage bucket create my-first-bucket</pre><pre># Grant access to your key<br>docker compose exec garage garage bucket allow \<br>  --read --write \<br>  my-first-bucket \<br>  --key my-access-key</pre><pre># List buckets to verify<br>docker compose exec garage garage bucket list</pre><h3>Step 9: Test with AWS CLI</h3><p>Install AWS CLI if you haven’t:</p><pre># Ubuntu/Debian<br>sudo apt install awscli</pre><pre># macOS<br>brew install awscli</pre><pre># Configure AWS CLI for Garage<br>aws configure set aws_access_key_id GK123...<br>aws configure set aws_secret_access_key abc123...<br>aws configure set region garage</pre><p>Test the connection:</p><pre># Create a test file<br>echo &quot;Hello from Garage!&quot; &gt; test.txt</pre><pre># Upload to S3<br>aws s3 cp test.txt s3://my-first-bucket/ \<br>  --endpoint-url <a href="http://localhost:3900/">http://localhost:3900</a></pre><pre># List objects<br>aws s3 ls s3://my-first-bucket/ \<br>  --endpoint-url <a href="http://localhost:3900/">http://localhost:3900</a></pre><pre># Download file<br>aws s3 cp s3://my-first-bucket/test.txt downloaded.txt \<br>  --endpoint-url <a href="http://localhost:3900/">http://localhost:3900</a></pre><pre># Verify content<br>cat downloaded.txt</pre><p><strong>Success!</strong> You now have a working Garage standalone instance.</p><h3>Storage Architecture Best Practices</h3><h3>Separating Metadata and Data</h3><p>For optimal performance, use separate volumes:</p><pre># In docker-compose.yml<br>volumes:<br>  - ./meta:/var/lib/garage/meta    # Fast storage (SSD preferred)<br>  - ./data:/var/lib/garage/data    # Bulk storage (HDD acceptable)</pre><p><strong>Why separate them?</strong></p><ul><li>Metadata: Frequently accessed, benefits from SSD speed</li><li>Data: Large volumes, can use slower but cheaper storage</li></ul><h3>Filesystem Recommendations</h3><p>For data storage, XFS provides optimal performance, while you should avoid EXT4 for large object counts due to inode limitations.</p><pre># Check your filesystem<br>df -T</pre><pre># XFS is ideal for data volumes<br># BTRFS or ZFS are good for metadata (integrity features)</pre><h3>Monitoring Storage Usage</h3><pre># Check Garage statistics<br>docker compose exec garage garage stats</pre><pre># Check disk usage<br>docker compose exec garage df -h /var/lib/garage/data<br>docker compose exec garage df -h /var/lib/garage/meta</pre><pre># Docker volume inspection<br>docker system df</pre><h3>Integrating with Applications</h3><h3>Nextcloud Integration</h3><p>Configure Nextcloud to use Garage as primary storage:</p><pre>// In config/config.php<br>&#39;objectstore&#39; =&gt; [<br>  &#39;class&#39; =&gt; &#39;\\OC\\Files\\ObjectStore\\S3&#39;,<br>  &#39;arguments&#39; =&gt; [<br>    &#39;bucket&#39; =&gt; &#39;nextcloud&#39;,<br>    &#39;key&#39; =&gt; &#39;your-access-key&#39;,<br>    &#39;secret&#39; =&gt; &#39;your-secret-key&#39;,<br>    &#39;hostname&#39; =&gt; &#39;garage-server-ip&#39;,<br>    &#39;port&#39; =&gt; 3900,<br>    &#39;use_ssl&#39; =&gt; false,<br>    &#39;region&#39; =&gt; &#39;garage&#39;,<br>    &#39;use_path_style&#39; =&gt; true<br>  ],<br>],</pre><h3>Backup with Restic</h3><pre># Install Restic<br>sudo apt install restic</pre><pre># Initialize repository<br>export AWS_ACCESS_KEY_ID=your-access-key<br>export AWS_SECRET_ACCESS_KEY=your-secret-key</pre><pre>restic -r s3:http://localhost:3900/backups init</pre><pre># Create backup<br>restic -r s3:http://localhost:3900/backups \<br>  backup /home/user/documents</pre><pre># List snapshots<br>restic -r s3:http://localhost:3900/backups snapshots</pre><h3>Using with rclone</h3><pre># Install rclone<br>curl https://rclone.org/install.sh | sudo bash</pre><pre># Configure rclone<br>rclone config</pre><pre># Choose: s3<br># Provider: Other<br># Access Key: your-access-key<br># Secret Key: your-secret-key<br># Region: garage<br># Endpoint: <a href="http://localhost:3900/">http://localhost:3900</a></pre><pre># Copy files<br>rclone copy /local/path garage:my-bucket/</pre><h3>Troubleshooting Common Issues</h3><h3>Connection Refused</h3><p><strong>Problem:</strong> Connection refused when accessing S3 API</p><p><strong>Solutions:</strong></p><pre># Check if Garage is running<br>docker compose ps</pre><pre># Check logs<br>docker compose logs garage</pre><pre># Verify port binding<br>docker compose port garage 3900</pre><pre># Test locally<br>curl <a href="http://localhost:3900/">http://localhost:3900</a></pre><h3>Permission Errors</h3><p><strong>Problem:</strong> Permission denied errors in logs</p><p><strong>Solutions:</strong></p><pre># Fix data directory permissions<br>sudo chown -R 1000:1000 ./data ./meta</pre><pre># Or run as root (not recommended for production)<br>docker compose run --user root garage</pre><h3>Storage Not Appearing</h3><p><strong>Problem:</strong> Objects uploaded but not showing in listings</p><p><strong>Solutions:</strong></p><pre># Verify bucket permissions<br>docker compose exec garage garage bucket list<br>docker compose exec garage garage bucket info my-bucket</pre><pre># Check key permissions<br>docker compose exec garage garage key list<br>docker compose exec garage garage key info my-access-key</pre><pre># Re-grant permissions<br>docker compose exec garage garage bucket allow \<br>  --read --write my-bucket --key my-access-key</pre><h3>High Memory Usage</h3><p><strong>Problem:</strong> Garage consuming too much memory</p><p><strong>Solutions:</strong></p><pre># Check actual usage<br>docker stats garage</pre><pre># Adjust block size in garage.toml<br># block_size = &quot;1M&quot;  # Default is good for most cases</pre><pre># Limit Docker container memory<br># In docker-compose.yml:<br>services:<br>  garage:<br>    mem_limit: 512m</pre><h3>Slow Performance</h3><p><strong>Problem:</strong> Slow upload/download speeds</p><p><strong>Solutions:</strong></p><pre># Check network<br>docker compose exec garage ping -c 4 8.8.8.8</pre><pre># Monitor disk I/O<br>docker stats garage</pre><pre># Move metadata to SSD if on HDD<br># Adjust compression in garage.toml<br>compression_level = 0  # Disable if CPU-constrained</pre><h3>Upgrading and Maintenance</h3><h3>Upgrading Garage</h3><pre># Check current version<br>docker compose exec garage garage --version</pre><pre># Pull new image<br>docker compose pull</pre><pre># Stop and restart<br>docker compose down<br>docker compose up -d</pre><pre># Verify upgrade<br>docker compose logs -f garage</pre><h3>Backup Configuration</h3><pre># Backup critical files<br>tar -czf garage-backup-$(date +%Y%m%d).tar.gz \<br>  garage.toml \<br>  .env \<br>  docker-compose.yml \<br>  meta/</pre><pre># Store backups securely offsite</pre><h3>Regular Maintenance</h3><pre># Check cluster health (weekly)<br>docker compose exec garage garage status</pre><pre># Monitor disk usage (weekly)<br>du -sh data/ meta/</pre><pre># Review logs for errors (weekly)<br>docker compose logs garage | grep -i error</pre><pre># Prune old Docker resources (monthly)<br>docker system prune -a</pre><h3>Security Considerations</h3><h3>Network Security</h3><pre># For production, use reverse proxy with SSL<br># Example Nginx configuration:</pre><pre>server {<br>    listen 443 ssl;<br>    server_name s3.yourdomain.com;</pre><pre>    ssl_certificate /etc/letsencrypt/live/s3.yourdomain.com/fullchain.pem;<br>    ssl_certificate_key /etc/letsencrypt/live/s3.yourdomain.com/privkey.pem;</pre><pre>    location / {<br>        proxy_pass <a href="http://localhost:3900;">http://localhost:3900;</a><br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>    }<br>}</pre><h3>Access Key Rotation</h3><pre># Create new key<br>docker compose exec garage garage key create new-access-key</pre><pre># Update applications to use new key<br># ...</pre><pre># Delete old key<br>docker compose exec garage garage key delete old-access-key</pre><h3>Firewall Configuration</h3><pre># UFW example (Ubuntu)<br>sudo ufw allow 3900/tcp  # S3 API<br>sudo ufw allow 3902/tcp  # S3 Web (if used)<br>sudo ufw allow 3903/tcp  # Admin API (restrict to admin IPs)</pre><h3>Performance Tuning</h3><h3>Optimizing for Your Workload</h3><p><strong>Small files (&lt; 1MB):</strong></p><pre># In garage.toml<br>block_size = &quot;1M&quot;<br>compression_level = 2</pre><p><strong>Large files (&gt; 100MB):</strong></p><pre># In garage.toml<br>block_size = &quot;10M&quot;<br>compression_level = 1</pre><p><strong>High throughput:</strong></p><pre># In garage.toml<br>compression_level = 0  # Disable compression<br># Use SSD for both data and metadata</pre><h3>Docker Resource Limits</h3><pre># In docker-compose.yml<br>services:<br>  garage:<br>    deploy:<br>      resources:<br>        limits:<br>          cpus: &#39;2&#39;<br>          memory: 2G<br>        reservations:<br>          cpus: &#39;1&#39;<br>          memory: 512M</pre><h3>Migration Strategies</h3><h3>Migrating from Local Filesystem</h3><pre># Using rclone<br>rclone sync /local/path garage:my-bucket/ \<br>  --progress \<br>  --transfers 4</pre><h3>Migrating from MinIO</h3><pre># Configure both as rclone remotes<br>rclone config</pre><pre># Copy data<br>rclone copy minio:old-bucket garage:new-bucket/ \<br>  --progress \<br>  --checkers 8 \<br>  --transfers 4</pre><h3>Cost Analysis: Cloud vs Self-Hosted</h3><p><strong>Typical Cloud Costs (AWS S3):</strong></p><ul><li>Storage: $0.023/GB/month</li><li>GET requests: $0.0004/1000 requests</li><li>PUT requests: $0.005/1000 requests</li></ul><p><strong>For 1TB storage with 100K requests/month:</strong></p><ul><li>Storage: $23.50</li><li>Requests: $5</li><li><strong>Total: ~$28.50/month = $342/year</strong></li></ul><p><strong>Self-Hosted Garage:</strong></p><ul><li>Hardware: $200–400 (one-time)</li><li>Electricity: ~$5/month = $60/year</li><li><strong>Total Year 1: $260–460</strong></li><li><strong>Subsequent years: $60/year</strong></li></ul><p><strong>Break-even:</strong> 8–12 months</p><h3>Next Steps and Advanced Topics</h3><h3>Expanding to Cluster Mode</h3><p>When you outgrow standalone, you can seamlessly transition to cluster mode. Keep your same configuration and data — Garage makes this transition smooth. Check out the companion article “Garage Cluster: Multi-Node Distributed Storage” to learn how.</p><h3>Community and Resources</h3><p><strong>Official Documentation:</strong></p><ul><li><a href="https://garagehq.deuxfleurs.fr/documentation/">https://garagehq.deuxfleurs.fr/documentation/</a></li></ul><p><strong>Community:</strong></p><ul><li>Matrix: #garage:deuxfleurs.fr</li><li>GitHub: <a href="https://github.com/deuxfleurs-org/garage">https://github.com/deuxfleurs-org/garage</a></li><li>Forum: <a href="https://forum.deuxfleurs.fr/">https://forum.deuxfleurs.fr/</a></li></ul><p><strong>Useful Tools:</strong></p><ul><li>S3 Browser (GUI client)</li><li>Cyberduck (Desktop client)</li><li>s3cmd (CLI tool)</li></ul><h3>Getting Help</h3><p>When asking for help, provide:</p><pre># Garage version<br>docker compose exec garage garage --version</pre><pre># Configuration (sanitized)<br>cat garage.toml | grep -v secret</pre><pre># Recent logs<br>docker compose logs --tail 100 garage</pre><pre># Cluster status<br>docker compose exec garage garage status</pre><h3>Conclusion</h3><p>Garage standalone offers an excellent balance of simplicity, reliability, and resource efficiency for self-hosted object storage. While it may not have all the bells and whistles of enterprise solutions, it excels at what it’s designed for: providing reliable, S3-compatible storage that works on real-world infrastructure.</p><p><strong>Key Takeaways:</strong></p><p>✅ <strong>Perfect for:</strong> Home labs, small businesses, distributed deployments<br> ✅ <strong>Resource efficient:</strong> Runs on modest hardware, even Raspberry Pi<br> ✅ <strong>Simple operations:</strong> Single binary, minimal configuration<br> ✅ <strong>S3 compatible:</strong> Works with existing tools and applications<br> ✅ <strong>Cost effective:</strong> Significant savings over cloud storage</p><p><strong>Remember:</strong> Start simple, test thoroughly, and scale when needed. Garage’s design makes it easy to begin with a standalone node and expand to a distributed cluster as your needs grow.</p><h3>Repository</h3><p>The complete Docker Compose setup used in this guide is available at:<br> <a href="https://github.com/ryoguritno/garage-docker"><strong>https://github.com/ryoguritno/garage-docker</strong></a></p><p>Check the garage-standalone-ready/ directory for production-ready configurations, helper scripts, and additional documentation.</p><p><strong>Ready for distributed storage?</strong> Continue with the next article: “Garage Cluster: Building Multi-Site Resilient Object Storage” to learn how to deploy Garage across multiple nodes and geographic locations.</p><p><em>This article is part of a series on self-hosted object storage solutions. For questions or feedback, open an issue on the GitHub repository.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5073bd51b566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Rescued a Dead EC2 Instance Without Touching SSH Keys]]></title>
            <link>https://medium.com/@kryukz/how-i-rescued-a-dead-ec2-instance-without-touching-ssh-keys-e00f41bb0fe0?source=rss-945136394d8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e00f41bb0fe0</guid>
            <dc:creator><![CDATA[Ryo Guritno]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 14:34:24 GMT</pubDate>
            <atom:updated>2025-12-15T14:34:24.029Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Forget authorized_keys — here’s how to bypass SSH entirely by installing SSM Agent on a mounted volume</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1ZbVg6ZXqRuryqYw" /><figcaption>Photo by <a href="https://unsplash.com/@mrw0rld?utm_source=medium&amp;utm_medium=referral">Ilnur</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Problem That Keeps SREs Up at Night</h3><p>Picture this: It’s 2 AM, your production EC2 instance is unreachable via SSH, and your heart drops. The security group is fine, the network ACLs look good, but something inside the OS is broken. Maybe someone accidentally misconfigured sshd, corrupted a critical system file, or the instance just won&#39;t boot properly.</p><p><strong>Traditional “Mount and Fix” Solution:</strong> Attach the volume to a rescue instance, mount it, and add your public SSH key to /root/.ssh/authorized_keys.</p><p><strong>The Problem with That Approach:</strong></p><ul><li>❌ SSH service still needs to work</li><li>❌ Firewall/security groups must allow port 22</li><li>❌ Doesn’t help if SSH daemon is completely broken</li><li>❌ Requires managing SSH keys</li><li>❌ Instance still needs a public IP or bastion host</li></ul><p><strong>This Script’s Approach:</strong> Forget SSH entirely. Install AWS Systems Manager (SSM) Agent instead and access the instance through AWS’s secure tunnel.</p><h3>The Revolutionary Difference: SSH vs SSM</h3><p>Let me make this crystal clear with a side-by-side comparison:</p><h3>Traditional Volume Mount Recovery</h3><pre># Old way - Fixing SSH access<br>sudo mount /dev/sdf1 /mnt/broken-instance<br>sudo nano /mnt/broken-instance/root/.ssh/authorized_keys<br># Paste your public key<br>sudo umount /mnt/broken-instance<br># Reattach and hope SSH works now</pre><p><strong>You’re still dependent on:</strong></p><ul><li>SSH daemon running properly</li><li>Port 22 being accessible</li><li>Network connectivity to SSH port</li><li>SSH keys being in the right place with correct permissions</li></ul><h3>This Script’s Approach</h3><pre># New way - Installing SSM Agent directly into the volume<br>sudo mount /dev/sdf1 /mnt/broken-instance<br>./aws-install-ssm-broken-ssh-vm.sh<br>sudo umount /mnt/broken-instance<br># Reattach and connect via AWS Session Manager</pre><p><strong>You’re now using:</strong></p><ul><li>✅ AWS Systems Manager Session Manager (port 443 outbound only)</li><li>✅ No SSH daemon required at all</li><li>✅ No public IP needed</li><li>✅ No SSH keys to manage</li><li>✅ Works even if SSH is completely broken or disabled</li></ul><h3>Why This Is a Game-Changer</h3><h3>The Key Insight 🔑</h3><p><strong>Most tutorials teach you to fix SSH. This script teaches you to BYPASS SSH completely.</strong></p><p>When you run this script, you’re not repairing the SSH service — you’re installing an entirely different access mechanism that:</p><ol><li>Doesn’t require any network ports to be open (except HTTPS outbound)</li><li>Doesn’t depend on SSH daemon functionality</li><li>Doesn’t require managing authentication keys</li><li>Works even in private subnets with no internet gateway</li></ol><h3>Real-World Scenario</h3><p><strong>Situation:</strong> Your instance’s SSH daemon is completely misconfigured. Even if you add your public key to authorized_keys, you can&#39;t connect because:</p><ul><li>sshd_config has PermitRootLogin no</li><li>SSH service won’t start due to config errors</li><li>The firewall is blocking port 22 internally</li><li>You accidentally deleted the SSH binary</li></ul><p><strong>Traditional mount-and-fix approach:</strong> ❌ FAILS — You’re still dependent on SSH working</p><p><strong>This script’s approach:</strong> ✅ WORKS — SSM Agent creates a secure tunnel over HTTPS, completely independent of SSH</p><h3>What This Script Actually Does (The Clear Explanation)</h3><h3>The Big Picture</h3><pre>┌─────────────────────────────────────────────────────────────┐<br>│ Traditional Approach: Fix SSH                                │<br>├─────────────────────────────────────────────────────────────┤<br>│ Mount volume → Edit authorized_keys → Still need SSH to work│<br>└─────────────────────────────────────────────────────────────┘</pre><pre>┌─────────────────────────────────────────────────────────────┐<br>│ This Script&#39;s Approach: Install Alternative Access Method   │<br>├─────────────────────────────────────────────────────────────┤<br>│ Mount volume → Install SSM Agent → SSH becomes irrelevant   │<br>└─────────────────────────────────────────────────────────────┘</pre><h3>What Happens Step-by-Step</h3><ol><li><strong>Downloads SSM Agent package</strong> (not SSH keys!)</li><li><strong>Extracts the package manually</strong> without running installers</li><li><strong>Copies SSM Agent binaries</strong> directly into the mounted volume</li><li><strong>Configures systemd</strong> to auto-start SSM Agent on boot</li><li><strong>When instance restarts:</strong> SSM Agent connects to AWS, creating a secure tunnel</li></ol><p><strong>Result:</strong> You can now connect using:</p><pre>aws ssm start-session --target i-1234567890abcdef0</pre><p>No SSH involved. No keys. No port 22. Just a secure HTTPS tunnel managed by AWS.</p><h3>Breaking Down the Code: What Makes This Different</h3><h3>1. It’s Not Touching SSH at All</h3><pre>MOUNT=&quot;/mnt/broken-instance&quot;</pre><p>Notice: No references to .ssh/, authorized_keys, or sshd_config. This script doesn&#39;t care about SSH.</p><h3>2. Installing Alternative Access Software</h3><pre>PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb&quot;</pre><p>We’re downloading <strong>AWS Systems Manager Agent</strong> — a completely different remote access tool that:</p><ul><li>Uses AWS’s managed infrastructure</li><li>Communicates over HTTPS (port 443)</li><li>Authenticates via IAM roles (not SSH keys)</li><li>Provides shell access through AWS Session Manager</li></ul><h3>3. Detecting the Operating System</h3><pre>if [ -f &quot;$MOUNT/etc/debian_version&quot; ] || [ -f &quot;$MOUNT/etc/debian_release&quot; ]; then<br>  echo &quot;Detected: Debian/Ubuntu&quot;<br>  PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb&quot;<br>  PACKAGE_TYPE=&quot;deb&quot;<br>elif [ -f &quot;$MOUNT/etc/redhat-release&quot; ] || [ -f &quot;$MOUNT/etc/system-release&quot; ]; then<br>  echo &quot;Detected: Amazon Linux/RHEL/CentOS&quot;<br>  PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm&quot;<br>  PACKAGE_TYPE=&quot;rpm&quot;</pre><p><strong>Why this matters:</strong> Different Linux distributions use different package formats:</p><ul><li><strong>Debian/Ubuntu</strong> → .deb packages (APT)</li><li><strong>Amazon Linux/RHEL/CentOS</strong> → .rpm packages (YUM/DNF)</li></ul><p>The script intelligently checks multiple system files to identify the OS type, then downloads the appropriate package format.</p><h3>4. Manual Installation on a “Sleeping” OS</h3><pre>if [ &quot;$PACKAGE_TYPE&quot; = &quot;deb&quot; ]; then<br>  dpkg-deb -x ../amazon-ssm-agent.deb .<br>elif [ &quot;$PACKAGE_TYPE&quot; = &quot;rpm&quot; ]; then<br>  rpm2cpio ../amazon-ssm-agent.rpm | cpio -idmv<br>fi</pre><pre>sudo cp -r ./* &quot;$MOUNT&quot;/</pre><p><strong>This is the crucial part:</strong> We’re extracting the package contents manually and copying them into the mounted filesystem.</p><p>Think of it like installing software on a computer while it’s powered off:</p><ul><li>Normal installation: Run installer while OS is running</li><li>This approach: Manually place all files where they need to be</li></ul><p>For DEB packages, we use dpkg-deb -x to unpack without installation. For RPM packages, we convert to CPIO archive format and extract.</p><h3>5. Ensuring Auto-Start (The Secret Sauce)</h3><pre>if [ -f &quot;$MOUNT/lib/systemd/system/amazon-ssm-agent.service&quot; ]; then<br>  sudo mkdir -p &quot;$MOUNT/etc/systemd/system/multi-user.target.wants&quot;<br>  sudo cp &quot;$MOUNT/lib/systemd/system/amazon-ssm-agent.service&quot; &quot;$MOUNT/etc/systemd/system/&quot;<br>  sudo ln -sf ../amazon-ssm-agent.service &quot;$MOUNT/etc/systemd/system/multi-user.target.wants/&quot;<br>fi</pre><p>This configures the system to automatically start SSM Agent on boot — without this, the agent would be installed but inactive.</p><p><strong>Why this matters:</strong> When you reattach the volume and start the instance:</p><ol><li>OS boots normally</li><li>Systemd sees SSM Agent should start</li><li>SSM Agent connects to AWS Systems Manager</li><li>You can now connect via Session Manager — SSH never enters the picture</li></ol><p>The symbolic link in multi-user.target.wants tells systemd to start the service when the system reaches multi-user mode (the normal operational state).</p><h3>The Real-World Rescue Mission: Complete Walkthrough</h3><h3>Scenario: SSH is Completely Broken</h3><p>Your instance’s SSH configuration is corrupted, the SSH service won’t start, or port 22 is blocked. Traditional key-based recovery won’t help.</p><h3>Prerequisites</h3><p>Before you begin, ensure you have:</p><ul><li>AWS CLI configured with appropriate permissions</li><li>A “rescue” EC2 instance in the same availability zone as the broken instance</li><li>The broken instance must have (or you must attach) an IAM role with SSM permissions</li></ul><p><strong>Required IAM Policy for the Broken Instance:</strong></p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;ssm:UpdateInstanceInformation&quot;,<br>        &quot;ssmmessages:CreateControlChannel&quot;,<br>        &quot;ssmmessages:CreateDataChannel&quot;,<br>        &quot;ssmmessages:OpenControlChannel&quot;,<br>        &quot;ssmmessages:OpenDataChannel&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;*&quot;<br>    }<br>  ]<br>}</pre><h3>Step 1: Prepare the Rescue Mission</h3><pre># Stop the broken instance<br>aws ec2 stop-instances --instance-ids i-broken123</pre><pre># Wait for it to stop<br>aws ec2 wait instance-stopped --instance-ids i-broken123</pre><pre># Detach its root volume<br>aws ec2 detach-volume --volume-id vol-broken456</pre><pre># Attach to your rescue instance<br>aws ec2 attach-volume --volume-id vol-broken456 \<br>  --instance-id i-rescue789 --device /dev/sdf</pre><h3>Step 2: Mount and Install SSM Agent</h3><pre># SSH into the rescue instance<br>ssh -i your-key.pem ec2-user@rescue-instance-ip</pre><pre># Check what device the volume is attached as<br>lsblk</pre><pre># Create mount point<br>sudo mkdir -p /mnt/broken-instance</pre><pre># Mount the volume (adjust /dev/sdf1 based on your partition)<br>sudo mount /dev/sdf1 /mnt/broken-instance</pre><pre># Verify mount<br>ls -la /mnt/broken-instance</pre><pre># Download and run the script<br>wget <a href="https://your-script-location/aws-install-ssm-broken-ssh-vm.sh">https://your-script-location/aws-install-ssm-broken-ssh-vm.sh</a><br>chmod +x aws-install-ssm-broken-ssh-vm.sh<br>sudo ./aws-install-ssm-broken-ssh-vm.sh</pre><p><strong>What you’ll see:</strong></p><pre>Detecting OS on mounted volume...<br>Detected: Ubuntu<br>Downloading SSM Agent (deb)...<br>Extracting package...<br>Copying files to /mnt/broken-instance...<br>Setting up systemd service...<br>Installation complete!</pre><h3>Step 3: Clean Up and Reattach</h3><pre># Unmount the volume<br>sudo umount /mnt/broken-instance</pre><pre># Exit the rescue instance<br>exit</pre><pre># Detach from rescue instance<br>aws ec2 detach-volume --volume-id vol-broken456</pre><pre># Wait for detachment<br>aws ec2 wait volume-available --volume-ids vol-broken456</pre><pre># Reattach to original instance as root volume<br>aws ec2 attach-volume --volume-id vol-broken456 \<br>  --instance-id i-broken123 --device /dev/xvda</pre><pre># Start the instance<br>aws ec2 start-instances --instance-ids i-broken123</pre><h3>Step 4: Connect via SSM (Not SSH!)</h3><pre># Wait 1-2 minutes for SSM Agent to register with AWS<br># Check if the instance is online in Systems Manager<br>aws ssm describe-instance-information \<br>  --filters &quot;Key=InstanceIds,Values=i-broken123&quot;</pre><pre># Connect via Session Manager<br>aws ssm start-session --target i-broken123</pre><p><strong>You’re in!</strong> No SSH, no keys, no port 22. Just a secure AWS-managed session.</p><pre>Starting session with SessionId: john.doe-0a1b2c3d4e5f6g7h8<br>sh-4.2$ whoami<br>ssm-user<br>sh-4.2$ sudo su -<br>[root@ip-10-0-1-100 ~]#</pre><h3>The Complete Script Explained</h3><p>Here’s the full script with detailed annotations:</p><pre>#!/bin/bash<br>MOUNT=&quot;/mnt/broken-instance&quot;</pre><pre>echo &quot;Detecting OS on mounted volume...&quot;</pre><pre># Detect OS by checking distribution-specific files<br>if [ -f &quot;$MOUNT/etc/debian_version&quot; ] || [ -f &quot;$MOUNT/etc/debian_release&quot; ]; then<br>  echo &quot;Detected: Debian/Ubuntu&quot;<br>  PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb&quot;<br>  PACKAGE_TYPE=&quot;deb&quot;<br>elif [ -f &quot;$MOUNT/etc/redhat-release&quot; ] || [ -f &quot;$MOUNT/etc/system-release&quot; ]; then<br>  echo &quot;Detected: Amazon Linux/RHEL/CentOS&quot;<br>  PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm&quot;<br>  PACKAGE_TYPE=&quot;rpm&quot;<br>else<br>  # Fallback: Check os-release file<br>  echo &quot;Cannot detect OS. Checking os-release...&quot;<br>  if sudo grep -qi &quot;ubuntu\|debian&quot; &quot;$MOUNT/etc/os-release&quot; 2&gt;/dev/null; then<br>    echo &quot;Detected via os-release: Debian/Ubuntu&quot;<br>    PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb&quot;<br>    PACKAGE_TYPE=&quot;deb&quot;<br>  elif sudo grep -qi &quot;amazon\|centos\|rhel\|red hat&quot; &quot;$MOUNT/etc/os-release&quot; 2&gt;/dev/null; then<br>    echo &quot;Detected via os-release: Amazon Linux/RHEL/CentOS&quot;<br>    PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm&quot;<br>    PACKAGE_TYPE=&quot;rpm&quot;<br>  else<br>    echo &quot;ERROR: Cannot determine OS type. Defaulting to RPM.&quot;<br>    PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm&quot;<br>    PACKAGE_TYPE=&quot;rpm&quot;<br>  fi<br>fi</pre><pre># Download SSM Agent package from AWS<br>echo &quot;Downloading SSM Agent ($PACKAGE_TYPE)...&quot;<br>cd /tmp<br>wget -q &quot;$PACKAGE_URL&quot;</pre><pre># Extract package contents without installing<br>echo &quot;Extracting package...&quot;<br>mkdir -p ssm-extract<br>cd ssm-extract</pre><pre>if [ &quot;$PACKAGE_TYPE&quot; = &quot;deb&quot; ]; then<br>  # Extract DEB package<br>  dpkg-deb -x ../amazon-ssm-agent.deb .<br>elif [ &quot;$PACKAGE_TYPE&quot; = &quot;rpm&quot; ]; then<br>  # Convert RPM to CPIO and extract<br>  rpm2cpio ../amazon-ssm-agent.rpm | cpio -idmv<br>fi</pre><pre># Copy extracted files to the mounted volume<br>echo &quot;Copying files to $MOUNT...&quot;<br>sudo cp -r ./* &quot;$MOUNT&quot;/</pre><pre># Configure systemd to auto-start SSM Agent<br>echo &quot;Setting up systemd service...&quot;<br>if [ -f &quot;$MOUNT/lib/systemd/system/amazon-ssm-agent.service&quot; ]; then<br>  sudo mkdir -p &quot;$MOUNT/etc/systemd/system/multi-user.target.wants&quot;<br>  sudo cp &quot;$MOUNT/lib/systemd/system/amazon-ssm-agent.service&quot; &quot;$MOUNT/etc/systemd/system/&quot;<br>  sudo ln -sf ../amazon-ssm-agent.service &quot;$MOUNT/etc/systemd/system/multi-user.target.wants/&quot;<br>fi</pre><pre>echo &quot;Installation complete!&quot;<br>sudo ls -la &quot;$MOUNT/opt/amazon/ssm/&quot; 2&gt;/dev/null || echo &quot;Check $MOUNT/opt/amazon/ssm/&quot;</pre><h3>Side-by-Side Comparison: The Methods Explained</h3><pre>┌────────────────────────────┬────────────────────────────┬────────────────────────────┐<br>│                            │                            │                            │<br>│         ASPECT             │   TRADITIONAL &quot;FIX SSH&quot;    │    THIS SCRIPT &quot;INSTALL    │<br>│                            │                            │           SSM&quot;             │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ What you&#39;re fixing         │ Adding your public key to  │ Installing alternative     │<br>│                            │ authorized_keys            │ access software            │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Access method              │ SSH (port 22)              │ AWS Session Manager        │<br>│                            │                            │ (HTTPS/443)                │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Depends on SSH working?    │ ✅ YES                     │ ❌ NO                       │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Requires public IP?        │ Usually yes                │ No                         │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Works if SSH daemon broken?│ ❌ NO                      │ ✅ YES                      │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Authentication             │ SSH keys                   │ IAM roles                  │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Network requirements       │ Inbound port 22            │ Outbound port 443          │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Works in private subnets?  │ Needs bastion              │ ✅ YES (with VPC endpoints) │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Audit trail                │ Depends on logging config  │ Built into CloudTrail      │<br>├────────────────────────────┼────────────────────────────┼────────────────────────────┤<br>│ Session recording          │ Manual setup required      │ Available via Session      │<br>│                            │                            │ Manager                    │<br>└────────────────────────────┴────────────────────────────┴────────────────────────────┘</pre><h3>Why Most Guides Don’t Teach This</h3><p>Most “recover broken EC2 instance” tutorials focus on the traditional approach:</p><ol><li>Mount the volume</li><li>Add your SSH key to authorized_keys</li><li>Fix sshd_config if needed</li><li>Hope SSH works</li></ol><p><strong>They assume SSH is the only way to access an instance.</strong></p><p>This script represents <strong>cloud-native thinking</strong>: Why fix an old access method when you can install a modern, AWS-integrated alternative?</p><h3>Common Questions Answered</h3><h3>Q: “Why not just fix SSH?”</h3><p><strong>A:</strong> Because SSH might be unfixable without the OS running, or you might not want SSH at all. SSM Agent:</p><ul><li>Works even if SSH binary is deleted</li><li>Doesn’t require open ports</li><li>Provides better audit logging</li><li>Is the AWS-recommended access method</li><li>Enables session recording and compliance features</li></ul><h3>Q: “Will this work if the instance doesn’t have an IAM role?”</h3><p><strong>A:</strong> No, the instance MUST have an IAM role with SSM permissions. If it doesn’t, you’ll need to attach one:</p><pre># Create IAM role (if you don&#39;t have one)<br>aws iam create-role --role-name SSM-Instance-Role \<br>  --assume-role-policy-document file://trust-policy.json</pre><pre># Attach AWS managed policy for SSM<br>aws iam attach-role-policy --role-name SSM-Instance-Role \<br>  --policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore</pre><pre># Create instance profile<br>aws iam create-instance-profile --instance-profile-name SSM-Instance-Profile</pre><pre># Add role to instance profile<br>aws iam add-role-to-instance-profile \<br>  --instance-profile-name SSM-Instance-Profile \<br>  --role-name SSM-Instance-Role</pre><pre># Attach to your instance<br>aws ec2 associate-iam-instance-profile \<br>  --instance-id i-broken123 \<br>  --iam-instance-profile Name=SSM-Instance-Profile</pre><p><strong>trust-policy.json:</strong></p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><h3>Q: “Does this disable SSH?”</h3><p><strong>A:</strong> No! SSH continues to work (or not work) exactly as before. You’re just adding an <strong>alternative</strong> access method. Think of it as installing a second door on your house — the first door still exists.</p><h3>Q: “What if I want BOTH methods?”</h3><p><strong>A:</strong> Perfect! Run this script to install SSM, AND fix your SSH config. Now you have two ways in:</p><pre># Option 1: SSH (if it works)<br>ssh ec2-user@instance-ip</pre><pre># Option 2: SSM (always works)<br>aws ssm start-session --target i-instance123</pre><h3>Q: “What about instances in private subnets with no internet?”</h3><p><strong>A:</strong> SSM Agent needs to communicate with AWS Systems Manager endpoints. For private subnets, you have two options:</p><ol><li><strong>VPC Endpoints (Recommended):</strong> Create VPC endpoints for:</li></ol><ul><li>com.amazonaws.region.ssm</li><li>com.amazonaws.region.ssmmessages</li><li>com.amazonaws.region.ec2messages</li></ul><ol><li><strong>NAT Gateway:</strong> Allow outbound HTTPS (443) traffic to AWS Systems Manager</li></ol><h3>Q: “Can I use this on ARM instances (Graviton)?”</h3><p><strong>A:</strong> Yes! You need to modify the script to download ARM packages:</p><pre># For Debian/Ubuntu ARM<br>PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_arm64/amazon-ssm-agent.deb&quot;</pre><pre># For Amazon Linux/RHEL ARM<br>PACKAGE_URL=&quot;https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_arm64/amazon-ssm-agent.rpm&quot;</pre><h3>Troubleshooting Common Issues</h3><h3>Issue 1: “Instance not showing up in Systems Manager”</h3><p><strong>Check:</strong></p><pre># Verify IAM role is attached<br>aws ec2 describe-instances --instance-ids i-broken123 \<br>  --query &#39;Reservations[0].Instances[0].IamInstanceProfile&#39;</pre><pre># Check SSM Agent status (if you can access the instance)<br>sudo systemctl status amazon-ssm-agent</pre><p><strong>Solutions:</strong></p><ul><li>Ensure IAM role has AmazonSSMManagedInstanceCore policy</li><li>Verify outbound HTTPS (443) connectivity</li><li>Check if SSM Agent service is running</li><li>Wait 2–5 minutes for agent registration</li></ul><h3>Issue 2: “Wrong partition mounted”</h3><p><strong>Symptoms:</strong> Files don’t look right, or you see an empty filesystem</p><p><strong>Solution:</strong></p><pre># List all partitions<br>sudo fdisk -l /dev/sdf</pre><pre># You might need /dev/sdf1, /dev/sdf2, etc.<br># Look for the partition marked as &quot;Linux&quot; with the largest size<br>sudo mount /dev/sdf1 /mnt/broken-instance</pre><h3>Issue 3: “systemd service not starting”</h3><p><strong>Check the service file:</strong></p><pre># After mounting<br>cat $MOUNT/etc/systemd/system/amazon-ssm-agent.service</pre><pre># Verify symbolic link<br>ls -la $MOUNT/etc/systemd/system/multi-user.target.wants/amazon-ssm-agent.service</pre><h3>The Bigger Picture: Modern Cloud Access Patterns</h3><p>This script teaches an important lesson: <strong>In the cloud, you have options beyond traditional SSH.</strong></p><h3>The Evolution of Instance Access</h3><pre>2006 (EC2 Launch):     SSH with key pairs<br>                       ↓<br>2010s:                 SSH + Bastion hosts<br>                       ↓<br>2017:                  SSH + Systems Manager Agent<br>                       ↓<br>2024:                  SSM Session Manager as primary<br>                       (SSH optional)</pre><p><strong>Modern best practice:</strong> Install SSM Agent in your base AMIs. Make SSH the backup plan, not the primary access method.</p><h3>Benefits of SSM-First Strategy</h3><ol><li><strong>Security:</strong></li></ol><ul><li>No exposed SSH ports</li><li>IAM-based authentication</li><li>MFA support</li><li>Session recording for compliance</li></ul><p>2. <strong>Operational:</strong></p><ul><li>Works in private subnets</li><li>No bastion hosts to maintain</li><li>Centralized access logging</li><li>Port forwarding capabilities</li></ul><p>3. <strong>Cost:</strong></p><ul><li>No NAT Gateway needed for access (with VPC endpoints)</li><li>No bastion instance costs</li><li>Reduced attack surface = fewer security incidents</li></ul><h3>Real-World Use Cases</h3><h3>Case 1: The Midnight SSH Lockout</h3><p><strong>Scenario:</strong> Junior engineer accidentally runs sudo chmod 600 /etc/ssh instead of /etc/ssh/sshd_config, breaking SSH for everyone.</p><p><strong>Traditional approach:</strong> Emergency change window, infrastructure rebuild, potential data loss.</p><p><strong>With this script:</strong> 15-minute fix. Mount, install SSM, access restored. Fix SSH at leisure.</p><h3>Case 2: The Security Group Mistake</h3><p><strong>Scenario:</strong> Security team removes port 22 from all production security groups during a security audit.</p><p><strong>Traditional approach:</strong> Emergency security group changes, explaining to security why you need port 22.</p><p><strong>With this script:</strong> Install SSM, never open port 22 again. Security team is happy.</p><h3>Case 3: The Private Subnet Instance</h3><p><strong>Scenario:</strong> Instance in private subnet needs maintenance, but bastion host is down.</p><p><strong>Traditional approach:</strong> Fix bastion first, or create temporary jump box.</p><p><strong>With this script:</strong> Access via SSM Session Manager through VPC endpoints. No public internet required.</p><h3>Advanced Tips and Tricks</h3><h3>Tip 1: Automate with User Data</h3><p>Include SSM Agent installation in your launch templates:</p><pre>#!/bin/bash<br># Ubuntu/Debian<br>apt-get update -y<br>apt-get install -y amazon-ssm-agent<br>systemctl enable amazon-ssm-agent<br>systemctl start amazon-ssm-agent</pre><pre># Amazon Linux/RHEL<br>yum install -y amazon-ssm-agent<br>systemctl enable amazon-ssm-agent<br>systemctl start amazon-ssm-agent</pre><h3>Tip 2: Port Forwarding via SSM</h3><p>Once SSM is installed, you can forward ports without SSH:</p><pre># Forward RDS port through SSM<br>aws ssm start-session --target i-instance123 \<br>  --document-name AWS-StartPortForwardingSession \<br>  --parameters &#39;{&quot;portNumber&quot;:[&quot;3306&quot;],&quot;localPortNumber&quot;:[&quot;3306&quot;]}&#39;</pre><h3>Tip 3: Batch Script Execution</h3><p>Run commands on multiple instances via Systems Manager:</p><pre>aws ssm send-command \<br>  --document-name &quot;AWS-RunShellScript&quot; \<br>  --targets &quot;Key=tag:Environment,Values=production&quot; \<br>  --parameters &#39;commands=[&quot;df -h&quot;,&quot;uptime&quot;]&#39;</pre><h3>Tip 4: Session Recording for Compliance</h3><p>Enable session logging to S3:</p><pre>aws ssm create-document --name &quot;SessionManagerLogging&quot; --document-type &quot;Session&quot; --content &#39;{<br>  &quot;schemaVersion&quot;: &quot;1.0&quot;,<br>  &quot;description&quot;: &quot;Document to hold regional settings for Session Manager&quot;,<br>  &quot;sessionType&quot;: &quot;Standard_Stream&quot;,<br>  &quot;inputs&quot;: {<br>    &quot;s3BucketName&quot;: &quot;your-session-logs-bucket&quot;,<br>    &quot;s3KeyPrefix&quot;: &quot;session-logs/&quot;,<br>    &quot;s3EncryptionEnabled&quot;: true,<br>    &quot;cloudWatchLogGroupName&quot;: &quot;/aws/ssm/session-logs&quot;,<br>    &quot;cloudWatchEncryptionEnabled&quot;: true<br>  }<br>}&#39;</pre><h3>Try It Yourself: Hands-On Lab</h3><h3>Safe Test Environment Setup</h3><p><strong>Step 1: Launch test instance</strong></p><pre>aws ec2 run-instances \<br>  --image-id ami-0c55b159cbfafe1f0 \<br>  --instance-type t3.micro \<br>  --iam-instance-profile Name=SSM-Instance-Profile \<br>  --tag-specifications &#39;ResourceType=instance,Tags=[{Key=Name,Value=SSM-Test}]&#39;</pre><p><strong>Step 2: Deliberately break SSH</strong></p><pre># SSH into the instance first<br>ssh -i your-key.pem ec2-user@instance-ip</pre><pre># Break SSH intentionally<br>sudo chmod 000 /etc/ssh/sshd_config<br>sudo systemctl stop sshd<br>sudo systemctl disable sshd</pre><pre># Verify you&#39;re locked out<br>exit<br>ssh -i your-key.pem ec2-user@instance-ip  # This should fail</pre><p><strong>Step 3: Run the recovery</strong> Follow the complete walkthrough steps above to mount the volume and install SSM.</p><p><strong>Step 4: Verify success</strong></p><pre>aws ssm start-session --target i-your-test-instance</pre><p><strong>Step 5: Clean up</strong></p><pre>aws ec2 terminate-instances --instance-ids i-your-test-instance</pre><p>This hands-on exercise proves the script’s value: You’re accessing an instance <strong>where SSH is completely broken</strong>.</p><h3>Security Considerations</h3><h3>IAM Permissions Best Practices</h3><p><strong>Minimum required permissions for users to connect via SSM:</strong></p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;ssm:StartSession&quot;<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:ec2:*:*:instance/*&quot;<br>      ],<br>      &quot;Condition&quot;: {<br>        &quot;StringLike&quot;: {<br>          &quot;ssm:resourceTag/Environment&quot;: [&quot;production&quot;]<br>        }<br>      }<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;ssm:TerminateSession&quot;,<br>        &quot;ssm:ResumeSession&quot;<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:ssm:*:*:session/${aws:username}-*&quot;<br>      ]<br>    }<br>  ]<br>}</pre><h3>Network Security</h3><p><strong>Required outbound rules for SSM (if using security groups):</strong></p><pre>Protocol: HTTPS<br>Port: 443<br>Destination: 0.0.0.0/0 (or specific AWS service endpoints)</pre><p><strong>For VPC Endpoints (no internet required):</strong></p><ul><li>com.amazonaws.region.ssm</li><li>com.amazonaws.region.ssmmessages</li><li>com.amazonaws.region.ec2messages</li></ul><h3>Cost Considerations</h3><h3>SSM vs SSH + Bastion</h3><p><strong>Traditional Bastion Setup:</strong></p><ul><li>Bastion instance: ~$15–30/month (t3.small)</li><li>NAT Gateway: ~$32/month + data transfer</li><li>Elastic IP: ~$3.60/month</li><li><strong>Total: ~$50–65/month</strong></li></ul><p><strong>SSM with VPC Endpoints:</strong></p><ul><li>VPC Endpoint: ~$7.20/month per AZ</li><li>No NAT Gateway needed for SSM access</li><li>No bastion instance</li><li><strong>Total: ~$7–15/month</strong> (depending on AZs)</li></ul><p><strong>Savings: 70–80% reduction in infrastructure costs</strong></p><h3>When to Use This Technique</h3><h3>✅ Perfect For:</h3><ul><li>SSH service is broken or misconfigured</li><li>Firewall rules locked you out</li><li>Emergency access to private instances</li><li>Forensics on a compromised instance</li><li>Compliance requirements for session recording</li><li>Instances that should never have SSH exposed</li></ul><h3>⚠️ Consider Alternatives For:</h3><ul><li>Kernel panics or boot failures (may need console access)</li><li>Completely corrupted filesystems (may need data recovery)</li><li>Instances without any IAM role (must add role first)</li><li>Windows instances (different SSM installation process)</li></ul><h3>❌ Won’t Work For:</h3><ul><li>Stopped instances with instance store root volumes (data is lost)</li><li>Instances in different regions (volume attachment restriction)</li><li>Severely corrupted systemd or init systems</li></ul><h3>Key Takeaway</h3><p><strong>This script doesn’t fix SSH — it makes SSH irrelevant.</strong></p><p>That’s not a bug; it’s a feature. In modern cloud architecture, having multiple access paths is security through diversity. When SSH fails, SSM saves the day.</p><p><strong>What’s your recovery strategy?</strong> Share your war stories in the comments. Have you ever been permanently locked out of an instance because you only relied on SSH?</p><p><em>Follow me for more AWS techniques that go beyond the official documentation. Sometimes the best solutions are the ones nobody talks about.</em></p><p><strong>GitHub: [</strong><a href="https://github.com/ryoguritno"><strong>@ryoguritno</strong></a><strong>]</strong><br> <strong>Connect:</strong> [<a href="https://www.linkedin.com/in/ryo-guritno-ba02a3165/">LinkedIn</a>]</p><p>Is this clearer now? The distinction between “fixing SSH” vs “installing alternative access method” is front and center! 🎯</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e00f41bb0fe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a “Snitch Bot” That Catches Engineers Clicking in AWS Console (And It’s Gloriously Petty)]]></title>
            <link>https://medium.com/@kryukz/i-built-a-snitch-bot-that-catches-engineers-clicking-in-aws-console-and-its-gloriously-petty-dbaa8145b981?source=rss-945136394d8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbaa8145b981</guid>
            <dc:creator><![CDATA[Ryo Guritno]]></dc:creator>
            <pubDate>Thu, 11 Dec 2025 14:35:39 GMT</pubDate>
            <atom:updated>2025-12-11T14:38:16.199Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fo3Y2NeBjfl5MLk1" /><figcaption>Photo by <a href="https://unsplash.com/@bweaver?utm_source=medium&amp;utm_medium=referral">Brad Weaver</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>How I Stopped Worrying and Learned to Love Infrastructure as Code</h3><p><strong>TL;DR:</strong> I built an open-source tool that sends Slack notifications every time someone clicks around in the AWS Console instead of writing proper Infrastructure as Code. It monitors 12+ AWS accounts, costs $0/month, and has already prevented three production incidents. Here’s how you can deploy it in 30 minutes.</p><h3>The Problem: ClickOps is Killing Your Infrastructure</h3><p>Picture this: It’s 3 AM. Your production is down. You’re debugging with your team on Zoom, screens shared, adrenaline pumping.</p><p><em>“Wait… who changed the security group?”</em></p><p><em>“I don’t know, the Terraform state doesn’t show it…”</em></p><p><em>“Check CloudTrail.”</em></p><p><em>[10 minutes of scrolling through JSON logs]</em></p><p><em>“Oh. Sarah from DevOps added a rule manually last week.”</em></p><p>Sound familiar?</p><p>This is <strong>ClickOps</strong> — the silent killer of infrastructure automation. It happens when engineers bypass your carefully crafted CI/CD pipelines and Terraform modules to “just quickly fix something” in the AWS Console.</p><p>And it happens more often than you think.</p><h3>Why ClickOps Happens (And Why Engineers Do It Anyway)</h3><p>Before I built this tool, I surveyed my team. Here’s what they said:</p><ul><li><strong>“Terraform is too slow for debugging”</strong> (37%)</li><li><strong>“I was just checking something”</strong> (28%)</li><li><strong>“The pipeline was broken”</strong> (18%)</li><li><strong>“I didn’t think it mattered”</strong> (17%)</li></ul><p>The brutal truth? <strong>ClickOps is easier</strong>.</p><p>Point. Click. Done.</p><p>No pull requests, no code reviews, no waiting for CI/CD. Just instant gratification.</p><p>But here’s what they don’t see:</p><pre>Manual Change (Console)<br>    ↓<br>Infrastructure Drift<br>    ↓<br>Terraform State Out of Sync<br>    ↓<br>Next Deploy Fails<br>    ↓<br>[3 AM Page to SRE Team]<br>    ↓<br>&quot;Who changed this?!&quot;</pre><h3>The Solution: Real-Time ClickOps Detection</h3><p>I needed something that would:</p><ol><li><strong>Catch manual changes immediately</strong> (not days later during deployment)</li><li><strong>Work across multiple AWS accounts</strong> (we have 12+)</li><li><strong>Cost nothing</strong> (I’m an engineer, not made of budget)</li><li><strong>Be zero-maintenance</strong> (I have actual work to do)</li><li><strong>Shame people publicly</strong> (kidding… mostly 😅)</li></ol><p>Enter: <strong>ClickOps Notifier</strong></p><h3>How It Works (The 30-Second Version)</h3><pre>AWS Console Action<br>    ↓<br>CloudTrail catches it<br>    ↓<br>EventBridge triggers Lambda<br>    ↓<br>Lambda sends Slack notification<br>    ↓<br>Entire team sees: &quot;🚨 John just created an EC2 instance manually&quot;</pre><h3>The Architecture (The Pretty Diagram)</h3><pre>┌─────────────────────────────────────────┐<br>│         AWS Account (Isolated)          │<br>│                                         │<br>│  CloudTrail ──┐                         │<br>│               ↓                         │<br>│         EventBridge Rule                │<br>│         (Filters Console Actions)       │<br>│               ↓                         │<br>│         Lambda Function                 │<br>│         (Formats Alert)                 │<br>│               ↓                         │<br>└───────────────┼─────────────────────────┘<br>                ↓<br>         Slack Webhook<br>                ↓<br>    #aws-console-alerts Channel<br>    <br>    [🚨 Alert Example]<br>    ClickOps Detected!<br>    User: john.doe<br>    Action: RunInstances<br>    Account: Production<br>    Region: us-east-1</pre><p><strong>Key Design Principle:</strong> Everything runs <strong>inside each AWS account</strong>. No cross-account IAM roles, no VPC peering, no central monitoring account. Completely isolated.</p><h3>Building It: The Technical Journey</h3><h3>Attempt #1: CloudWatch Logs Insights (Failed)</h3><p>My first idea: Query CloudTrail logs with CloudWatch Logs Insights.</p><pre>fields @timestamp, userIdentity.userName, eventName<br>| filter userAgent like /console.amazonaws.com/<br>| sort @timestamp desc</pre><p><strong>Problem:</strong> This requires manual queries. I needed <strong>real-time alerts</strong>.</p><p><strong>Lesson learned:</strong> Reactive monitoring ≠ proactive alerting.</p><h3>Attempt #2: Lambda + CloudWatch Events (Almost There)</h3><p>Second attempt: Lambda function triggered by CloudWatch Events (now EventBridge).</p><p><strong>Problems I hit:</strong></p><ol><li><strong>EventBridge pattern was wrong</strong> — caught API calls, not console actions</li><li><strong>Too many false positives</strong> — every DescribeBucket triggered an alert</li><li><strong>No filtering logic</strong> — service-linked roles spammed Slack</li></ol><p><strong>Code snippet that finally worked:</strong></p><pre># The magic event pattern<br>event_pattern = {<br>    &quot;source&quot;: [&quot;aws.ec2&quot;, &quot;aws.s3&quot;, &quot;aws.rds&quot;, ...],<br>    &quot;detail-type&quot;: [&quot;AWS API Call via CloudTrail&quot;],<br>    &quot;detail&quot;: {<br>        &quot;userAgent&quot;: [<br>            {&quot;prefix&quot;: &quot;console.amazonaws.com&quot;},<br>            {&quot;prefix&quot;: &quot;Mozilla&quot;}  # Some console actions use browser UA<br>        ],<br>        &quot;eventCategory&quot;: [&quot;Management&quot;]  # Ignore data events<br>    }<br>}</pre><p><strong>Lesson learned:</strong> EventBridge patterns are powerful but finicky. Test with real CloudTrail events, not documentation examples.</p><h3>Attempt #3: Smart Filtering (Success!)</h3><p>The breakthrough came when I realized: <strong>Not all console actions matter</strong>.</p><p>I added filtering logic:</p><pre>def should_notify(details):<br>    event_name = details[&quot;event_name&quot;]<br>    <br>    # Skip read-only operations<br>    readonly_prefixes = [&quot;Get&quot;, &quot;List&quot;, &quot;Describe&quot;, &quot;Head&quot;]<br>    if any(event_name.startswith(prefix) for prefix in readonly_prefixes):<br>        return False<br>    <br>    # Skip automated actions<br>    excluded_events = [&quot;SwitchRole&quot;, &quot;AssumeRole&quot;, &quot;ConsoleLogin&quot;]<br>    if event_name in excluded_events:<br>        return False<br>    <br>    # Skip service-linked roles (automated AWS actions)<br>    if &quot;servicelinkedrole&quot; in details[&quot;user&quot;].lower():<br>        return False<br>    <br>    return True  # Alert on everything else</pre><p><strong>Result:</strong> Alert fatigue dropped by 90%. Only actionable notifications got through.</p><h3>The Deployment Story: Multi-Account at Scale</h3><p>Here’s where it got interesting. Our infrastructure:</p><ul><li><strong>2 AWS Organizations</strong> (prod + dev)</li><li><strong>10 standalone accounts</strong> (legacy, acquisitions, etc.)</li><li><strong>Different AWS CLI profiles</strong> for each</li></ul><p>Deploying manually? 12 accounts × 3 AWS services (CloudTrail, Lambda, EventBridge) = <strong>36 manual steps</strong>.</p><p>Nope.</p><p>I automated everything:</p><pre># deploy.py - The magic script<br>python deploy.py --deploy-all</pre><pre># Output:<br># [STEP] Starting deployment to 12 accounts...<br># [INFO] Progress: 1/12<br># [STEP] Deploying to: Production Org (111111111111)<br># [INFO] Step 1/3: Checking CloudTrail...<br># [INFO] Step 2/3: Deploying Lambda function...<br># [INFO] Step 3/3: Setting up EventBridge rule...<br># ✅ Successfully deployed to Production Org<br># <br># [INFO] Progress: 2/12<br># ...<br># <br># 🎉 All deployments successful!</pre><p><strong>Deployment time:</strong> 45 minutes (mostly waiting for IAM propagation).</p><p><strong>Maintenance time:</strong> 0 minutes/month.</p><p><strong>My time saved:</strong> Countless hours not debugging “who changed this?”</p><h3>Real-World Impact: The Stories</h3><h3>Story #1: The Saturday Morning Save</h3><p><strong>Saturday, 11:23 AM.</strong> I’m having coffee when Slack pings:</p><pre>🚨 ClickOps Detected in AWS Console</pre><pre>Account: Production<br>User: intern-mike<br>Action: ModifyDBInstance<br>Service: rds<br>Region: us-east-1</pre><p>I call Mike. Turns out he was “testing” a database parameter change… <strong>on production</strong>.</p><p><strong>Outcome:</strong> Caught it before any traffic hit. Reverted immediately. Taught Mike about staging environments.</p><p><strong>Cost of NOT having this tool:</strong> Potential production outage, angry customers, incident report.</p><h3>Story #2: The Security Group Incident</h3><p><strong>Tuesday, 2:47 PM.</strong> Alert comes in:</p><pre>🚨 HIGH RISK ACTION DETECTED</pre><pre>Account: Production<br>User: alice<br>Action: AuthorizeSecurityGroupIngress<br>Service: ec2<br>Region: us-east-1<br>Source IP: 203.0.113.42</pre><p>Alice opened port 22 to 0.0.0.0/0 (the entire internet) while debugging an SSH issue.</p><p><strong>Outcome:</strong> I pinged her in Slack. She realized the mistake and immediately restricted it to her IP.</p><p><strong>Without this tool:</strong> That SSH port would’ve stayed open. Potential security breach.</p><h3>Story #3: The CloudFormation Mystery</h3><p><strong>Thursday, 4:15 PM.</strong> Our deployment pipeline failed with:</p><pre>Error: Resource already exists: my-bucket</pre><p>But our Terraform said it should create the bucket. WTF?</p><p>Checked ClickOps Notifier logs:</p><pre>Account: Production<br>User: bob<br>Action: CreateBucket<br>Service: s3<br>Timestamp: 2 hours ago</pre><p><strong>Outcome:</strong> Bob had manually created the bucket “to test something” and forgot to delete it.</p><p><strong>Without this tool:</strong> 30 minutes of debugging CloudFormation errors instead of 30 seconds checking Slack history.</p><h3>The Slack Notification Design: Small Details Matter</h3><p>I iterated on the notification format <strong>six times</strong> before landing on this:</p><pre>🚨 ClickOps Detected in AWS Console</pre><pre>Account: Production Org<br>Account ID: 123456789012<br>User: john.doe<br>User Type: IAMUser<br>Action: RunInstances<br>Service: ec2<br>Region: us-east-1<br>Source IP: 203.0.113.42</pre><pre>🕐 2025-12-11 10:30:00 UTC</pre><p><strong>Why this format?</strong></p><ul><li><strong>Emoji first</strong> — Catches attention in busy Slack channels</li><li><strong>Account name + ID</strong> — Clear context (we have 12 accounts)</li><li><strong>User info</strong> — Accountability (but not shaming)</li><li><strong>Action + Service</strong> — What happened, where</li><li><strong>Source IP</strong> — Security context</li><li><strong>Timestamp</strong> — Chronological debugging</li></ul><p><strong>High-risk actions</strong> get special treatment:</p><pre>🚨 ClickOps Detected in AWS Console</pre><pre>⚠️ HIGH RISK ACTION DETECTED</pre><pre>Account: Production<br>Action: DeleteDBInstance<br>...</pre><p>Bright red background in Slack. Impossible to miss.</p><h3>The Cost Analysis: $0/Month (Seriously)</h3><p>Let’s break down the AWS costs:</p><p>Service Usage Cost/Month CloudTrail (Management Events) Included <strong>$0</strong> EventBridge (1K events) Free tier <strong>$0</strong> Lambda (1K invocations) Free tier <strong>$0</strong> CloudWatch Logs (50MB) Free tier <strong>$0</strong> <strong>Total per account</strong> <strong>$0</strong> <strong>Total for 12 accounts</strong> <strong>$0</strong></p><p><strong>Why is this free?</strong></p><ol><li><strong>CloudTrail management events</strong> are free (we don’t monitor S3 data events)</li><li><strong>EventBridge</strong> free tier = 1M events/month (we use ~1K)</li><li><strong>Lambda</strong> free tier = 1M requests/month (we use ~1K)</li><li><strong>CloudWatch Logs</strong> free tier = 5GB/month (we use ~50MB)</li></ol><p><strong>Caveat:</strong> This assumes normal usage. If you have 1000+ engineers clicking constantly, you might hit $5–10/month.</p><p>Still cheaper than a single production incident.</p><h3>Lessons Learned: What I’d Do Differently</h3><h3>1. Should’ve Added Tests From Day One</h3><p>I deployed without tests. Bad idea. Later, I changed the filtering logic and broke production notifications.</p><p><strong>What I added:</strong></p><pre># test_lambda_function.py<br>def test_filter_readonly_operations():<br>    details = {&#39;event_name&#39;: &#39;ListBuckets&#39;, &#39;user&#39;: &#39;bob&#39;}<br>    assert should_notify(details) == False<br>    <br>def test_detect_dangerous_actions():<br>    details = {&#39;event_name&#39;: &#39;DeleteBucket&#39;, &#39;user&#39;: &#39;bob&#39;}<br>    assert should_notify(details) == True</pre><p><strong>Lesson:</strong> Even simple Lambda functions need tests.</p><h3>2. Webhook Security Was an Afterthought</h3><p>Initially, I stored Slack webhook URLs in config.json (plaintext).</p><p><strong>Security team:</strong> “Are you serious?”</p><p><strong>Me:</strong> “…oops.”</p><p><strong>Fix:</strong> Move to AWS Secrets Manager:</p><pre>import boto3</pre><pre>def get_webhook_url():<br>    client = boto3.client(&#39;secretsmanager&#39;)<br>    response = client.get_secret_value(SecretId=&#39;clickops/slack-webhook&#39;)<br>    return response[&#39;SecretString&#39;]</pre><p><strong>Lesson:</strong> Credentials should never be in config files, even “internal” ones.</p><h3>3. No Monitoring of the Monitor</h3><p>What if the monitoring system breaks? How would I know?</p><p><strong>Solution:</strong> CloudWatch alarms</p><pre># Alert if Lambda has errors<br>cloudwatch.put_metric_alarm(<br>    AlarmName=&#39;clickops-notifier-errors&#39;,<br>    MetricName=&#39;Errors&#39;,<br>    Namespace=&#39;AWS/Lambda&#39;,<br>    Threshold=5,<br>    ComparisonOperator=&#39;GreaterThanThreshold&#39;<br>)</pre><pre># Alert if zero invocations for 24 hours (suspicious!)<br>cloudwatch.put_metric_alarm(<br>    AlarmName=&#39;clickops-notifier-silent&#39;,<br>    MetricName=&#39;Invocations&#39;,<br>    Period=86400,  # 24 hours<br>    Threshold=1,<br>    ComparisonOperator=&#39;LessThanThreshold&#39;<br>)</pre><p><strong>Lesson:</strong> Monitor your monitoring tools.</p><h3>How to Deploy It Yourself (30-Minute Guide)</h3><h3>Prerequisites</h3><pre># Install boto3<br>pip install boto3</pre><pre># Configure AWS profiles<br>aws configure --profile prod-account<br>aws configure --profile dev-account<br># ... repeat for all accounts</pre><h3>Step 1: Get Slack Webhook</h3><ol><li>Go to <a href="https://api.slack.com/apps">https://api.slack.com/apps</a></li><li>Create new app → “From scratch”</li><li>“Incoming Webhooks” → Enable</li><li>Add to workspace → Select channel (#aws-alerts)</li><li>Copy webhook URL</li></ol><h3>Step 2: Clone &amp; Configure</h3><pre>git clone https://github.com/yourusername/clickops-notifier<br>cd clickops-notifier</pre><pre># Copy config template<br>cp config.template.json config.json</pre><pre># Edit config.json<br>vim config.json</pre><p><strong>Edit this:</strong></p><pre>{<br>  &quot;notification&quot;: {<br>    &quot;slack_webhook_url&quot;: &quot;https://hooks.slack.com/YOUR/WEBHOOK&quot;<br>  },<br>  &quot;organizations&quot;: [<br>    {<br>      &quot;name&quot;: &quot;Production&quot;,<br>      &quot;management_account_id&quot;: &quot;123456789012&quot;,<br>      &quot;aws_profile&quot;: &quot;prod-account&quot;,<br>      &quot;region&quot;: &quot;us-east-1&quot;<br>    }<br>  ],<br>  &quot;standalone_accounts&quot;: [<br>    {<br>      &quot;name&quot;: &quot;Development&quot;,<br>      &quot;account_id&quot;: &quot;987654321098&quot;,<br>      &quot;aws_profile&quot;: &quot;dev-account&quot;,<br>      &quot;region&quot;: &quot;us-east-1&quot;<br>    }<br>  ]<br>}</pre><h3>Step 3: Deploy</h3><pre>python deploy.py --deploy-all</pre><p><strong>Grab coffee ☕</strong> — This takes ~45 minutes for 12 accounts.</p><h3>Step 4: Test</h3><ol><li>Go to AWS Console</li><li>Do literally anything (create S3 bucket, launch EC2, etc.)</li><li>Check Slack</li></ol><p>You should see:</p><pre>🚨 ClickOps Detected in AWS Console</pre><pre>Account: Production<br>User: your-name<br>Action: CreateBucket<br>Service: s3</pre><p><strong>Done!</strong> You’re now monitoring all console activity.</p><h3>Advanced Features</h3><h3>Multi-Region Support</h3><p>Deploy to multiple regions per account:</p><pre>{<br>  &quot;standalone_accounts&quot;: [<br>    {<br>      &quot;name&quot;: &quot;Production&quot;,<br>      &quot;account_id&quot;: &quot;123456789012&quot;,<br>      &quot;aws_profile&quot;: &quot;prod&quot;,<br>      &quot;regions&quot;: [&quot;us-east-1&quot;, &quot;us-west-2&quot;, &quot;eu-west-1&quot;]<br>    }<br>  ]<br>}</pre><h3>Google Chat Integration</h3><p>Add Google Chat webhook:</p><pre>{<br>  &quot;notification&quot;: {<br>    &quot;slack_webhook_url&quot;: &quot;https://hooks.slack.com/...&quot;,<br>    &quot;google_chat_webhook_url&quot;: &quot;https://chat.googleapis.com/...&quot;<br>  }<br>}</pre><p>Both Slack and Google Chat get alerts simultaneously.</p><h3>Custom Filtering</h3><p>Edit lambda_function.py:</p><pre>def should_notify(details):<br>    # Skip specific users<br>    if details[&#39;user&#39;] in [&#39;admin&#39;, &#39;terraform-service-account&#39;]:<br>        return False<br>    <br>    # Skip specific actions<br>    if details[&#39;event_name&#39;] == &#39;CreateTags&#39;:<br>        return False<br>    <br>    # Only alert on production account<br>    if &#39;prod&#39; not in details[&#39;account_name&#39;].lower():<br>        return False<br>    <br>    return True</pre><h3>The Team’s Reaction</h3><p><strong>Week 1:</strong> “Why are we being spied on?”</p><p><strong>Week 2:</strong> “Oh, this caught my mistake before deployment.”</p><p><strong>Week 3:</strong> “Can we add Google Chat too?”</p><p><strong>Week 4:</strong> “This saved us from a security incident.”</p><p><strong>Month 3:</strong> “How did we live without this?”</p><p>The key was <strong>framing</strong>. I didn’t position it as “Big Brother watching you.”</p><p>I framed it as: <strong>“Safety net for all of us.”</strong></p><p>Like seatbelts. Like code reviews. Like automated testing.</p><p>Nobody wants to be the person who brought down production with a manual change.</p><h3>Metrics: 3 Months In</h3><ul><li><strong>Console actions detected:</strong> 1,247</li><li><strong>High-risk actions caught:</strong> 18</li><li><strong>Potential incidents prevented:</strong> 3</li><li><strong>False positives:</strong> 4 (0.3%)</li><li><strong>Team adoption:</strong> 100%</li><li><strong>Cost:</strong> $0</li><li><strong>Maintenance hours:</strong> 0</li></ul><p><strong>ROI:</strong> Prevented one production incident that would’ve cost us 4 hours of engineering time × 5 people = <strong>20 hours saved</strong>.</p><p>At $100/hour engineering cost, that’s <strong>$2,000 saved</strong>.</p><p>For a tool that costs $0 to run.</p><h3>Future Improvements</h3><h3>1. Anomaly Detection</h3><p>Use machine learning to detect unusual patterns:</p><pre>Alice usually makes 2-3 console actions/day.<br>Today she made 47.<br>🚨 Alert: Unusual activity</pre><h3>2. Approval Workflow</h3><p>For high-risk actions, require approval:</p><pre>John wants to delete RDS instance in production.<br>[Approve] [Deny]</pre><h3>3. Auto-Remediation</h3><p>Automatically revert unauthorized changes:</p><pre>Detected manual security group change.<br>Change not in approved list.<br>Auto-reverting in 60 seconds...<br>[Cancel] to keep change</pre><h3>4. Slack Bot Integration</h3><p>Interactive commands:</p><pre>@clickops-bot status<br>&gt; All accounts healthy. 23 actions today.</pre><pre>@clickops-bot history john.doe<br>&gt; John&#39;s last 10 console actions...</pre><pre>@clickops-bot whitelist CreateTags<br>&gt; Whitelisted CreateTags for 24 hours</pre><h3>Open Source &amp; Community</h3><p>I’ve open-sourced this on GitHub: <a href="https://github.com/yourusername/clickops-notifier"><strong>https://github.com/yourusername/clickops-notifier</strong></a></p><p><strong>Features:</strong></p><ul><li>✅ Multi-account support</li><li>✅ Zero cross-account traffic</li><li>✅ Slack + Google Chat</li><li>✅ Smart filtering</li><li>✅ $0/month cost</li><li>✅ 30-minute deployment</li><li>✅ Zero maintenance</li></ul><p><strong>Contributing:</strong></p><p>Found a bug? Have an idea? PRs welcome!</p><pre>git clone https://github.com/yourusername/clickops-notifier<br># Make changes<br># Submit PR</pre><h3>Conclusion: The Philosophy</h3><p>This tool isn’t about <strong>catching people making mistakes</strong>.</p><p>It’s about <strong>creating visibility</strong>.</p><p>In DevOps, the worst thing isn’t making mistakes. It’s <strong>making mistakes invisibly</strong>.</p><p>When mistakes are visible:</p><ul><li>They get fixed faster</li><li>We learn from them</li><li>We improve processes</li><li>We build better systems</li></ul><p><strong>ClickOps Notifier</strong> makes the invisible visible.</p><p>And sometimes, that’s all you need.</p><h3>Try It Yourself</h3><p><strong>Repository:</strong> <a href="https://github.com/yourusername/clickops-notifier">https://github.com/ryoguritno/clickops-notifier</a></p><p><strong>Deployment time:</strong> 30 minutes</p><p><strong>Cost:</strong> $0/month</p><p><strong>Maintenance:</strong> Zero</p><p><strong>Impact:</strong> Potentially preventing your next production incident</p><p>Go build it. Deploy it. Customize it. Make it yours.</p><p>And the next time someone manually changes production…</p><p>You’ll know. 🚨</p><p><strong>Got questions?</strong> Drop a comment below or ping me on Twitter [@ryoguritno]</p><p><strong>Want to see the code?</strong> Check out the <a href="https://github.com/ryoguritno/clickops-notifier">GitHub repo</a></p><p><strong>Found this useful?</strong> Give it a ⭐ on GitHub and share with your team!</p><p><em>P.S. — After publishing this, three of my colleagues tried to “test” the system by creating buckets in production. All three were caught instantly. The system works. 😎</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbaa8145b981" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello World from nubies]]></title>
            <link>https://medium.com/@kryukz/hello-world-from-nubies-62f896e8dfe4?source=rss-945136394d8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/62f896e8dfe4</guid>
            <dc:creator><![CDATA[Ryo Guritno]]></dc:creator>
            <pubDate>Mon, 06 Sep 2021 07:01:17 GMT</pubDate>
            <atom:updated>2021-09-06T07:03:08.712Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Fellas, My name is Ryo Guritno. I want to start my journey about writing tech docs or anything that I write. Hope you guys enjoy it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62f896e8dfe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>