Skip to content

RaihanStark/aws-instance-management

Repository files navigation

AWS Instance Management

A simple web application to manage AWS EC2 instances and save money on remote development or VPS costs.

AWS Instance Management Dashboard

Why This Project?

Running EC2 instances 24/7 on AWS can be expensive. This tool helps you save money by making it easy to:

  • Start your VPS only when you need to use it
  • Stop your VPS when you're not using it
  • Track your usage hours and costs

Instead of paying for 720+ hours per month (24/7 operation), you only pay for the hours you actually use.

Features

  • Simple Dashboard: View all your EC2 instances at a glance
  • One-Click Control: Start and stop instances with a single click
  • Cost Tracking:
    • Monthly usage hours and costs (from AWS Cost Explorer)
    • Hourly pricing rates (automatically fetched from AWS Pricing API)
  • Multi-Platform Support: Automatically detects and prices Linux and Windows instances correctly
  • Secure: Password-protected with server-side authentication

Note on Real-Time Session Tracking: AWS EC2 does not provide an API to track when an instance was last started. The LaunchTime field represents when the instance was originally created, not when it was last started after a stop. Therefore, accurate real-time session cost tracking is not currently supported by AWS infrastructure.

Prerequisites

  • Node.js (v18 or higher)
  • AWS Account with EC2 instances
  • AWS IAM credentials with the following permissions:
    • ec2:DescribeInstances
    • ec2:StartInstances
    • ec2:StopInstances
    • ce:GetCostAndUsage
    • pricing:GetProducts

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd aws-instance-management
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory:
# Authentication Password
AUTH_PASSWORD=your-secure-password

# Session Secret (change this to a random string)
SESSION_SECRET=your-random-secret-key

# AWS Credentials
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_REGION=ap-southeast-1
  1. Start the development server:
npm run dev
  1. Open your browser and navigate to http://localhost:5173

Building for Production

To create a production build:

npm run build

Preview the production build:

npm run preview

How It Works

  1. Login: Enter your password to access the dashboard
  2. View Instances: See all your EC2 instances with their current status
  3. Control: Click "Start" or "Stop" to manage your instances
  4. Monitor Costs:
    • Monthly Hours/Cost: Historical data from AWS Cost Explorer (24-48h delay)
    • Hourly Rate: Accurate pricing from AWS Pricing API

Cost Savings Example

If you use a t3.medium instance ($0.0416/hour in Singapore):

  • 24/7 Operation: 720 hours/month = $29.95/month
  • 8 Hours/Day: 240 hours/month = $9.98/month
  • Savings: $19.97/month (67% reduction)

Technology Stack

  • Frontend: SvelteKit with Tailwind CSS
  • Backend: SvelteKit API routes
  • AWS SDK:
    • @aws-sdk/client-ec2 - Instance management
    • @aws-sdk/client-cost-explorer - Monthly billing data
    • @aws-sdk/client-pricing - Accurate hourly rates

Security Notes

  • All AWS operations are performed server-side
  • Session authentication using HTTP-only cookies
  • No AWS credentials exposed to the client
  • Password stored in environment variable

License

MIT

About

A simple web application to manage AWS EC2 instances and save money on remote development or VPS costs.

Resources

Stars

Watchers

Forks

Contributors