Skip to content

About

A web tool that help you to quickly query EC2 instance information, including: configuration, specifications, features and monthly on-demand price for reference.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

EC2 QuickLook

A web tool that helps you quickly query EC2 instance information, including configuration, specifications, features, and monthly on-demand price for reference.

Features

  • 🔍 Query EC2 instance details and OD pricing
  • 💾 EBS volume OD pricing
  • 📊 Detailed instance specifications
  • 💰 Price change indicators
  • 📈 Instance price comparison (up to 8 instances)
  • 🌐 Support for both AWS Global and China regions
  • 🚀 Serverless deployment with AWS Chalice
  • 📝 Swagger UI API documentation

What is this project?

This is a demonstration project for AWS Chalice, a microservice framework for writing serverless applications in Python. The project features a modern Vue.js frontend with Bootstrap-Vue components, RESTful backend APIs, and integrated Swagger UI for API documentation.

You can deploy it to the AWS cloud with a single command. No servers, containers, or storage resources are required for deployment.

Architecture

  • Infrastructure: AWS Lambda + API Gateway (managed by Chalice)
  • Database: Amazon DynamoDB (app config, plus a daily snapshot of every region's instance types)
  • Instance type data: the scheduled function sync_instance_types refreshes the snapshot daily at 00:00 UTC; API requests read only the snapshot, never the EC2 API
  • Frontend: Vue.js with Bootstrap-Vue components
  • Backend: Python with AWS Chalice framework
  • API Documentation: Swagger UI

File Structure

ec2-quicklook/ ├── app.py # Main application entry point ├── chalicelib/ │ ├── config.py # Configuration management │ ├── sdk.py # AWS SDK integration │ ├── utils.py # Utility functions │ ├── models.py # Data models │ ├── product/ # Product-related functionality │ ├── swagger/ # Swagger UI integration │ ├── webui/ # Web interface │ └── static/ # Static assets │ └── js/ # VUE JavaScript └── tests/ # Test files

Prerequisites

  • Python 3.14 (pinned in .python-version); Chalice deploys to the Lambda runtime matching the Python it runs under
  • AWS Chalice
  • AWS Credentials (with appropriate permissions)

Installation

  1. Clone the repository:
git clone https://github.com/aleck31/ec2-quicklook.git
cd ec2-quicklook
  1. Set up Python virtual environment:
python -m venv .venv

# Linux/Mac
source .venv/bin/activate

# Windows
.venv/Scripts/Activate.ps1
  1. Install required dependencies:
pip install -r requirements-dev.txt  # runtime deps (requirements.txt, packaged into Lambda) plus chalice CLI and pytest
  1. Create required AWS resources:
# Create resources (default --stage dev)
python create-resources.py

Local Development

  1. Run the application locally:
chalice local
  1. Access the application:

Deployment

Deploy to AWS:

chalice deploy

# Example output:
Updating lambda function: ec2-quicklook-dev
Updating rest API
Resources deployed:
  - Lambda ARN: arn:aws:lambda:us-east-1::function:ec2-quicklook-dev
  - Rest API URL: https://...execute-api.us-east-1.amazonaws.com/api/

After deployment, you can access:

  • Main application: https://...execute-api.us-east-1.amazonaws.com/api/
  • API documentation: https://...execute-api.us-east-1.amazonaws.com/api/docs

After the first deployment, fill the instance type snapshot once instead of waiting for the daily run:

chalice invoke --name sync_instance_types

Environment Configuration

Log Level

Log level is controlled by ENV_LOG_LEVEL environment variable in .chalice/config.json:

  • CRITICAL
  • ERROR
  • WARNING
  • INFO
  • DEBUG
  • NOTSET

Reference: Python logging levels

IAM Role Policy

You can customize the IAM role policy for your project:

Troubleshooting

Access Denied

If you encounter an "AccessDeniedException", ensure that the correct permissions are configured for the Lambda service role. Refer to example/role_policy.json to update the Lambda role permissions.

AWS China Region

China-region instance data is fetched by the daily sync using IAM outbound identity federation instead of access keys: the sync function gets a short-lived token from STS (sts:GetWebIdentityToken, already in policy-dev.json) and exchanges it for temporary credentials of a role in the AWS China account. To set it up:

  1. Enable outbound identity federation in the global account
  2. In the AWS China account, add an OIDC provider for that account's token issuer (client ID sts.amazonaws.com.cn) and a role that trusts it, restricted to sub = the Lambda role ARN (sync_instance_types runs under the api_handler role, see config.json), with ec2:DescribeInstanceTypes
  3. Set CN_ROLE_ARN in config.json to that role's ARN

Local Development

Common issues and solutions:

  1. DynamoDB Connection: Ensure your AWS credentials have DynamoDB access permissions
  2. API Gateway: Local development uses a mock API Gateway, some features might behave differently
  3. Environment Variables: Check .chalice/config.json for correct environment variable configuration

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

A web tool that help you to quickly query EC2 instance information, including: configuration, specifications, features and monthly on-demand price for reference.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages