A DevOps solution for BTL, a small business that organizes events and requires real-time weather information for operational decision-making. This project creates an automated system that fetches weather data and displays it on a public dashboard using AWS S3 static website hosting.
BTL needs a real-time weather dashboard integrated into their event booking page to help customers make informed decisions. As a small business without technical expertise, they require a low-maintenance, cost-effective solution that:
- Fetches weather data from a reliable source
- Processes it into a visually appealing format
- Hosts it on a scalable platform
- Provides easy public access
The project implements two main components:
- JSON data storage pipeline for analytics
- Dynamic HTML dashboard for public display
- Data Source: OpenWeatherMap API
- Programming Language: Python
- Cloud Platform: AWS S3
- Development Environment:
- Vagrant (VM)
- VS Code
- Key Libraries:
- Requests: API integration
- Boto3: AWS S3 interaction
- Jinja2: HTML templating
- python-dotenv: Environment management
- Vagrant and VirtualBox (Optional)
- Visual Studio Code
- AWS Account
- Python 3
- AWS CLI
# Initialize Vagrant
vagrant init hashicorp/bionic64
vagrant up
mkdir -p weather_dashboard/{src,data,tests,templates}
cd weather_dashboard
# Update system and install Python
sudo apt update && sudo apt install -y python3-pip python3-venv
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install AWS CLI
sudo apt install -y awscli
# Configure AWS credentials
aws configure
Create a .env
file with the following parameters:
OPENWEATHERMAP_API_KEY=your_openweathermap_api_key
JSON_BUCKET_NAME=your_s3_bucket_for_json
HTML_BUCKET_NAME=your_s3_bucket_for_html
Add .env
to .gitignore
:
echo ".env" >> .gitignore
python3 src/json_weather_dashboard.py
python3 src/web_weather_dashboard.py
- Configure S3 Bucket for Static Website Hosting:
- Navigate to your S3 bucket in AWS Console
- Enable Static website hosting under Properties
- Uncheck "Block all public access"
- Add bucket policy for public read access:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
- Access the dashboard at:
http://your_html_bucket.s3-website-us-east-1.amazonaws.com
- S3 Bucket Creation Error: Fixed by implementing proper bucket name validation
- API Authorization: Resolved unauthorized access issues by validating API key presence
- Missing Dependencies: Addressed by properly managing virtual environment and requirements
- PATH Issues: Fixed pip-related PATH problems by updating environment variables
Access the live weather dashboard: http://web-jarvis-weather.s3-website.us-east-2.amazonaws.com/
Feel free to fork this repository and submit pull requests with improvements.
This project is open source and available under the MIT License.