This project deploys a cost-effective, self-healing NAT solution on AWS using fck-nat instances within an Auto Scaling Group. It includes a Justfile to automate deployment and simplify SSH connections to private resources.
- Cost Effective: Uses
t4g.nanoort3.microinstances instead of expensive AWS NAT Gateways. - Self-Healing: If the NAT instance fails, the Auto Scaling Group launches a new one, and the route table is automatically updated.
- Automation: Includes a
Justfilefor one-command deployment and SSH tunneling. - VS Code Support: Pre-configured tasks for easy execution from the editor.
- Terraform installed.
- AWS CLI configured with credentials.
- Just installed (command runner).
The project uses just to handle Terraform commands and key permissions automatically.
just init
just applyDisplays the generated keys and IP addresses.
just infoThis setup includes helper commands to handle SSH keys and tunneling automatically.
Connects directly to the bastion/NAT host.
just ssh-natSince the application server is in a private subnet, we use SSH tunneling.
-
Open the tunnel in the background:
just ssh-tunnel
-
Connect to the app:
just ssh-app
-
Close the tunnel when finished:
just ssh-tunnel-close
A .vscode/tasks.json file is included. You can run all the above commands directly from Visual Studio Code:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac). - Type
Run Task. - Select any task (e.g.,
⚡ Terraform Apply,💻 SSH to Private App).
To destroy all resources:
just destroy- Key Permission Error: Run
just fix-perms. - Host Key Verification Failed: Run
just ssh-clearto remove old localhost entries from your known_hosts file. - Tunnel Issues: Run
just ssh-tunnel-closeto clear old processes, then try opening the tunnel again.