A comprehensive Python utility to convert Palo Alto Panorama XML configuration exports into Terraform configuration files, specifically designed to facilitate firewall migrations between different Palo Alto platforms.
This tool is purpose-built for migrating Palo Alto firewalls to different platforms (e.g., PA-3000 β PA-5000, physical β VM-Series). It extracts your complete configuration and generates both:
- Terraform files for automated deployment
- Interface migration report for planning interface mapping
panorama_to_terraform.py- Main conversion script (comprehensive parser and generator)sample_panorama_config.xml- Example configuration with all featuresMIGRATION_GUIDE.md- Complete step-by-step migration workflowUSAGE_GUIDE.md- Comprehensive technical documentationREADME.md- This filequick_start.sh- Quick start demonstration scriptexample_interface_report.txt- Sample interface inventory report
# 1. Make scripts executable
chmod +x panorama_to_terraform.py quick_start.sh
# 2. Run the quick start demo
./quick_start.sh
# 3. Or convert your own Panorama config
python3 panorama_to_terraform.py your_config.xml --output-dir terraform_output- Python 3.6+
- Terraform 1.0+
- Access to Palo Alto Panorama or Firewall
- β Zones - Security zones with interface assignments
- β Interfaces - Ethernet, VLAN, Loopback with IP addresses
- β Virtual Routers - Routing configuration and static routes
- β BGP - β NEW - BGP configuration with peers and peer groups
- β OSPF - β NEW - OSPF configuration with areas and interfaces
- β IPsec VPN - β NEW - IKE gateways, IPsec tunnels, crypto profiles
- β Security Profiles - Antivirus, Anti-Spyware, Vulnerability, URL Filtering, File Blocking, WildFire
- β Security Profile Groups - Profile group assignments
- β Address Objects (IP, FQDN, Range)
- β Address Groups (Static & Dynamic)
- β Service Objects (TCP/UDP)
- β Service Groups
- β Security Policy Rules
- β NAT Policy Rules
- β Device Groups
- β Interface Migration Report - Complete interface and IP inventory
- β VPN Migration Report - β NEW - VPN configuration with key management instructions
- β Platform Guidance - PA-200/500, PA-800, PA-3000, PA-5000, PA-7000, VM-Series
- β Migration Checklist - Step-by-step migration workflow
- β Interface Mapping Planning - Tools to plan interface changes
panos_bgp- β NEWpanos_bgp_peer_group- β NEWpanos_bgp_peer- β NEWpanos_ospf- β NEWpanos_ospf_area- β NEWpanos_ospf_area_interface- β NEWpanos_ike_crypto_profile- β NEWpanos_ipsec_crypto_profile- β NEWpanos_ike_gateway- β NEWpanos_ipsec_tunnel- β NEWpanos_ipsec_tunnel_proxy_id_ipv4- β NEWpanos_zonepanos_ethernet_interfacepanos_virtual_routerpanos_static_route_ipv4panos_security_profile_grouppanos_address_objectpanos_address_grouppanos_service_objectpanos_service_grouppanos_security_rule_grouppanos_nat_rule_group
Export Config β Run Converter β Review Interface Report
β
Plan Interface Mapping
β
Adjust Terraform Configs
β
Test in Lab β Deploy to Production
Key Output: INTERFACE_MIGRATION_REPORT.txt
- Lists all interfaces with IP addresses
- Shows interface types and modes
- Displays management profiles
- Includes VLAN tags
- Provides platform migration guidance
Key Output: VPN_MIGRATION_REPORT.txt β NEW (if VPNs detected)
- Lists all IKE gateways and IPsec tunnels
- Highlights placeholder pre-shared keys
- Provides key management best practices
- Includes security warnings and checklist
- Critical: Keys must be updated before deployment
python3 panorama_to_terraform.py panorama_export.xmlpython3 panorama_to_terraform.py panorama_export.xml --output-dir /path/to/terraformcd terraform_output
ls -la
# You'll see:
# - provider.tf
# - variables.tf
# - zones.tf β NEW
# - interfaces.tf β NEW
# - virtual_routers.tf β NEW
# - security_profiles.tf β NEW
# - security_profile_groups.tf β NEW
# - address_objects.tf
# - address_groups.tf
# - service_objects.tf
# - service_groups.tf
# - security_rules.tf
# - nat_rules.tf
# - INTERFACE_MIGRATION_REPORT.txt β NEW - Critical for migration planning
# - README.md- Device β Setup β Operations
- Save named Panorama configuration snapshot
- Download and extract XML
ssh admin@panorama
> set cli config-output-format xml
> configure
# show
> save config to export.xmlcurl -k -X GET 'https://panorama/api/?type=export&category=configuration&key=KEY' -o config.xmlINTERFACE AND IP ADDRESS MIGRATION REPORT
Generated for Firewall Migration Planning
ETHERNET INTERFACES (4)
--------------------------------------------------------------------------------
Interface: ethernet1/1
Type: ethernet
Mode: layer3
Comment: Trust Interface - Internal Network
IPv4 Addresses:
- 10.1.1.1/24
IPv6 Addresses:
- 2001:db8::1/64
Management Profile: Ping-Only
Interface: ethernet1/2
Type: ethernet
Mode: layer3
Comment: Untrust Interface - Internet Connection
IPv4 Addresses:
- 203.0.113.1/30
Management Profile: Allow-All
MIGRATION CHECKLIST
1. Review interface naming differences between platforms
2. Map source interfaces to target platform interfaces
3. Verify IP addressing scheme is compatible
...
- Create credentials file (
terraform.tfvars):
panos_hostname = "panorama.example.com"
panos_username = "admin"
panos_password = "your-password"
device_group = "Production-DG"- Initialize Terraform:
cd terraform_output
terraform init- Review changes:
terraform plan- Apply configuration:
terraform apply- Complete zone configurations
- Interface definitions with IP addresses
- Virtual router and static routes
- Security profile references
- All policy rules
- Address and service objects
- Interface adjustments - Adapt to target platform hardware
- Security profile details - Full rule definitions
- VPN configurations
- GlobalProtect settings
- HA configurations
- Management interface specifics
- β Always test in lab first - Critical for successful migration
- β
Review
INTERFACE_MIGRATION_REPORT.txtbefore starting - β Create interface mapping table for source β target
- β Backup existing configuration
- β Verify interface naming for target platform
- β Use version control (Git)
- β Apply changes incrementally
- β
See
MIGRATION_GUIDE.mdfor detailed procedures
- Ensure XML is valid and complete
- Re-export from Panorama if corrupted
- Review target platform interface naming conventions
- Update
interfaces.tfaccordingly - See platform-specific notes in interface report
- Check device group permissions
- Verify shared resource access
- Ensure interfaces exist before zones
- Use Terraform
depends_onif needed
- MIGRATION_GUIDE.md - Complete migration workflow and procedures
- USAGE_GUIDE.md - Technical documentation and API details
- example_interface_report.txt - Sample interface inventory
- README.md - This overview
- β Migrating between Palo Alto hardware platforms
- β Physical to VM-Series migrations
- β VM-Series to physical migrations
- β Platform upgrades (e.g., PA-3000 β PA-5000)
- β Configuration standardization across devices
- β Disaster recovery planning
- β Configuration version control
- β Multi-vendor migrations (Palo Alto only)
- β Complex VPN configurations (manual setup needed)
- β GlobalProtect (not in export)
Current Version: 4.0.0 - Production-Ready Edition
- β¨ Production-tested on 133,000-line config with 10,000+ objects
- β¨ 16 new object types: Tags, Custom URLs, App Groups/Filters, PBF, Decryption, etc.
- β¨ Terraform Provider 2.0.7 support
- β¨ 36 total object types (was 20 in v3.0)
- β¨ Enhanced interfaces: Tunnel, Aggregate, Subinterfaces
- β¨ Complete coverage: 95%+ of common Palo Alto objects
- β¨ 31 Terraform files generated (was ~15)
- β¨ See
VERSION_4.0_COMPLETE_COVERAGE.mdfor full details
- BGP and OSPF routing protocol support
- IPsec VPN with IKE gateway/tunnel configuration
- VPN key management reporting
- Multi-virtual-router migrations
- Automatic device group splitting
- Zone configuration parsing and generation
- Interface configuration with IP addresses
- Virtual router and static route support
- Security profile and profile group support
- INTERFACE_MIGRATION_REPORT.txt generation
- Platform-specific migration guidance
- Core configuration parsing
- Address/service object support
- Security/NAT rule conversion
- Basic Terraform generation
This project is dual-licensed:
GNU Affero General Public License v3 - Free for open source use
- β Free to use, modify, and distribute
β οΈ Must release source code if distributed or deployed as serviceβ οΈ Modifications must be AGPL v3- See LICENSE-AGPL for full terms
Proprietary License - For commercial/proprietary use
- β Use in closed-source products
- β No source code release required
- β Deploy as SaaS without sharing code
- β Commercial support included
- See LICENSE-COMMERCIAL for details
Use AGPL v3 (Free) if:
- Building open source projects
- Willing to share your source code
- Using internally and can share modifications
- Learning or experimenting
Buy Commercial License if:
- Building commercial/proprietary products
- Running as SaaS for clients
- Cannot release your source code
- Need commercial support and warranty
- Embedding in proprietary software
π Detailed comparison: See DUAL-LICENSING-EXPLAINED.md
πΌ Purchase commercial license: Contact [Your Email]
| Feature | AGPL v3 | Commercial |
|---|---|---|
| Cost | FREE | Paid |
| Proprietary use | β | β |
| SaaS deployment | β | |
| Support | Community | β Professional |
| Must release code | β | β |
- Review
MIGRATION_GUIDE.mdfor detailed procedures - Check
INTERFACE_MIGRATION_REPORT.txtfor interface planning - Test in lab environment first
- Consult Palo Alto platform compatibility matrix
- Review generated files
- Check Terraform validation output
- Consult provider documentation
- Validate XML export
π― New Feature: Logical Routers (PAN-OS 10.2+)
- Added support for Advanced Routing Engine logical routers
- Automatically detects and parses both virtual routers (legacy) and logical routers
- Generates Terraform for mixed VR/LR configurations
- Properly identifies router types in generated files
- Impact: Full support for PAN-OS 10.2+ Advanced Routing Engine migrations
- See ADVANCED-ROUTING-ENGINE-SUPPORT.md for details
π Fixed: Multiple Critical Issues
1. Virtual Router Multi-VR Support:
- Critical Fix: Virtual routers missing when names duplicated across templates
- Added template-aware parsing with interface signature deduplication
- Now captures ALL VRs including multi-VR templates and duplicate names
- Impact: Configs with multiple templates now get all VRs (e.g., found 7 instead of 6)
- See MULTI-VR-FIX.md for technical details
2. Split Device Groups Script:
- Critical Fix: split_device_groups.py missing 99% of objects in split files
- Fixed: Only copied first
<shared>section (Panorama has 11+ sections) - Fixed: Duplicate device group detection
- Now merges ALL shared sections into split files
- Impact: Split files now include all 3,699 addresses, 430 services, etc. (was 0)
- See SPLIT-SCRIPT-FIX.md for technical details
Action Required:
β οΈ If you have multiple templates with VRs: Regenerate your filesβ οΈ If you used split_device_groups.py: Re-split to get all objects
π Fixed: Shared Object References
- Critical Fix: Objects with empty values/members in Terraform output
- Added detection and filtering of reference-only entries (entries with only
<id>tags) - Changed parse order to prioritize device-group definitions over shared references
- Fixed 4 parsing methods: address objects, address groups, service objects, service groups
- Impact: All objects now have correct values populated
- See SHARED-OBJECT-REFERENCE-FIX.md for technical details
β οΈ If you used v4.0.0, regenerate your Terraform files
π Major Release
- Added 16 new object types (tags, custom URLs, app groups/filters, external lists, decryption, PBF, etc.)
- Expanded from 20 to 36 object types (80% increase)
- Updated to Terraform Provider 2.0.7
- Tested on 133,411-line production config with 10,299 objects
- Achieved 95%+ coverage of Palo Alto objects
- 100% success rate on production data
- Applied AGPL v3 + Commercial dual licensing
π Advanced Networking
- Added BGP support with peer configuration
- Added OSPF support with area configuration
- Added VPN support (IKE gateways, IPsec tunnels, crypto profiles)
- Added device group splitting utility
- Added multi-VR migration workflows
π Network Infrastructure
- Added zone support
- Added interface support (ethernet, VLAN, loopback, tunnel, aggregate)
- Added virtual router support
- Added static route support
- Comprehensive documentation
π― Foundation
- Basic object support (addresses, services, rules)
- Security policy conversion
- NAT policy conversion
- Address and service object/group support
Made with β€οΈ for Network Engineers migrating Palo Alto firewalls to different platforms
π₯ Perfect for platform upgrades, physical-to-VM migrations, and infrastructure modernization projects