This project is a Python-based network provisioning and validation framework that automates the creation of VPCs, subnets, and routing tables across LocalStack (AWS-like) and Google Cloud Platform (GCP). It ensures cross-cloud consistency, real-time validation, and infrastructure state synchronization using:
- Boto3 (LocalStack/AWS)
- Google Cloud SDK (Python API)
- Paramiko (SSH validation)
- Create VPCs and subnets
- Create and associate route tables
- Automatically sync topology across LocalStack & GCP
- Idempotent: re-running does not duplicate resources
- Connect to remote hosts via SSH
- Run commands (e.g.,
ip route,ip addr) - Verify routing and network consistency
- LocalStack (local AWS emulator)
- GCP (real cloud)
cloud-network-automation/
├── providers/
│ ├── localstack_provider.py
│ └── gcp_provider.py
├── validators/
│ └── ssh_validator.py
├── utils/
│ └── logger.py
├── config.yaml
├── main.py
├── requirements.txt
└── README.md
Python 3.9+
virtualenv recommended
You can run LocalStack via Docker:
docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack:latestCreate a service account with the following permissions:
- Compute Network Admin
- Compute Admin
- Service Account Token Creator (optional for local auth)
Then:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"To run validation:
- Ensure your SSH private key exists (
~/.ssh/id_rsa) - Add your SSH-accessible host IP in
config.yaml
git clone https://github.com/your-username/python-network-automation.git
cd python-network-automation
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtEdit the file:
config.yaml
Example:
localstack:
endpoint_url: http://localhost:4566
region: us-east-1
vpc:
cidr_block: 10.0.0.0/16
name: local-vpc-demoSee full sample config in the repo.
python main.py --config config.yaml --env localstack --action provisionpython main.py --config config.yaml --env gcp --action provisionpython main.py --config config.yaml --env both --action provisionpython main.py --config config.yaml --action validatepython main.py --config config.yaml --action allaws ec2 describe-vpcs --endpoint-url http://localhost:4566 --region us-east-1
aws ec2 describe-subnets --endpoint-url http://localhost:4566 --region us-east-1
aws ec2 describe-route-tables --endpoint-url http://localhost:4566 --region us-east-1The project uses a lightweight Python logger (utils/logger.py).
Logs print to the console with:
- timestamp
- log level
- module name
Example:
2025-11-13 22:29:44 [INFO] localstack-provider: Created subnet subnet-12345 (10.0.1.0/24)
-
Ensure LocalStack is running at
http://localhost:4566 -
If resources fail to create, run:
localstack logs
Make sure your service account has:
roles/compute.admin
roles/compute.networkAdmin
- Ensure IP is reachable
- Ensure user and key are correct
- Check firewall rules (GCP may block SSH)
These are safe to ignore.
- Drift detection (compare LS <-> GCP resources)
- Automatic instance creation for deeper validation
- Web dashboard visualizing infrastructure
- Export topology to Terraform or Pulumi
- Adding AWS real-cloud support
MIT License. Feel free to use, modify, and contribute.
