A web tool that helps you quickly query EC2 instance information, including configuration, specifications, features, and monthly on-demand price for reference.
- 🔍 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
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.
- 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_typesrefreshes 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
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
- 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)
- Clone the repository:
git clone https://github.com/aleck31/ec2-quicklook.git
cd ec2-quicklook- Set up Python virtual environment:
python -m venv .venv
# Linux/Mac
source .venv/bin/activate
# Windows
.venv/Scripts/Activate.ps1- Install required dependencies:
pip install -r requirements-dev.txt # runtime deps (requirements.txt, packaged into Lambda) plus chalice CLI and pytest- Create required AWS resources:
# Create resources (default --stage dev)
python create-resources.py- Run the application locally:
chalice local- Access the application:
- Main application: http://127.0.0.1:8000
- API documentation: http://127.0.0.1:8000/api/docs
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_typesLog level is controlled by ENV_LOG_LEVEL environment variable in .chalice/config.json:
- CRITICAL
- ERROR
- WARNING
- INFO
- DEBUG
- NOTSET
Reference: Python logging levels
You can customize the IAM role policy for your project:
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.
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:
- Enable outbound identity federation in the global account
- 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 tosub= the Lambda role ARN (sync_instance_typesruns under theapi_handlerrole, seeconfig.json), withec2:DescribeInstanceTypes - Set
CN_ROLE_ARNinconfig.jsonto that role's ARN
Common issues and solutions:
- DynamoDB Connection: Ensure your AWS credentials have DynamoDB access permissions
- API Gateway: Local development uses a mock API Gateway, some features might behave differently
- Environment Variables: Check
.chalice/config.jsonfor correct environment variable configuration
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS Chalice Tutorial - Python Serverless Framework
- AWS Pricing API - EC2 Pricing Information
- Bootstrap-Vue - Vue.js Implementation of Bootstrap
- Swagger UI - API Documentation