Packer Script for Secure, Automated Moltbot (AI Agent) Deployment on AWS Graviton

Job ID: 40187355

Budget: $20 – $30 SGD

1. OverviewWe require a DevOps expert to create a Packer template and associated scripts to build an Amazon Machine Image (AMI) for hosting Moltbot (an open-source Node.js AI agent). The target architecture is AWS Graviton (ARM64). The focus is on security, automation, and user experience (UX) for the end-user.
2. Scope of Work
2.1 Infrastructure as Code (Packer)
Tooling: Must use Packer (HCL format) to automate the AMI creation. Manual setup via SSH is not accepted.
Base Image: Ubuntu 24.04 LTS (ARM64 architecture).
Target Instance: Optimized for t4g or c7g families.
2.2 Application Configuration (Docker)
Create a docker-compose setup for Moltbot tailored for ARM64.
Persistence: Map container volumes (/app/memory, /app/workspace) to the host filesystem to ensure data persists across container recreations.
Self-Healing: Configure Docker with restart: always policy.
2.3 Security Layer (Caddy & Auth)
Install and configure Caddy as a reverse proxy.
Mandatory Authentication: Implement HTTP Basic Auth in Caddy to protect the web interface.
Port Security: Configure ufw or iptables to block all external access to application ports (e.g., 3000), allowing ingress only on ports 80, 443, and 22.
2.4 "First-Run" Interactive Wizard
Develop a bash script (setup_wizard.sh) triggered automatically upon the first SSH login (via .bashrc or MOTD).
Workflow:
Prompt user to set a new password for the Web UI (updates Caddy config).
Prompt user for environment variables (e.g., ANTHROPIC_API_KEY, TELEGRAM_TOKEN).
Save credentials to .env and restart Docker containers.
Self-destruct mechanism: The script should disable itself after a successful run.
2.5 AMI Clean-up
The Packer script must perform standard AMI hardening:
Remove SSH host keys, authorized_keys, and command history (.bash_history).
Ensure no secrets or API keys are hardcoded in the image.
3. Deliverables
Source Code: build.pkr.hcl, docker-compose.yml, setup_wizard.sh, and Caddyfile.
Documentation: README.md with instructions on how to run the Packer build command.
Verification: A successful build log and a demo IP address (optional) showing the login prompt.
4. Acceptance Criteria
Build Success: I can run packer build . and get a working AMI in my AWS account.
Security Check: Accessing the web interface without credentials must fail (401 Unauthorized).
Persistence Check: Rebooting the instance does not wipe the AI's memory files.