DevOps & Cloud / One-Click-Multi-Cloud-Provisioner
One-Click Multi-Cloud Provisioner
A comprehensive DevOps automation tool that provisions complete infrastructure on AWS and GCP using Terraform, Ansible, and Python.
Open the full technical write-up
A comprehensive DevOps automation tool that provisions complete infrastructure on AWS and GCP using Terraform, Ansible, and Python. Deploy production-ready infrastructure with monitoring, databases, and CI/CD integration in a single command.
Table of Contents
- Overview
- Key Features
- Architecture
- Prerequisites
- Quick Start
- Setup Steps
- Usage Examples
- Project Structure
- Cost Estimation
- Drift Detection
- CI/CD Integration
- Testing
- Roadmap
- Contributing
- License
What this project does
The One-Click Multi-Cloud Provisioner automates the entire infrastructure provisioning lifecycle:
- Infrastructure as Code: Terraform manages VPCs, subnets, compute instances, and databases
- Configuration Management: Ansible deploys applications and monitoring agents
- Cost Optimization: Real-time cost estimation using cloud provider APIs
- Drift Detection: Automated monitoring of infrastructure configuration drift
- CI/CD Ready: Jenkins and GitHub Actions workflows included
Core workflows
- Multi-Cloud Support: Deploy to AWS and GCP with the same command
- Environment Management: Separate configurations for dev, staging, and prod
- Automated Monitoring: Prometheus and Node Exporter pre-configured
- Database Support: Optional RDS (AWS) or CloudSQL (GCP) provisioning
- Cost Estimation: Real-time cost estimates before provisioning
- Drift Detection: Automated alerts for infrastructure configuration drift
- CI/CD Integration: Ready-to-use Jenkins and GitHub Actions workflows
- Production Ready: Security groups, encryption, and best practices included
How the system is built
graph TB
subgraph "User Interface"
CLI[Python CLI
provision.py]
end
subgraph "Orchestration Layer"
PROV[Provisioner
Python Script]
COST[Cost Estimator
Module]
DRIFT[Drift Detector
Module]
end
subgraph "Infrastructure Layer"
TF_AWS[Terraform
AWS]
TF_GCP[Terraform
GCP]
end
subgraph "Configuration Layer"
ANS[Ansible
Playbooks]
APP[App Deployment
Role]
MON[Monitoring
Role]
end
subgraph "Cloud Providers"
AWS[AWS
EC2, VPC, RDS]
GCP[GCP
Compute, VPC, CloudSQL]
end
subgraph "Monitoring Stack"
PROM[Prometheus]
NODE[Node Exporter]
end
CLI --> PROV
PROV --> COST
PROV --> TF_AWS
PROV --> TF_GCP
PROV --> ANS
TF_AWS --> AWS
TF_GCP --> GCP
ANS --> APP
ANS --> MON
MON --> PROM
MON --> NODE
PROV --> DRIFT
DRIFT --> TF_AWS
DRIFT --> TF_GCP
style CLI fill:#e1f5ff
style PROV fill:#fff4e1
style TF_AWS fill:#ffebee
style TF_GCP fill:#e8f5e9
style ANS fill:#f3e5f5
Prerequisites
Required Software
- Python 3.9+
- Terraform 1.0+
- Ansible 2.9+
- AWS CLI (for AWS deployments)
- Google Cloud SDK (for GCP deployments)
Cloud Provider Accounts
- AWS Account with appropriate IAM permissions
- GCP Project with billing enabled and required APIs enabled
Authentication
- AWS: Configure credentials using
aws configureor environment variables - GCP: Authenticate using
gcloud auth application-default login
Quick Start
1. Clone the Repository
git clone https://github.com/yourusername/one-click-multicloud-provisioner.git
cd one-click-multicloud-provisioner
2. Install Dependencies
Windows (using winget):
python setup.py install-deps
Linux/Mac:
pip install -r requirements.txt
3. Provision Infrastructure
# AWS Staging Environment
python scripts/provision.py --cloud aws --env staging
# GCP Production Environment with Database
python scripts/provision.py --cloud gcp --env prod --enable-db
Setup Steps
Detailed Installation
-
Install Python Dependencies
pip install -r requirements.txt -
Install Terraform
- Download from terraform.io
- Or use package manager:
winget install HashiCorp.Terraform
-
Install Ansible
pip install ansible ansible-core -
Configure AWS Credentials
aws configure # Or set environment variables: # export AWS_ACCESS_KEY_ID=your_key # export AWS_SECRET_ACCESS_KEY=your_secret -
Configure GCP Credentials
gcloud auth application-default login gcloud config set project YOUR_PROJECT_ID -
Set Terraform Variables (Optional)
- Create
terraform/aws/terraform.tfvarsfor AWS - Create
terraform/gcp/terraform.tfvarsfor GCP
- Create
Usage Examples
Basic Provisioning
# Provision AWS dev environment
python scripts/provision.py --cloud aws --env dev
# Provision GCP staging environment
python scripts/provision.py --cloud gcp --env staging
With Database
# Provision AWS production with RDS
python scripts/provision.py --cloud aws --env prod --enable-db
# Provision GCP staging with CloudSQL
python scripts/provision.py --cloud gcp --env staging --enable-db
Cost Estimation Only
from modules.cost_estimator import CostEstimator
estimator = CostEstimator("aws", "staging", enable_db=True)
cost_summary = estimator.estimate()
estimator.print_summary(cost_summary)
Drift Detection
# Check for configuration drift
python scripts/drift_detector.py --cloud aws
# With email alerts
python scripts/drift_detector.py --cloud gcp --email-config email_config.json
Sample CLI Output
============================================================
š Starting Multi-Cloud Provisioning
Cloud: AWS
Environment: STAGING
Database: Enabled
============================================================
ā
All prerequisites met
š° Estimating infrastructure costs for AWS...
============================================================
š° COST ESTIMATION SUMMARY
============================================================
āāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāā
ā Component ā Details ā Monthly Cost (USD) ā
āāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāā¤
ā Compute ā 1x t3.large ā $60.74 ā
ā Storage ā 50 GB ā $5.00 ā
ā Data Transfer ā Estimated ā $10.00 ā
ā Database ā db.t3.small ā $24.82 ā
āāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāā¤
ā TOTAL (Monthly) ā ā $100.56 ā
ā TOTAL (Yearly) ā ā $1,206.72 ā
āāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāāā
š§ Initializing Terraform for AWS...
ā
Terraform initialized successfully
š Running Terraform plan for AWS...
ā
Terraform plan completed successfully
š Applying Terraform configuration for AWS...
ā
Terraform apply completed successfully
š¦ Running Ansible playbooks...
ā
Ansible deployment completed successfully
============================================================
ā
Provisioning completed successfully!
============================================================
š Infrastructure Outputs:
instance_public_ips: ['54.123.45.67']
vpc_id: vpc-0123456789abcdef0
How files are organized
one-click-multicloud-provisioner/
āāā terraform/
ā āāā aws/
ā ā āāā main.tf # AWS infrastructure definition
ā ā āāā variables.tf # AWS variables
ā ā āāā outputs.tf # AWS outputs
ā ā āāā .gitignore
ā āāā gcp/
ā āāā main.tf # GCP infrastructure definition
ā āāā variables.tf # GCP variables
ā āāā outputs.tf # GCP outputs
ā āāā .gitignore
āāā ansible/
ā āāā playbooks/
ā ā āāā deploy.yml # Main deployment playbook
ā āāā roles/
ā ā āāā app_deployment/ # Application deployment role
ā ā āāā monitoring/ # Monitoring setup role
ā āāā inventory/ # Dynamic inventory files
ā āāā ansible.cfg # Ansible configuration
āāā scripts/
ā āāā provision.py # Main provisioning script
ā āāā drift_detector.py # Drift detection script
āāā modules/
ā āāā cost_estimator.py # Cost estimation module
ā āāā drift_detector.py # Drift detector module wrapper
āāā .github/
ā āāā workflows/
ā āāā ci.yml # GitHub Actions workflow
āāā Jenkinsfile # Jenkins pipeline
āāā requirements.txt # Python dependencies
āāā setup.py # Setup script with winget
āāā README.md # This file
Cost Estimation
The cost estimator module provides real-time cost estimates using:
- AWS Pricing API: Fetches current pricing for EC2, RDS, and storage
- GCP Billing API: Estimates costs for Compute Engine and CloudSQL
- Fallback Pricing: Uses cached pricing if APIs are unavailable
What the project includes
- Instance type recommendations based on environment
- Storage and data transfer estimates
- Database cost calculations
- Monthly and yearly projections
- Cost breakdown by component
Drift Detection
The drift detector monitors infrastructure for configuration drift:
What the project includes
- Automated Terraform plan execution
- Detailed drift reports
- Email alerts (optional)
- Historical drift tracking
- Integration with CI/CD pipelines
Usage
# Basic drift detection
python scripts/drift_detector.py --cloud aws
# With email notifications
python scripts/drift_detector.py --cloud gcp \
--email-config email_config.json
CI/CD Integration
GitHub Actions
The included workflow provides:
- Automated linting and validation
- Terraform syntax checking
- Ansible syntax validation
- Manual provisioning triggers
- Multi-cloud testing
Setup:
- Add AWS credentials to GitHub Secrets:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY - Add GCP service account key to GitHub Secrets:
GCP_SA_KEY - Workflow will run on push/PR and can be triggered manually
Jenkins
The Jenkinsfile includes:
- Multi-stage pipeline
- Parallel testing
- Terraform validation
- Ansible syntax checks
- Automated cleanup
Setup:
- Install required Jenkins plugins: Pipeline, Ansible, Terraform
- Configure cloud credentials in Jenkins
- Create a pipeline job pointing to the Jenkinsfile
Testing
The project includes a comprehensive test suite with 55 test cases covering all major components.
Test Coverage
- Total Tests: 55 tests
- Test Status: All passing
- Code Coverage: 74% overall
modules/cost_estimator.py: 92% coveragemodules/drift_detector.py: 100% coveragescripts/drift_detector.py: 79% coveragescripts/provision.py: 61% coverage
Test Suite Structure
tests/
āāā test_provisioner.py # 13 tests - Provisioner class validation and workflows
āāā test_cost_estimator.py # 18 tests - Cost estimation logic for AWS and GCP
āāā test_drift_detector.py # 16 tests - Drift detection functionality
āāā test_integration.py # 5 tests - Integration and end-to-end scenarios
Running Tests
# Run all tests
pytest tests/ -v
# Run with coverage report
pytest tests/ --cov=scripts --cov=modules --cov-report=term-missing
# Run specific test file
pytest tests/test_provisioner.py -v
# Run specific test
pytest tests/test_cost_estimator.py::TestCostEstimator::test_estimate_aws -v
Test Results Summary
============================= test session starts =============================
platform win32 -- Python 3.11.9, pytest-8.4.2
collected 55 items
tests/test_cost_estimator.py::TestCostEstimator ................ [18 tests] ā
tests/test_drift_detector.py::TestDriftDetector ................ [16 tests] ā
tests/test_integration.py::TestIntegration ..................... [5 tests] ā
tests/test_provisioner.py::TestProvisioner ..................... [13 tests] ā
============================= 55 passed in 53.19s =============================
Test Categories
Unit Tests
- Provisioner Tests: Initialization, validation, prerequisite checking, Terraform operations, Ansible integration
- Cost Estimator Tests: AWS/GCP cost calculations, region/instance type selection, database cost estimation
- Drift Detector Tests: Terraform plan execution, drift parsing, report generation, email alerts
Integration Tests
- Multi-cloud provisioning workflows
- Cost estimation across all environments (dev, staging, prod)
- Database enablement scenarios
- Validation flow for all cloud/environment combinations
Test Evidence
Last Test Run: All 55 tests passing
Coverage Report:
Name Stmts Miss Cover Missing
---------------------------------------------------------
modules\cost_estimator.py 109 9 92%
modules\drift_detector.py 2 0 100%
scripts\drift_detector.py 141 30 79%
scripts\provision.py 183 72 61%
---------------------------------------------------------
TOTAL 435 111 74%
Continuous Testing
Tests are automatically run:
- On every commit via GitHub Actions (if configured)
- Before merging pull requests
- As part of the CI/CD pipeline
Adding New Tests
When adding new features:
- Write unit tests for new functions/classes
- Add integration tests for new workflows
- Ensure coverage remains above 70%
- Run tests locally before committing
Roadmap
Phase 1 (Current)
- AWS and GCP provisioning
- Basic monitoring setup
- Cost estimation
- Drift detection
Phase 2 (Planned)
- Azure support
- Kubernetes cluster provisioning
- Advanced monitoring (Grafana, AlertManager)
- Multi-region deployments
- Disaster recovery automation
Phase 3 (Future)
- Web UI dashboard
- Infrastructure visualization
- Cost optimization recommendations
- Automated scaling policies
- Blue-green deployment support
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow PEP 8 for Python code
- Use Terraform best practices
- Write Ansible roles with idempotency
- Add tests for new features
- Update documentation
Code Style
- Python: Use
blackformatter, max line length 120 - Terraform: Use
terraform fmt - Ansible: Follow Ansible best practices
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- HashiCorp for Terraform
- Red Hat for Ansible
- Prometheus community
- AWS and GCP for their excellent APIs
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@example.com
Disclaimer
This tool provisions real cloud infrastructure that will incur costs. Always review the cost estimates and ensure you have proper access controls in place. The authors are not responsible for any costs incurred from using this tool.
Made by the DevOps community